2 | How to develop an IoT device using RIOT-OS and connect it to Thingsboard using MQTT-SN

IoT cloud-based system using Thingsboard, MQTT, RIOT-OS and IoT-LAB
git pull
git submodule update --init --recursive
  • brokers : it contains all configurations of the broker and the gateway. In addition, there are 2 submodules to fetch directly source code of mosquitto.rsmb and paho MQTT-SN Transparent Gateway.
  • device/riot : contains the RIOT source folder for the IoT device and a small script set_network.sh to easily configure network interfaces on native deployment.


  • energy-efficiency and real-time capabilities;
  • small memory footprint and modularity;
  • uniform API access: independent of the underlying hardware (POSIX).


IoT devices are no longer directly connected to Thingsboard MQTT, hence we need to change our default topic. Now, we will publish telemetry over:

Topic: v1/gateway/telemetry
"Device A": [
"ts": 1483228800000,
"values": {
"temperature": 42,
"humidity": 80
"Device B": [
"ts": 1483228800000,
"values": {
"temperature": 42,
"humidity": 80
Thingsboard gateway configuration
DRIVER ?= lps331ap        #to use directly sensors
USEMODULE += saul_default #sensors API
custom shell commands on riot


MQTT-SN is a publish/subscribe messaging protocol for wireless sensor networks (WSN), with the aim of extending the MQTT protocol beyond the reach of TCP/IP infrastructure for Sensor and Actuator solutions.

MQTT-SN Architecture
cd brokers/MQTTSN-Gateway
mv gateway.conf gateway.conf.bkp
cp ../conf/MQTTSN-Gateway.conf gateway.conf
mosquitto -c brokers/conf/bridge_gateway_prod.conf
cd brokers/MQTTSN-Gateway
cd device/riot/sensors_mqttsn
PORT=tap0 make clean all term
RIOT native, MQTTSN trasparent bridge and mosquitto
ifconfig 5 add fec0:affe::99
con fec0:affe::1 1885
set_device "Device Piano"
pub v1/gateway/telemetry "{ 'Device Piano': [ { 'ts': 1585744760000, 'values':{'humidity': 42 }}]}" 1
  • set_device <device_name> : is a custom command which I wrote to setup dynamically the device name
  • pub <topic> <payload> is a default command available emcute_mqttsn
  • pub_telemetry : is a custom command which I wrote to directly push random data (in case of native applications) to <device_name>
  • pub_data : is a custom command to continuously push data using another thread. (Not use it for now, it is only a stub to multi-thread programming)
A RIOT execution
Multi-device dashboard
Device Dashboard


  1. Register to IoT-Lab.
  2. Configure SSH Access (link).
  3. Follow this tutorial
ssh <username>@saclay.iot-lab.info
#mv to your src folder
source /opt/riot.source
BOARD=iotlab-m3 make all
iotlab-experiment submit -n riot_m3 -d 60 -l 1,archi=m3:at86rf231+site=saclay
iotlab-experiment get -i <exp_id> -r
iotlab-node --update <your_binary>.elf -l saclay,m3,<dev_id>
nc <dev_id> 20000



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Francesco Colasante

Francesco Colasante

Sapienza University — Engineering in Computer Science