Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zigbee home automation profile's Thermostat cluster

Hello Everyone,

I am developing one product for the HVAC system. I have Radiator and STM's primary MCU. For development, I need to configure the thermostat cluster ID for controlling the Radiator command using the Zigbee gateway.

My System is as follows,

nRF52840 Zigbee MCU communicates STM's MCU via UART, there happens a command exchange between these 2 MCU's. And user gives a command using Zigbee base Gateway for cloud communication.

So, for this, I need a thermostat cluster-ID and controlling commands and ids.

I tried to find the document for the same but I could not.

Can anyone help me with how to enable the thermostat cluster in light_bulb code and modify it as per my requirement. Any documents or links would help me to study the same.

Thanks and Regards

Rohit R

  • Hi Rohit,

    The cluster ID for the thermostat cluster is 0x201. You can find this, as well as any other IDs and information about standard Zigbee clusters in the Zigbee Cluster Library specification. In revision 6, which can be found here, the cluster list is found in chapter 6.1.3, and the thermostat cluster is found in chapter 6.3. The thermostat cluster consists of two attribute sets: thermostat information (0x000) and thermostat settings (0x001), both of which has their own lists of attributes. These attributes and their corresponding IDs are all found in the specification.

    Standard Zigbee clusters are also defined in the file external\zboss\include\zcl\zb_zcl_common.h in the SDK, where you can find the thermostat cluster identifier ZB_ZCL_CLUSTER_ID_THERMOSTAT.

    As for implementing the thermostat cluster into your application, I would recommend taking a look at the information about implementing a Zigbee product with ZCL.

    Best regards,

    Marte

  • Hi Marte,

    Thank you for the quick response,

    I will go through the chapters.

    As for implementing the thermostat cluster into your application, I would recommend taking a look at the information about implementing a Zigbee product with ZCL.

    - So means with reference to this, using light_bulb as a base code I can change the thermostat cluster in the main file. And use as per my requirement. Correct?

    - And I told you host and master communication happens using UART. Here, the master is our nRF MCU so can I use the default UART pin 8 and 6. For my communication, I disable in SDK_Config file or can I use other others as UART? If, yes then please let me know the UART configuration tutorial link. like how it is there for the app_timer tutorial.

    - For UART communication, referred the SDK/peripheral/uart example and tried to communicate between nRF - Dev kit and Texas Dev-kit. But I could not do the same.

    What I did is, using nRF UART example just kept the app_uart_put () function and on Texas Dev-kit get() and used put() function to display on putty. But It did not work also I want to use uart_interrupt routine to do this, so I did but if I type single char it start printing same char continuously.

    I want to send multiply data but whenever there is interrupt on UART not continuously. Please share some data or docs about UART use and configure.

    Thanks and Regards

    Rohit R

  • Hi,

    You can add the thermostat cluster to the light_bulb example. However, it must follow the specifications for the thermostat cluster as specified in the Zigbee Cluster  Library specification, which I linked to in my last reply. The cluster itself is already implemented in the SDK, so you do not have to implement it yourself, but you must declare it in your project to use it, just like the different clusters already used in the sample (such as basic cluster, on/off cluster, etc.). You must also declare the attributes in the cluster. The documentation for the cluster in the SDK can be found here, and I really recommend taking a look at that. There you can find the different attributes you can use and other useful information. The implementation of the cluster can be found in external/zboss/include/zcl/zb_zcl_thermostat.h.

    If your requirements does not correspond with how the cluster is implemented, then you will have to implement it as a custom cluster. However, I do not recommend this, and you should instead use it as is specified in the ZCL specification.

    As for UART, I would recommend using the UART driver directly as described here. However, you must be aware that if logging over UART is enabled, then UARTE0 and the standard pins will be used for this, so you must either turn off logging over UART or use UARTE1 for communication between nRF52840 and STM. You do not need to use specific GPIO pins, you can use any of them, but you should avoid using the ones that have "standard drive" as recommended usage. You can see more about pin assignments and recommended usage here.

    Best regards,

    Marte

  • Hi Marte,

    I am not understanding this uart example,

    The flow of code, if I just keep app_uart_put and write some data then it stops at below line,

        NRF_BREAKPOINT_COND;
        // On assert the system can only recover with a reset.

    My snippet

    int main(void)
    {
        uint32_t err_code;

        bsp_board_init(BSP_INIT_LEDS);

        const app_uart_comm_params_t comm_params =
          {
              RX_PIN_NUMBER,
              TX_PIN_NUMBER,
              RTS_PIN_NUMBER,
              CTS_PIN_NUMBER,
              UART_HWFC,
              false,
    #if defined (UART_PRESENT)
              NRF_UART_BAUDRATE_115200
    #else
              NRF_UARTE_BAUDRATE_115200
    #endif
          };

        APP_UART_FIFO_INIT(&comm_params,
                             UART_RX_BUF_SIZE,
                             UART_TX_BUF_SIZE,
                             uart_error_handle,
                             APP_IRQ_PRIORITY_LOWEST,
                             err_code);

        APP_ERROR_CHECK(err_code);

    #ifndef ENABLE_LOOPBACK_TEST
        printf("\r\nUART example started.\r\n");

        while (true)
        {
            uint8_t cr;
            //while (app_uart_get(&cr) != NRF_SUCCESS);
            while (app_uart_put(cr) != NRF_SUCCESS);

            if (cr == 'q' || cr == 'Q')
            {
                printf(" \r\nExit!\r\n");

                while (true)
                {
                    // Do nothing.
                }
            }
        }
    #else

        // This part of the example is just for testing the loopback.
        while (true)
        {
            uart_loopback_test();
        }
    #endif
    }

    What is the explanation for this code? How it is design

    I am trying to put data and print on other Dev-kit. But not working

    And if keep app_uart_put and data in uart_handler() it continuously printing. I am using default Rx and Tx pins now.

    And also, using drv library I tried to execute the following code, but unable to do so. Please help how can I send my data to another device,

    The attached snippet is,

    main.c

    /**
     * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
     * @defgroup uart_example_main main.c
     * @{
     * @ingroup uart_example
     * @brief UART Example Application main file.
     *
     * This file contains the source code for a sample application using UART.
     *
     */
    
    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include "app_uart.h"
    #include "app_error.h"
    #include "nrf_delay.h"
    #include "nrf.h"
    #include "bsp.h"
    #if defined (UART_PRESENT)
    #include "nrf_uart.h"
    #endif
    #if defined (UARTE_PRESENT)
    #include "nrf_uarte.h"
    #endif
    #include "nrf_drv_uart.h"
    
    //#define ENABLE_LOOPBACK_TEST  /**< if defined, then this example will be a loopback test, which means that TX should be connected to RX to get data loopback. */
    
    #define MAX_TEST_DATA_BYTES     (15U)                /**< max number of test bytes to be used for tx and rx. */
    #define UART_TX_BUF_SIZE 256                         /**< UART TX buffer size. */
    #define UART_RX_BUF_SIZE 256                         /**< UART RX buffer size. */
    
    //static const NRF_UART_Type *p_reg;
    const nrf_drv_uart_t UART0 = NRF_DRV_UART_INSTANCE(0);
    
    uint8_t ui8UART0Rx = 0;
    
    void uart0_handle(nrf_drv_uart_event_t *p_event, void *p_contextr)
    {
       nrf_drv_uart_rx(&UART0,&ui8UART0Rx,sizeof(ui8UART0Rx));
       nrf_drv_uart_tx(&UART0,&ui8UART0Rx,sizeof(ui8UART0Rx));
    }
    
    
    
    
    /**
     * @brief Function for main application entry.
     */
    int main(void)
    {
        uint32_t err_code;
    
        nrf_drv_uart_config_t uart0_cfg = NRF_DRV_UART_DEFAULT_CONFIG;
        uart0_cfg.baudrate = NRF_UART_BAUDRATE_115200;
       
    //    uart0_cfg.hwfc = NRF_UART_HWFC_DISABLED;
    //    uart0_cfg.interrupt_priority = 0;
    //    uart0_cfg.parity = NRF_UART_PARITY_EXCLUDED;
        err_code = nrf_drv_uart_init(&UART0,&uart0_cfg,uart0_handle);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_uart_rx_enable(&UART0);       
    }
    
    
    /** @} */
    

    sdk_config.h

    // </e>
    
    // </e>
    
    // <e> NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver
    //==========================================================
    #ifndef NRFX_UARTE_ENABLED
    #define NRFX_UARTE_ENABLED 0
    #endif
    // <o> NRFX_UARTE0_ENABLED - Enable UARTE0 instance 
    #ifndef NRFX_UARTE0_ENABLED
    #define NRFX_UARTE0_ENABLED 0
    #endif
    
    // <o> NRFX_UARTE1_ENABLED - Enable UARTE1 instance 
    #ifndef NRFX_UARTE1_ENABLED
    #define NRFX_UARTE1_ENABLED 0
    #endif
    
    // <o> NRFX_UARTE_DEFAULT_CONFIG_HWFC  - Hardware Flow Control
     
    // <0=> Disabled 
    // <1=> Enabled 
    
    #ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC
    #define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0
    #endif
    
    // <o> NRFX_UARTE_DEFAULT_CONFIG_PARITY  - Parity
     
    // <0=> Excluded 
    // <14=> Included 
    
    #ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY
    #define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0
    #endif
    
    // <o> NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE  - Default Baudrate
     
    // <323584=> 1200 baud 
    // <643072=> 2400 baud 
    // <1290240=> 4800 baud 
    // <2576384=> 9600 baud 
    // <3862528=> 14400 baud 
    // <5152768=> 19200 baud 
    // <7716864=> 28800 baud 
    // <8388608=> 31250 baud 
    // <10289152=> 38400 baud 
    // <15007744=> 56000 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 NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE
    #define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920
    #endif
    
    // <o> NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
    #define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // <e> NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRFX_UARTE_CONFIG_LOG_ENABLED
    #define NRFX_UARTE_CONFIG_LOG_ENABLED 0
    #endif
    // <o> NRFX_UARTE_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef NRFX_UARTE_CONFIG_LOG_LEVEL
    #define NRFX_UARTE_CONFIG_LOG_LEVEL 3
    #endif
    
    // <o> NRFX_UARTE_CONFIG_INFO_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRFX_UARTE_CONFIG_INFO_COLOR
    #define NRFX_UARTE_CONFIG_INFO_COLOR 0
    #endif
    
    // <o> NRFX_UARTE_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRFX_UARTE_CONFIG_DEBUG_COLOR
    #define NRFX_UARTE_CONFIG_DEBUG_COLOR 0
    #endif
    
    // </e>
    
    // </e>
    
    // <e> NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver
    //==========================================================
    #ifndef NRFX_UART_ENABLED
    #define NRFX_UART_ENABLED 1
    #endif
    // <o> NRFX_UART0_ENABLED - Enable UART0 instance 
    #ifndef NRFX_UART0_ENABLED
    #define NRFX_UART0_ENABLED 1
    #endif
    
    // <o> NRFX_UART_DEFAULT_CONFIG_HWFC  - Hardware Flow Control
     
    // <0=> Disabled 
    // <1=> Enabled 
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_HWFC
    #define NRFX_UART_DEFAULT_CONFIG_HWFC 0
    #endif
    
    // <o> NRFX_UART_DEFAULT_CONFIG_PARITY  - Parity
     
    // <0=> Excluded 
    // <14=> Included 
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_PARITY
    #define NRFX_UART_DEFAULT_CONFIG_PARITY 0
    #endif
    
    // <o> NRFX_UART_DEFAULT_CONFIG_BAUDRATE  - Default Baudrate
     
    // <323584=> 1200 baud 
    // <643072=> 2400 baud 
    // <1290240=> 4800 baud 
    // <2576384=> 9600 baud 
    // <3866624=> 14400 baud 
    // <5152768=> 19200 baud 
    // <7729152=> 28800 baud 
    // <8388608=> 31250 baud 
    // <10309632=> 38400 baud 
    // <15007744=> 56000 baud 
    // <15462400=> 57600 baud 
    // <20615168=> 76800 baud 
    // <30924800=> 115200 baud 
    // <61845504=> 230400 baud 
    // <67108864=> 250000 baud 
    // <123695104=> 460800 baud 
    // <247386112=> 921600 baud 
    // <268435456=> 1000000 baud 
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE
    #define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800
    #endif
    
    // <o> NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY
    #define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // <e> NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRFX_UART_CONFIG_LOG_ENABLED
    #define NRFX_UART_CONFIG_LOG_ENABLED 0
    #endif
    // <o> NRFX_UART_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef NRFX_UART_CONFIG_LOG_LEVEL
    #define NRFX_UART_CONFIG_LOG_LEVEL 3
    #endif
    
    // <o> NRFX_UART_CONFIG_INFO_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRFX_UART_CONFIG_INFO_COLOR
    #define NRFX_UART_CONFIG_INFO_COLOR 0
    #endif
    
    // <o> NRFX_UART_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRFX_UART_CONFIG_DEBUG_COLOR
    #define NRFX_UART_CONFIG_DEBUG_COLOR 0
    #endif
    
    // </e>
    
    // </e>
    
    // <e> UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer
    //==========================================================
    #ifndef UART_ENABLED
    #define UART_ENABLED 1
    #endif
    // <o> UART_DEFAULT_CONFIG_HWFC  - Hardware Flow Control
     
    // <0=> Disabled 
    // <1=> Enabled 
    
    #ifndef UART_DEFAULT_CONFIG_HWFC
    #define UART_DEFAULT_CONFIG_HWFC 0
    #endif
    
    // <o> UART_DEFAULT_CONFIG_PARITY  - Parity
     
    // <0=> Excluded 
    // <14=> Included 
    
    #ifndef UART_DEFAULT_CONFIG_PARITY
    #define UART_DEFAULT_CONFIG_PARITY 0
    #endif
    
    // <o> UART_DEFAULT_CONFIG_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 UART_DEFAULT_CONFIG_BAUDRATE
    #define UART_DEFAULT_CONFIG_BAUDRATE 30801920
    #endif
    
    // <o> UART_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY
    #define UART_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // <q> UART_EASY_DMA_SUPPORT  - Driver supporting EasyDMA
     
    
    #ifndef UART_EASY_DMA_SUPPORT
    #define UART_EASY_DMA_SUPPORT 1
    #endif
    
    // <q> UART_LEGACY_SUPPORT  - Driver supporting Legacy mode
     
    
    #ifndef UART_LEGACY_SUPPORT
    #define UART_LEGACY_SUPPORT 1
    #endif
    
    // <e> UART0_ENABLED - Enable UART0 instance
    //==========================================================
    #ifndef UART0_ENABLED
    #define UART0_ENABLED 1
    #endif
    // <q> UART0_CONFIG_USE_EASY_DMA  - Default setting for using EasyDMA
     
    
    #ifndef UART0_CONFIG_USE_EASY_DMA
    #define UART0_CONFIG_USE_EASY_DMA 1
    #endif
    
    // </e>
    
    // <e> UART1_ENABLED - Enable UART1 instance
    //==========================================================
    #ifndef UART1_ENABLED
    #define UART1_ENABLED 0
    #endif
    // </e>

    Thanks and Regards

    Rohit R

  • Hi Rohit,

    Please open a new ticket with this issue, as it is a different topic than the original in this ticket.

    Best regards,

    Marte

Related