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
  • Hi Filip,

    To change the value for the MeasuredValue attribute for the CarbonDioxideConcentrationMeasurement cluster (and similar), you need to use SetMeasuredValue. You can see a usage example in air-quality-sensor-manager.cpp.

    Best regards,

    Maria

  • 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?

  • Hi,

    did anybody have a time to take a look at my problem with settng measured data? I investigate it a little bit and I find out that it logs the following to the console at startup:

    <err> chip: [DMG]Endpoint 1, Cluster 0x0000_040D not found in IncreaseClusterDataVersion!

  • Hi Filip,

    Thank you for your patience.

    When I returned to this case today, I made sure to read the Matter specification along with it, and I found that the CarbonDioxideConcentrationMeasurement cluster should be more similar to the RelativeHumidityMeasurement you shared as an example. Neither cluster has write access for their MeasuredValue attribute, yet you are able to use Set on the Relative Humidity.

    I will contact the developers about this so we can find out what the proper functionality is.

    Best regards,

    Maria

  • Hi Maria,

    Thank you for your update.
    I tried to impelemnt Set function for sending MeasuredValue for CarbonDioxide cluster the same way as for Temperature measurement. here is the implemented function:

    EmberAfStatus Set(chip::EndpointId endpoint, float value)
    {
        using Traits = NumericAttributeTraits<float>;
        if (!Traits::CanRepresentValue(true, value))
        {
            return EMBER_ZCL_STATUS_CONSTRAINT_ERROR;
        }
        Traits::StorageType storageValue;
        Traits::WorkingToStorage(value, storageValue);
        uint8_t* writable = Traits::ToAttributeStoreRepresentation(storageValue);
        return emberAfWriteAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, writable, ZCL_SINGLE_ATTRIBUTE_TYPE);
    }

    but the return value is EMBER_ZCL_STATUS_FAILURE. I'm not sure, but it looks like its returning the value from this line https://github.com/project-chip/connectedhomeip/blob/3718e996b56f36a553c1b4571f77728396590776/src/app/util/attribute-storage.cpp#L656.

    I noticed one interesting thing. In zap tool, The Storage option for MeasuredValue of CarbonDioxide measurement is grayed out and I cannot change that to RAM. 

Related