Matter setting CarbonDioxideConcentrationMeasurement value.

Hello,

I am developing matter sensor and I would like to send data to `MeasuredValue` attribute of `CarbonDioxideConcentrationMeasurement` cluster. I followed this tutorial https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/protocols/matter/getting_started/adding_clusters.html. The only thing I changed is that I turned on CO2 cluster and its attribute `MeasuredValue`. I wanted to set the value with this piece of code:

Clusters::CarbonDioxideConcentrationMeasurement::Attributes::MeasuredValue::Set(cluster_id, co2_val);
, but it turned out `Set` function does not exist for `CarbonDioxideConcentrationMeasurement`.
All those `Set` functions are implemented in Accessors.h which is located in `sdk_path/modules/lib/mater/zzz_generated` and I wonder when was this folder generated and why it does contain `Set` functions for clusters used in the samples and not for others. I could implement my own "accessor" for the required cluster, but I would like to ask if I'm missing something, because there is no `Accessors.h` inside my src/zap-generated folder.
Thank you for your answer.
Best regards,
Filip Mrazek
Parents Reply Children
  • Hello Maria,

    First of all, thank you for your answer. I tried to change my code according to the example you sent. My code looks something like that:

    in header file:
    ConcentrationMeasurement::Instance<true, true, true, true, true, true> co2_cluster;
    
    in source file constructor:
    Constructor::Constructor()
        : co2_cluster(1, 
            CarbonDioxideConcentrationMeasurement::Id, 
            ConcentrationMeasurement::MeasurementMediumEnum::kAir,
            ConcentrationMeasurement::MeasurementUnitEnum::kPpm)
    {
        co2_cluster.Init();
    }
    
    void send_data(float value)
    {
        co2_cluster.SetMeasuredValue(DataModel::Nullable<float>(value));
        LOG_INF("data sent");
    }

    The code compiles, but if I try it, the CO2 value is missing. (I'm trying it with python matter server). On the other hand, I can see all other values (like temperature, humidity) which were send with the following code.

    Clusters::RelativeHumidityMeasurement::Attributes::MeasuredValue::Set(1, value);

    Am I missing something in the example?

Related