The Thread Cloud CoAP Client example demonstrates the interaction between the development kit and a remote Cloud service. The nRF52840 node uses the built-in OpenThread CoAP protocol. This example uses the thething.io cloud. However, the code can be easily modified to be used with a different CoAP cloud.
The client node sends the emulated temperature value each time BSP_BUTTON_0 or BSP_BUTTON_1 is pressed. Additionally, these buttons decrease and increase the value respectively. The example implements the CLI interface so that more advanced users can communicate with the nodes through the serial port and configure them manually.
For proper operation, this example must be used along with Nordic's Border Router to provide Internet connectivity to the Thread network. For more information, refer to Border Router Quick Start Guide and Thread NCP Example.
After the Border Router is set up, you must perform cloud and node configuration, which has been explained in the following sections.
For a detailed description of the sign-up procedure and an introduction to the web interface of thethings.io, complete the steps described in thethings.io Getting Started. After the account is created, perform the following steps:
As the first step, replace the Thing Token ({THING_TOKEN} string) with the appropriate one, obtained in the process of Cloud setup. The value can be found in the header of the main.c
file represented as the CLOUD_URI_PATH define. After that, reprogram the example.
The nRF52840 node indicates the network state on BSP_LED_0. When the device is not connected to the network, the LED blinks at a 200 ms period. Once the device connects to a network, either as a Child or as a Leader, the LED stops blinking and remains turned on. On startup, nodes will automatically enter the network with default parameters. The first device that was turned on will become a Leader of the network, while the rest of the nodes will become Children and Routers.
The application layer of the example is built on top of the CoAP protocol. The client sends emulated temperature value when BSP_BUTTON_0 and BSP_BUTTON_1 are pressed.
The example application uses a minimum and maximum value of 15 and 30 Celsius that cannot be exceeded.
Currently, only the GCC project is supported. You can find the source code and the make file in the following folder: <InstallFolder>\examples\thread\experimental\cloud_coap_client
Client LED assignments:
Client button assignments:
In case the temperature value is not sent, enter the command line interface (CLI) of the nRF52840 Development Kit and check if the address with fdff:cafe:cafe:cafe:: prefix is visible. If this prefix is not visible, the Border Router may be incorrectly set up.
To test the example, you need at least two development kits.
make
command in the project folder. Note that you must have the make tool available on your system. If you are using Windows, you can use the MinGW environment (http://www.mingw.org/).