Hello,I came across this twitter clip by Marjeris showing a Thingy 52 relaying temp info to Alexa.How was this done? by mqtt? or as gadget?thank-you,
Sorry for the late reply. We used the BLE Thingy and Zigbee Color Light Bulb example as the starting point and modified it by adding Zigbee Temperature sensor cluster and in this case, updated the temperature attribute of the cluster everytime we got a new temperature reading from the Thingy temperature characteristic. I have tried to write down some steps you can follow if you want to try to add temperature readings to the BLE thingy and Zigbee Color Light bulb example:
Declare a new endpoint with Zigbee temperature sensor cluster (you can use the Zigbee Multisensor example as a guideline).
In ble_thingy_master.c we updated some structures to include updates of the temperature characteristic from the Thingy:
/* Thingy device events passed to the main application. */
/* Structure to contain characteristic for discovery purpose */
/* Structure for storing used Thingy's characteristic's */
/**@brief Callback definition for intercepting thingy device events. */
typedef void (*thingy_evt_handler_t)(thingy_device_t * p_thingy, thingy_evt_t evt, ble_evt_t const * p_ble_evt);
And we added a new case for THINGY_TEMPERATURE_UPDATE inside the thingy_event_handler() in main.c to store the new temperature inside a variable and set a flag to update temperature cluster.
new_temperature = (zb_int16_t)p_ble_evt->evt.gattc_evt.params.hvx.data;
if (new_temperature != m_temperature)
m_temperature = new_temperature;
NRF_LOG_INFO("main temperature update %d", p_ble_evt->evt.gattc_evt.params.hvx.data);
m_update_temperature_flag = true;
NRF_LOG_INFO("same temperature (%d)", new_temperature);
Then called update_temperature() function from main loop to update the ZCL temperature cluster using zb_zcl_set_attr_val() for a new temperature reading:
static void update_temperature(zb_int16_t temperature)
static zb_int16_t new_temp_value;
/* Get new temperature measured value */
new_temp_value = temperature;
new_temp_value = new_temp_value * 100;
zcl_status = zb_zcl_set_attr_val(MULTI_SENSOR_ENDPOINT,
if (zcl_status != ZB_ZCL_STATUS_SUCCESS)
NRF_LOG_INFO("Set temperature value fail. zcl_status &d", zcl_status);
NRF_LOG_INFO("Set temperature value success, val: 0x%04x, %d", new_temp_value, new_temp_value);
Main loop at the end of main():
/* Enter main loop */
m_update_temperature_flag = false;
Links to the infocenter pages for the Zigbee examples that were used:
BLE Thingy and Zigbee multiprotocol example: https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/zigbee_multi_dynamic_color_light_sed_thingy_master.html
Zigbee multisensor example: https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/zigbee_multi_sensor_example.html
this is helpful in understanding how to add the BLE thingy to the Zigbee Color Light bulb example.
The other part of interest is the actual conversation with Alexa.
Which example was used to have Alexa issue a directive, and in turn, have the thingy (840DK with Zigbee) respond with an event?
Alexa recognized the device automatically as a temperature sensor because of the zigbee temperature cluster, so it was added as a common zigbee temperature sensor device which Alexa had already voice command buid-in support for. We didn't use Alexa gadgets or skills in this demo. One thing that perhaps didn't come well explained in the video for that demo is that Alexa is not communicating with the Thingy:52 directly, but through a nRF52840 dongle used as a Zigbee/BLE gateway.
Unfortunately I don't yet have experienced with creating new skills with Alexa, but we have just released an example using Amazon gadgets for BLE in NCS, it may be of help if you want to create a Amazon gadget using Thingy:52 directly: https://github.com/nrfconnect/sdk-nrf/tree/master/samples/bluetooth/alexa_gadget
I think you should be able to compile the example for the Thingy:52 board. If you have some issues perhaps take a look at this other case where somebody have already tried to do it: https://devzone.nordicsemi.com/f/nordic-q-a/68569/error-building-alexa-gadget-example-in-nrf-connect-sdk
I have the NCS-Zephyr gadget example working fine, and I was hoping to find some hints as to how this could be redone on nrf5 SDK,which could have been through this zigbee smart home demo.
Sorry for the innactivity due to the Holidays. It seems you have been in contact directly with Audun. To quote him "there are no technical limitations with the nRF5 SDK or SoftDevice that prevents one from running Gadgets there. A lot of the code from the NCS example can be reused but you would have to replace some NCS dependencies with the nRF5 SDK equivalent, such as bluetooth functions and callbacks."
Since it seems you have already gotten an answer for you question I recommend you closing this case if there are no other questions.
Our product is built around nRF5 SDK examples and all the available features that come with it.When the main IDE was transitioning from Keil to SES, there was a guide explaining how to migrate to SES, until all the examples became available on SES.A guide like that explaining how to migrate from nRF5 SDK to NCS-Zephyr would be of some help here,and if not a guide then maybe a common example to compare and see which part goes where.Having the gadget example in nRF5 would be even better.Unfamiliarity with the zephyr structure is what's hindering the matter of fact reply.