Please note that this tutorial assumes you're working on a Linux PC.Prerequisites
This project builds upon the cloud infrastructure that is developed in this project.
1- You must have followed these steps:
- AWS IoT configuration.
- Connection with DynamoDB.
- Developing the Node.js backend app.
- Developing the Angular frontend app.
2- You must have Git installed. If Git is not installed, you can download it here.Build the MQTT-SN Transparent Gateway
1- Open the Terminal and run the following commands to set up the gateway:
> git clone -b experiment https://github.com/eclipse/paho.mqtt-sn.embedded-c
> cd paho.mqtt-sn.embedded-c/MQTTSNGateway
> make SENSORNET=udp6
> make install
> make clean
2- Open the
gateway.conf file and edit the contents in this way:
# Copyright (c) 2016-2019, Tomoaki Yamaguchi
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# and Eclipse Distribution License v1.0 which accompany this distribution.
# The Eclipse Public License is available at
# and the Eclipse Distribution License is available at
# config file of MQTT-SN Gateway
# When AggregatingGateway=YES or ClientAuthentication=YES,
# All clients must be specified by the ClientList File
Basically, you have to configure the MQTT part (the broker we will interact with, that in my case it is a
localhost and runs in
The other important thing is that you have to bind the upd6 address (
fec0:affe::1/64 is the same address that you see in the RIOT-OS
README file for the MQTT-SN connection) and the port (
1885 is the port that allows you to receive message from the RIOT's instances).
3- To execute the gateway open the Terminal from the directory where you have installed Paho and run this command:
Bridge Mosquitto MQTT Broker to AWS IoT
1- Install Mosquitto broker. You can download it here.
2- Now, you need to configure the bridge so that the Mosquitto broker can create a connection to AWS IoT. To do so you must create a new
mosquitto_bridge.conf file and write the following lines inside it:
# Bridges to AWS IOT
# AWS IoT endpoint
# Specifying which topics are bridged
# topic awsiot_to_localgateway in 1
# topic localgateway_to_awsiot out 1
# topic both_directions both 1
topic sensor/values both 1
# Setting protocol version explicitly
# Bridge connection name and MQTT client Id,
# enabling the connection automatically when the broker starts.
# Certificate based SSL/TLS support
#Path to the rootCA
# Path to the PEM encoded client certificate
# Path to the PEM encoded client private key
Is important that you replace this part with your own endpoint:
And here you have to insert the path of your certificates:
Remember that you have downloaded and saved the certificates during this step:
3- To run Mosquitto broker on port
1884, open the Terminal from the root directory of your configuartion file, and execute this command:
> sudo mosquitto -c ./mosquitto_bridge.conf –p 1884
You must have installed:
- Git. If Git is not installed, you can download it here.
- The build-essential packet (make, gcc etc.). This varies based on the operating system in use.
- The Native dependencies. If they are not installed, you can download they here.
- OpenOCD. If OpenOCD is not installed, you can download it here.
- GCC Arm Embedded Toolchain. If it is not installed, you can download it here.
- Netcat with IPv6 support. The installation command is the following:
> sudo apt-get install netcat-openbsd
1- To create your project, you need to clone the RIOT repository:
> git clone git://github.com/RIOT-OS/RIOT.git
2- Now, in order to have a command that publish a message containing the virtual sensors’ values on a topic every five seconds, you must update
RIOT/examples/emcute_mqttsn/main.c like this.
3- To start up the application follow step by step these:
- Open the terminal from the root directory of your project, and run this command to setup
If you want to check that the taps are on you can use this command:
> ifconfig | grep tap
- Assign a site-global prefix to the
tapbr0interface executing the following command:
> sudo ip a a fec0:affe::1/64 dev tapbr0
fec0:affe::1 is the address of the MQTTSN Gateway.
- Open the Terminal from the
RIOT/examples/emcute_mqttsndirectory and use the following command to open the native RIOT board:
> BOARD=native make term
- Assign a site-global address with the same prefix with this command:
> ifconfig 5 add fec0:affe::99
- To connect with the broker use the following command:
> con fec0:affe::1
- Finally, to start the message publishing, run this command replacing the name of my topic (
sensor/values) with your own:
> pub_values sensor/values
Note: if you want to see your web page properly working on localhost:4200, your frontend and backend apps must be running. See here how to do.About
This project has been developed as part of my MSc degree at Sapienza University of Rome for the 2019/2020 Internet of Things course.
Related video on YouTube.