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

Zigbee light_bulb turns full On(100%) instead of setting to 10% level

Hello All,

I am developing a light control device using Zigbee and Alexa. I am using an nRF52840 device and SDK nRF5_SDK_for_Thread_and_Zigbee_v3.0.0_d310e71.

For my development, I have referred to light_bulb code as per nordic engineer suggestion and made the respected changes to communicate with Alexa.

Till now everything is working perfectly fine without any issue even On dev-kit and my custom hardware so while testing corner cases on my hardware.

I came to know that if I send the "Alexa set 0 percent" command from the Alexa device it turns OFF correctly. But if I give "Alexa Turn ON" then it takes 100 percent (100%) not 10% or 20% which was my previous set level before setting to 0%.

But If I use the "Alexa Turn ON" and "Alexa Turn OFF" command then I get the expected result means example. If I set the level to 20% and then gave the OFF command it turns OFF and If I say "Alexa turn ON" then it turns ON to the set level which is 20%.

Only, If give "Alexa set 0 percentage" and "Alexa Turn ON" I facing this 100% ON instead of the previous level.

This same case happing in SDK's light_bulb code.

So please let me know the reason behind this? And also can we change as per our requirement? If yes, then share the steps so that we can keep command execution identical in all cases.

Thanks and Regards

Rohit R

  • Hi Edvin

    I am not able to see (value) in the watch window.

    I have managed my variable in light_bulb_onboard_set_brightness(zb_uint8_t brightness_level) function and assigned globle variable to this (brightness_level * 100U) / 255U;

    There I come to know it is giving me 99 value.

    But when the Turn On / Off command value show me in variable 10 or 20 whatever user set.

    And what might be happening is level_control_set_value() cluster_id is executing twice like I said test case in the previous post after command dim 0% to turn On transaction. And only once this cluster executing when we give Turn On/Off command.

    But how to manage or to avoid this twice execution level_control_set_value(value); clustore not understanding.

    This is my test result. I might be wrong.

    Let me know your view.

    Thanks and Regards

    Rohit R

  • Rohit Rajapure said:
    I am not able to see (value) in the watch window.

     Either you need to disable optimization, or you can monitor the log. What does the log say?

  • Hi,

    Ya, I tried to log on Putty but do not know why the log is not printing on putty.

    I tried with 9600 and 115200 baud rates.

    no logs are printing.

    Sorry, but due to urgency in the requirement, I am asking you one more question which not related to this topic.

    I got a new requirement from the hardware team that Using GPIO interrupt can we execute a Soft reset and start from the main function.

    As I am new to this nrf, and as per my study nRF52840 light_bulb example does not use soft devices so I do not know how to soft reset the device using interrupt. 

    Can you please let me know can we perform this action on pin interrupt? if yes, then which all files need to be included and enable the API.

    Sorry, again as a team is preparing the next version of hardware so it is urgent for me to clear the things before they make any changes. So I am asking this question here.

    Please let me know how we can do this.

    Thanks for understanding.

    Thanks and Regards

    Rohit R

  • The log backend in the Zigbee examples is described in sdk_config.h:

    // <o> NRF_LOG_BACKEND_UART_BAUDRATE  - Default Baudrate
     
    // <323584=> 1200 baud 
    // <643072=> 2400 baud 
    // <1290240=> 4800 baud 
    // <2576384=> 9600 baud 
    // <3862528=> 14400 baud 
    // <5152768=> 19200 baud 
    // <7716864=> 28800 baud 
    // <10289152=> 38400 baud 
    // <15400960=> 57600 baud 
    // <20615168=> 76800 baud 
    // <30801920=> 115200 baud 
    // <61865984=> 230400 baud 
    // <67108864=> 250000 baud 
    // <121634816=> 460800 baud 
    // <251658240=> 921600 baud 
    // <268435456=> 1000000 baud 
    
    #ifndef NRF_LOG_BACKEND_UART_BAUDRATE
    #define NRF_LOG_BACKEND_UART_BAUDRATE 268435456
    #endif

    So by default it uses baudrate: 1000000, buy you can change it to 115200 by setting the value "30801920".

    You can do a soft reset using the function NVIC_SystemReset(); If you want to do this on a pin interrupt, you need to set up a pin interrupt for the pin you want to use.

    In the light bulb example, there is a function called buttons_handler(). Try adding this to the event handler:

            case BSP_EVENT_KEY_1:
                NRF_LOG_INFO("Button 2 pressed");
                break;

    And if you want to reset based on that button press, then you can add NVIC_SystemReset(); to that event. Note that the log probably won't finish printing before the reset.

    BR,
    Edvin

  • Hi Edvin,

    Thank you so much for your response,

    I will make the baud rate changes and test the same.

    Here is my log file. dim 0% and turn ON command,

    <info> app: Set level value: 255
    <warning> app: Production config is not present or invalid
    <info> app: Joined network successfully
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 255
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 26
    <info> app: Set level value: 26
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 1
    <info> app: Set level value: 1
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 1
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 254
    <info> app: Set level value: 254
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 254
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 52
    <info> app: Set level value: 52
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 52
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 1
    <info> app: Set level value: 1
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 1
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 254
    <info> app: Set level value: 254
    <info> app: zcl_device_cb status: 0
    

    You can do a soft reset using the function NVIC_SystemReset(); If you want to do this on a pin interrupt, you need to set up a pin interrupt for the pin you want to use.

    - Okay, I will do the changes as per your suggestion and test using light_bulb.

    And thank you so much for these soft reset feature details. I will get back to you with the testing.

    - I am able to reset the device after pin interrupt.

    My requirement for testing is,

    - Read GPIO interrupt and after 5sec soft reset the device (NVIC_SystemReset()). which working after making changes as per your suggestion.

    - along with reset one more thing I need to perform is Erase Bonding information of Alexa device from my hard ware device. As per my study I need to just make changes in below ling,

    zigbee_erase_persistent_storage(ZB_TRUE);  //Erase Alexa hardware device bonding information

    Set TRUE, it will perform the erase but I tried the same it is not working. Still device connected to Alexa.

    Let me know if I am doing wrong in erasing.

    Once again thank you so much Slight smile

    Thanks and Regards

    Rohit R

Related