zigbee 2.0.0.0
Main Page

ZigBee click

‍ZigBee Click is a compact add-on board that contains a fully integrated Zigbee transceiver with a 32-bit ARMĀ® Cortex M3TM microprocessor, Flash and RAM memory, and peripherals. This board features the ETRX357, 2.4 GHz Zigbee Radio module from Silicon Labs, which has been designed to be easily integrated and to provide a fast, simple, and low-cost wireless mesh networking interface.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Oct 2021.
  • Type : UART type

Software Support

We provide a library for the ZigBee Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

‍This library contains API for ZigBee Click driver.

Standard key functions :

  • zigbee_cfg_setup Config Object Initialization function.
    void zigbee_cfg_setup(zigbee_cfg_t *cfg)
    ZigBee configuration object setup function.
    ZigBee Click configuration object.
    Definition zigbee.h:328
  • zigbee_init Initialization function.
    err_t zigbee_init ( zigbee_t *ctx, zigbee_cfg_t *cfg );
    err_t zigbee_init(zigbee_t *ctx, zigbee_cfg_t *cfg)
    ZigBee initialization function.
    ZigBee Click context object.
    Definition zigbee.h:306
  • zigbee_default_cfg Click Default Configuration function.
    err_t zigbee_default_cfg ( zigbee_t *ctx );

Example key functions :

  • zigbee_send_at Function merges two string and sends it to device.
    void zigbee_send_at ( zigbee_t *ctx, uint8_t *at_buf, uint8_t *suffix_buf );
    void zigbee_send_at(zigbee_t *ctx, uint8_t *at_buf, uint8_t *suffix_buf)
    Function merges two string and sends it to device.
  • zigbee_resp Function checking driver buffer string.
    uint8_t zigbee_resp ( zigbee_t *ctx, char *data_in );
    uint8_t zigbee_resp(zigbee_t *ctx, char *data_in)
    Function checking driver buffer string.
  • zigbee_set_pin_rst Function setting RST pin status.
    void zigbee_set_pin_rst ( zigbee_t *ctx, uint8_t status );
    void zigbee_set_pin_rst(zigbee_t *ctx, uint8_t status)
    Function setting RST pin status.

Example Description

‍This is an example that demonstrates the use of the ZigBee Click board.

The demo application is composed of two sections :

Application Init

‍Initialization of driver, UART ISR and then configures device. Depending on previous selected device mode it creates new PAN network or joins to one.

void application_init ( void )
{
log_cfg_t log_cfg;
zigbee_cfg_t zigbee_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
zigbee_cfg_setup( &zigbee_cfg );
ZIGBEE_MAP_MIKROBUS( zigbee_cfg, MIKROBUS_1 );
if ( UART_ERROR == zigbee_init( &zigbee, &zigbee_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, "------------------------------\r\n", app_buf );
log_printf( &logger, " Restarting Device \r\n" );
zigbee_restart( &zigbee );
log_printf( &logger, "------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT \r\n", app_buf );
resp_wait( &zigbee );
log_printf( &logger, "------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + DASSL \r\n", app_buf );
resp_wait( &zigbee );
log_printf( &logger, "------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : ATZ \r\n", app_buf );
resp_wait( &zigbee );
log_printf( &logger, "------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : ATI \r\n", app_buf );
resp_wait( &zigbee );
log_printf( &logger, "------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + N \r\n", app_buf );
resp_wait( &zigbee );
{
// Setting the device into host mode and creating a network for other devices to connect.
log_printf( &logger, "-----------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + HOST CFG 1 \r\n", app_buf );
resp_wait( &zigbee );
log_printf( &logger, "-----------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + HOST CFG 2 \r\n", app_buf );
resp_wait( &zigbee );
log_printf( &logger, "-----------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + HOST CFG 3 \r\n", app_buf );
resp_wait( &zigbee );
log_printf( &logger, "-----------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + EN \r\n", app_buf );
resp_wait( &zigbee );
}
else if ( ZIGBEE_DEV_USER == dev_mode )
{
// Setting the device into user mode and joining the existing network.
log_printf( &logger, "-----------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + JN \r\n", app_buf );
resp_wait( &zigbee );
}
log_printf( &logger, "-----------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + IDREQ \r\n", app_buf );
resp_wait( &zigbee );
log_printf( &logger, "-----------------------------------\r\n", app_buf );
log_printf( &logger, " Sending command : AT + N \r\n", app_buf );
resp_wait( &zigbee );
Delay_ms ( 1000 );
log_info( &logger, " Application Task " );
log_printf( &logger, "-----------------------------------\r\n", app_buf );
}
#define ZIGBEE_CMD_ATZ
Definition zigbee.h:75
#define ZIGBEE_CMD_AT_IDREQ
Definition zigbee.h:101
#define ZIGBEE_CMD_AT_EN
Definition zigbee.h:91
#define ZIGBEE_CMD_AT
ZigBee control commands.
Definition zigbee.h:73
#define ZIGBEE_CMD_AT_DASSL
Definition zigbee.h:96
#define ZIGBEE_CMD_AT_N
Definition zigbee.h:98
#define ZIGBEE_CMD_ATI
Definition zigbee.h:74
#define ZIGBEE_CMD_ATS
Definition zigbee.h:81
#define ZIGBEE_CMD_AT_JN
Definition zigbee.h:93
#define ZIGBEE_APP_TASK
Definition zigbee.h:275
#define ZIGBEE_DEV_USER
ZigBee device user mode.
Definition zigbee.h:273
#define ZIGBEE_APP_INIT
Definition zigbee.h:276
#define ZIGBEE_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition zigbee.h:291
#define ZIGBEE_DEV_HOST
ZigBee device host mode.
Definition zigbee.h:267
void zigbee_restart(zigbee_t *ctx)
Function for reseting device.
void zigbee_send_cmd(zigbee_t *ctx, uint8_t *cmd_buf)
Function sends string to device.
char AT_HOST_CFG3[50]
Definition main.c:42
void application_init(void)
Definition main.c:56
char AT_HOST_CFG2[20]
Definition main.c:41
uint8_t dev_mode
Definition main.c:33
uint8_t app_mode
Definition main.c:34
char AT_HOST_CFG1[10]
Definition main.c:40
void resp_wait(zigbee_t *ctx)
ZigBee wait response.
Definition main.c:199

Application Task

‍Host mode: Broadcasts message 'MikroE' every 3 seconds. User mode: Cheks if something is received.

void application_task ( void )
{
{
log_printf( &logger, "-----------------------------------\r\n", app_buf );
resp_wait( &zigbee );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
else if ( ZIGBEE_DEV_USER == dev_mode )
{
resp_wait( &zigbee );
log_printf( &logger, "-----------------------------------\r\n", app_buf );
}
}
#define ZIGBEE_CMD_AT_BCAST
Definition zigbee.h:127
void application_task(void)
Definition main.c:159
char AT_BCAST_MSG[15]
Definition main.c:38

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.ZigBee

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.