This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Thermostat cluster enable issue

Hi All,

I am developing product using nRF52840 and SDK nRF5_SDK_for_Thread_and_Zigbee_v3.0.0_d310e71.

This product is basically, using the Thermostat cluster and Zigbee protocol to communicate with the Zigbee gateway.

So, I referred light_bulb example and followed steps to enable "Thermostat cluster and attributes".

I have included the respective files also but I am unable to execute the below callback function case statement,

static zb_void_t zcl_device_cb(zb_uint8_t param)
{
    zb_uint8_t                       cluster_id;
    zb_uint8_t                       attr_id;
    zb_buf_t                       * p_buffer = ZB_BUF_FROM_REF(param);
    zb_zcl_device_callback_param_t * p_device_cb_param =
                     ZB_GET_BUF_PARAM(p_buffer, zb_zcl_device_callback_param_t);

    NRF_LOG_INFO("zcl_device_cb id %hd", p_device_cb_param->device_cb_id);

    /* Set default response value. */
    p_device_cb_param->status = RET_OK;

    switch (p_device_cb_param->device_cb_id)
    {
        case ZB_ZCL_SET_ATTR_VALUE_CB_ID:
            cluster_id = p_device_cb_param->cb_param.set_attr_value_param.cluster_id;
            attr_id    = p_device_cb_param->cb_param.set_attr_value_param.attr_id;

            if (cluster_id == ZB_ZCL_CLUSTER_ID_THERMOSTAT)
            {
                uint16_t value = p_device_cb_param->cb_param.set_attr_value_param.values.data16;

                NRF_LOG_INFO("thermostat local temperature: %d", value);
                if (attr_id == ZB_ZCL_ATTR_THERMOSTAT_LOCAL_TEMPERATURE_ID)
                {
                    local_temperature_value(value);
                }
            }
            else
            {
                /* Other clusters can be processed here */
                NRF_LOG_INFO("Unhandled cluster attribute id: %d", cluster_id);
            }
        break;

        default:
            p_device_cb_param->status = RET_ERROR;
            break;
    }

    NRF_LOG_INFO("zcl_device_cb status: %hd", p_device_cb_param->status);
}

Also, I am attaching code for reference please let me know what else I forgot to enable the functions. It is urgent for me to solve this issue.

Radiator_nRF_v0.9.0.zip

And, with these attributes, for some of the commands, I need to implement custom attributes so if you share how to add custom attributes to this cluster.

Thanks in advance.

Regards,

Rohit R

Parents
  • Hi Marte,

    Thank you for the details, 

    As of now, sending custom command is pending. I will work on this in some time. 

    But current requirement I am trying to enabled the required attributes list. With reference to your code and other I have created extended list also. 

    But unoccupied, min and max, local_calibration and etc are not getting highlighted from thermostat cluster. And also Battery percentage attribute also facing same problem. they are not getting highlighted and these are must attributes (mandatory ids). 

    I have tested in SDK 3.0 I am getting highlighted below points but in SDK 4.1 i am facing this issue. Let me know why?

    Below is the image attached for both cluster. And also my thermostat.h file please check what is wrong. Why I am not getting these attributes highlighted. 

    0508.zb_zcl_thermostat.h

    5807.zb_zcl_power_config.h

    Thanks and regards

    Rohit 

  • Hi Marte, 

    Any update on this. 

    Urgent!

    Is there any difference in my file. 

    Thanks and Regards

    Rohit R

  • Hi Marte, 

    Thank you I will wait for your response. Please let me know as early as possible.

    what the best way to do it when you want to wake up on received Zigbee commands and GPIO interrupt

    - Yes, more focus on wake up on zigbee commands from gateway ( first priority) and then GPIO as (second priority). 

    - But also, check my comments shared. Am I following correct steps or not? If I am doing anything wrong here then correct me. I will follow the steps and again check for current consumption. 

    Thanks and Regards

    Rohit R

  • Hi Rohit,

    You should not call nrf_pwr_mgmt_run() in the main loop yourself. When you call zboss_main_loop (or zboss_main_loop_iteration if you want to include custom features) in main you simply start the Zigbee stack, and the stack will interact with the application using stack signals (zboss_signal_handler) and ZCL callbacks (zcl_device_cb). So all of this is handled internally by the stack after you start the main loop. This includes the signal that it can go to sleep. The stack decides that it has nothing more to do, as there are no stack tasks or anything in the queue that needs to be handled, so the stack informs the device that it can go to sleep or power down. This will cause zb_osif_go_idle to be called automatically. This function checks if the logger has anything to process and calls the function zb_osif_wait_for_event, which in turn calls the nrf_pwr_mgmt_run API. You can see part of this in the flowchart below, which is from the page about Zigbee stack sleep routines in our documentation. Since your device is not a sleepy end device, the third step will result in no, since "rx_off_when_idle" is not true, and it will go to zb_osif_go_idle.

    While I wait for a response from the developers, you can also take a look at Powering down RAM sections to further reduce current consumption by powering down sections of the RAM memory that are not used by the application.

    Best regards,

    Marte

  • Hi Marte, 

    Thank you for the response. 

    Sorry my mistake, I have made confusion while explaining. 

    You should not call nrf_pwr_mgmt_run() in the main loop yourself.

    - This example is peripheral code. I have made one of example copy and followed some online tutorial steps to run this API. 

    When you call zboss_main_loop (or zboss_main_loop_iteration if you want to include custom features) in main you simply start the Zigbee stack, and the stack will interact with the application using stack signals (zboss_signal_handler) and ZCL callbacks (zcl_device_cb). So all of this is handled internally by the stack after you start the main loop. This includes the signal that it can go to sleep. The stack decides that it has nothing more to do, as there are no stack tasks or anything in the queue that needs to be handled, so the stack informs the device that it can go to sleep or power down. This will cause zb_osif_go_idle to be called automatically.

    - Yes, This is present in my radiator code. Here I have not added anything in while loop(). I kept code same as present in light_bulb code. With this only I have tested the current and it gave me 0.03mA after discovery. Where my Radiators STM base board and nRF52 Dev-kit connected. I want battery to life 2 years so I need almost 1uA current that too only my RF board (nRF should consume 1uA current). 

    While I wait for a response from the developers,

    - ya , sure please let me know i will wait for positive response. 

    you can also take a look at Powering down RAM sections to further reduce current consumption by powering down sections of the RAM memory that are not used by the application.

    - Okay, I will check this part too. 

    Thank you so much.  

    Regards, 

    Rohit R

  • Hi Marte, 

    I went through the Power down RAM section. Here, It is mentioned that use zigbee_power_down_unused_ram() function from  Zigbee application components. If I tried to search API/ function here it says zero result. 

    Similarly, Checked the light_switch example as it was mentioned in link for reference but in example alsp it says zero result. Am I following anything wrong here?

    Hi, I got this. zigbee_power_down_unused_ram() this present in light_switch SDK4.1 example and helper.c file but not present in SDK3.0. 

    Can we use in SDK 3.0 ? If yes the How to handle it in helper.c file or any other file. 

    Thanks and Regards

    Rohit R

  • Hi Marte, 

    Any update from developer? I need urgent help. 

    And, how to enable this below configuration 

    "ION_RAMOFF_EVENT System ON, no RAM retention, wake on any event 0.97 μA" typically. 

    can you explain me the configuration for same. 

    Thanks and Regards

    Rohit R

Reply Children
  • Hi Rohit,

    Due to summer vacation you might have to expect some increase in response time, also from our developers.

    As for current consumption, you will notice a significant increase in current consumption when not using Sleepy End Device (SED) compared to a device with SED enabled. This is because with other low power modes, the radio is still always on, causing a much higher current consumption than if it is off. With SED the other hand, the radio will be off when it sleeps. However, this will make it so that the device will not be able to receive messages at all times, and cannot wake up by a command from another device, as it will not receive the message when it is sleeping. So you will have to either use SED and have the radio off at times, or you will have to have a higher current consumption. A device implemented as a SED will wake up periodically to check for messages, as I have explained earlier. It will do this by polling it's parent and asking the parent if there are any messages for it, as the parent store the messages for some time so that the SED will receive them on wake up. You can change the poll interval with zb_zdo_pim_set_long_poll_interval, to make the sleepy end device poll it's parent at a shorter interval than the default one.

    Rohit Rajapure said:
    Can we use in SDK 3.0 ? If yes the How to handle it in helper.c file or any other file. 

     The best option would be to use SDK 4.1.0 instead, but since that is not an option, you can try to add the function zigbee_power_down_unused_ram to your project yourself, as the implementation of the function is available in v4.1.0, and not an internal stack function. To do this, you must add the function to your SDK, as well as any dependencies of that function. I cannot guarantee that it will work, as there might be other changes between v3.0.0 and v4.1.0 affecting this, but it should be possible to power down the unused RAM in v3.0.0 as well.

    Rohit Rajapure said:
    "ION_RAMOFF_EVENT System ON, no RAM retention, wake on any event 0.97 μA" typically. 

     This mode and current is for the base current consumption of the chip in ON idle mode.

    • System ON: This means that the chip is in system ON, and not in system OFF, which means that the chip is in a regular state ready to run, and that the CPU is in sleep mode. The CPU is in a WFE (waitinf for event) call, and will wake when there is an interrupt. This interrupt is typically the RTC clock, but with 1 μA. the RTC is not in use.
    • no RAM retention: this means that the RAM is not conserved, and will practically mean that there is no code running on the chip.

    So you will not be able to get this current consumption and still run your application on your device. You will minimally need RAM retention, RTC to wake up at intervals, and the LF clock, which is needed for RTC. Therefore, your current consumption will be above 1 μA, even if you are using SED and powering down RAM sections. According to the specification, the expected current consumption with RAM retention and RTC is as follows:

    ION_RAMON_RTC
    System ON, full 256 kB RAM retention, wake on RTC (running from LFRC clock)
    3.16 
    µA

     However, since you are able to power down unused parts of RAM, you will not have full 256 RAM retention, which will reduce current compared to the above. Additionally, you can use LFXO as a clock source instead of LFRC, and use an external crystal, which will have slightly lower current consumption than using LFRC.

    Best regards,

    Marte

  • Hi Marte, 

    Thank you so much for response, 

    Due to summer vacation you might have to expect some increase in response time, also from our developers.

    - Okay, i will wait but need help.

    As for current consumption, you will notice a significant increase in current consumption when not using Sleepy End Device (SED) compared to a device with SED enabled. This is because with other low power modes, the radio is still always on, causing a much higher current consumption than if it is off. With SED the other hand, the radio will be off when it sleeps. However, this will make it so that the device will not be able to receive messages at all times, and cannot wake up by a command from another device, as it will not receive the message when it is sleeping. So you will have to either use SED and have the radio off at times, or you will have to have a higher current consumption. A device implemented as a SED will wake up periodically to check for messages, as I have explained earlier.

    - Okay, If I configure as SED. It will give comparatively less current than getting now correct?

    - And, If I just call sleep now () in zigbee_signal_handler means it is configured as SED. And I can comment this part from code to make SED? Correct? 

    zb_void_t zb_osif_go_idle(zb_void_t)
    {
    //TODO: implement your own logic if needed
    zb_osif_wait_for_event();
    }

    - And, in SED device wake up every 10sec correct? I read in one of the nordic link. 

    The best option would be to use SDK 4.1.0 instead, but since that is not an option, you can try to add the function zigbee_power_down_unused_ram to your project yourself, as the implementation of the function is available in v4.1.0, and not an internal stack function. To do this, you must add the function to your SDK, as well as any dependencies of that function. I cannot guarantee that it will work, as there might be other changes between v3.0.0 and v4.1.0 affecting this, but it should be possible to power down the unused RAM in v3.0.0 as well.

    - Okay, I will check. 

     However, since you are able to power down unused parts of RAM, you will not have full 256 RAM retention, which will reduce current compared to the above. Additionally, you can use LFXO as a clock source instead of LFRC, and use an external crystal, which will have slightly lower current consumption than using LFRC.

    - No, I have note configured yet. But would like to configure. But LFRC give me better result then how to configure this? Is there any example for reference? 

    Thanks and Regards

    Rohit R

  • Hi Marte, 

    Any update on above post?

    My understanding is correct to configure SED device?If yes, then will configure likewise and test for current. Let me know your feedback.

    Thanks and Regards

    Rohit R

  • Hi Rohit,

    Rohit Rajapure said:
    If I configure as SED. It will give comparatively less current than getting now correct?

     Yes, that is correct.

    Rohit Rajapure said:
    And, If I just call sleep now () in zigbee_signal_handler means it is configured as SED

    This is not entirely correct.

    To configure the device as a SED you must call zb_set_rx_on_when_idle(ZB_FALSE) in main, such as in the multi sensor example. This enables sleepy behavior and makes your device act as a Sleepy End Device.

    You are correct in that you must call zb_sleep_now() in zboss_signal_handler(), when receiving the signal ZB_COMMON_SIGNAL_CAN_SLEEP. Again, you should do as in the multi sensor example.

    Rohit Rajapure said:
    And I can comment this part from code to make SED? Correct? 

     Yes, with SED you will use zb_sleep_now() to put the device and radio to sleep, and you can remove zb_osif_go_idle() from main.c. The function zb_osif_go_idle() is not really necessary to have in main.c if you are not using SED either, as it is already implemented in external/zboss/osif/zb_nrf52840_common.c. The only reason to use it in main.c is if you want to override the function to make it do something else than what it does in the implementation in zb_nrf52840_common.c.

    Rohit Rajapure said:
    But LFRC give me better result then how to configure this? Is there any example for reference? 

     You can read about the clock sources for the LFCLK controller here: LFCLK controller. Further down on that page you will find 32.768 kHz crystal oscillator (LFXO), where you can read about LFXO.

     You can see more about typical current consumption for nRF52840 in the electrical specification, where you can find information such as sleep current and radio transmitting/receiving current. The nRF52840 specification does not show the typical current for using LFXO, only LFRC, but the electrical specification for some of the other SoCs does, to show a comparison between using LFRC and LFXO as clock source:

    ION_RAMON_RTC System ON, Full 24 kB RAM retention, Wake on RTC (running from LFRC clock) 1.5 µA 
    ION_RAMON_RTC_LFXO System ON, Full 24 kB RAM retention, Wake on RTC (running from LFXO clock) 1.1 µA

    Please note that the above numbers are from another SoC than the nRF52840 and has different typical current consumption than nRF52840.

    Best regards,

    Marte

  • Hi Marte, 

    Thank you for the response, 

    To configure the device as a SED you must call zb_set_rx_on_when_idle(ZB_FALSE) in main, such as in the multi sensor example. This enables sleepy behavior and makes your device act as a Sleepy End Device.

    You are correct in that you must call zb_sleep_now() in zboss_signal_handler(), when receiving the signal ZB_COMMON_SIGNAL_CAN_SLEEP. Again, you should do as in the multi sensor example.

    - Okay, Noted.

     Yes, with SED you will use zb_sleep_now() to put the device and radio to sleep, and you can remove zb_osif_go_idle() from main.c. The function zb_osif_go_idle() is not really necessary to have in main.c if you are not using SED either, as it is already implemented in external/zboss/osif/zb_nrf52840_common.c. The only reason to use it in main.c is if you want to override the function to make it do something else than what it does in the implementation in zb_nrf52840_common.c.

    - Okay, Noted.

    You can read about the clock sources for the LFCLK controller here: LFCLK controller. Further down on that page you will find 32.768 kHz crystal oscillator (LFXO), where you can read about LFXO.

     You can see more about typical current consumption for nRF52840 in the electrical specification, where you can find information such as sleep current and radio transmitting/receiving current. The nRF52840 specification does not show the typical current for using LFXO, only LFRC, but the electrical specification for some of the other SoCs does, to show a comparison between using LFRC and LFXO as clock source:

    - Okay, I will check. 

    I have noted down your points for configuring SED. And as per your previous post I have discussed your points about SED with my team. But  they are like we will test the current default code on custom hardware and check the current. 

    - After testing default code on custom it gave us 3.9mA. This is too high. We are testing again on Dev-kit as well as custom. I will get back to you on result early. 

    And they want device should wake up Zigbee commands( it must) as per client requirement. But since nordic developer are busy. I will wait for something can we do here. But need help as early as possible make system wake up on Zigbee command and sleep if no commands. - Need help for this.

    One more update from my end. 

    - There is one feature in my device, that is perform "network leave or erase the current connect coordinator info"

    - To this what I done is, used zigbee_erase_persistent_storage() and set ZB_TRUE; this means by setting true it will erase the info. 

    - I did the same but it not erasing nor performing NVIC_SystemReset() correctly. 

    - My requirement is I have long button press which result in Reset of my STM8 board and that give me signal to nRF board (node) and I have perform erase info and softreset the device and start again. 

    Let me know whether I have followed correct API to execute this erase info and NVIC_SystemReset() is for software? 

    Thanks and Regards

    Rohit R

Related