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

Combining Zigbee multi_sensor + UART

I want to use a UART line to send and receive data to a nrf52840 DK and then have the data sent wirelessly to a separate DK  and then print it to a terminal like in the multi_sensor example, but instead of Temp and Pressure values the data sent from the UART line.

Is this possible with the SDK? If so, can you explain of point me to resources on how to accomplish this?

Thank you

Parents
  • Hello,

    Please look into the ble_app_uart example for how to set up UART and enable UART interrupts. When you have done that, you can look at how the multisensor example and where it sets the temperature and pressure, and call that from your uart event handler.

    The calls that are setting the temperature and pressure are found in the zb_app_timer_handler():

    static void zb_app_timer_handler(void * context)
    {
        zb_zcl_status_t zcl_status;
        static zb_int16_t new_temp_value, new_pres_value;
    
        /* Get new temperature measured value */
        new_temp_value = (zb_int16_t)sensorsim_measure(&m_temperature_sim_state, &m_temperature_sim_cfg);
        zcl_status = zb_zcl_set_attr_val(MULTI_SENSOR_ENDPOINT, 
                                         ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, 
                                         ZB_ZCL_CLUSTER_SERVER_ROLE, 
                                         ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, 
                                         (zb_uint8_t *)&new_temp_value, 
                                         ZB_FALSE);
        if(zcl_status != ZB_ZCL_STATUS_SUCCESS)
        {
            NRF_LOG_INFO("Set temperature value fail. zcl_status: %d", zcl_status);
        }
    
        /* Get new pressure measured value */
        new_pres_value = (zb_int16_t)sensorsim_measure(&m_pressure_sim_state, &m_pressure_sim_cfg);
        zcl_status = zb_zcl_set_attr_val(MULTI_SENSOR_ENDPOINT,
                                         ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, 
                                         ZB_ZCL_CLUSTER_SERVER_ROLE, 
                                         ZB_ZCL_ATTR_PRES_MEASUREMENT_VALUE_ID, 
                                         (zb_uint8_t *)&new_pres_value, 
                                         ZB_FALSE);
        if(zcl_status != ZB_ZCL_STATUS_SUCCESS)
        {
            NRF_LOG_INFO("Set pressure value fail. zcl_status: %d", zcl_status);
        }
    }

    Best regards,

    Edvin

  • Thank you for the help! I was able to combine the UART example with the multi_sensor example, however when I run the program this I get this error message printed out to PuTTY  -> "app: Production configuration is not present or invalid (status: -1) "

    If I commit out uart_init() the error message goes away, so I think there is some incompatibility between the two examples that I'm not seeing. Any idea what this could be?

  • Does this appear in the log if you don't use UART? I guess it is just a message that is being logged, and also pops up in the UART when you enable it. The CLI module is a bit weird, as it mixes the NRF_LOG and CLI functionality. I usually see that message when I start a zigbee example. It just means that no network information is stored, and that it is ready to join a network (no network keys stored from earlier).

    BR,
    Edvin

Reply
  • Does this appear in the log if you don't use UART? I guess it is just a message that is being logged, and also pops up in the UART when you enable it. The CLI module is a bit weird, as it mixes the NRF_LOG and CLI functionality. I usually see that message when I start a zigbee example. It just means that no network information is stored, and that it is ready to join a network (no network keys stored from earlier).

    BR,
    Edvin

Children
No Data
Related