IoT LoRa application service
Tutorial
F. Ferrero, J. Lanteri
V.1.3
1
Node Red – InFluxDB - GRAFANA
In this tutorial your are going to learn
how to use the data received on TTN
2
Outline
1/ Definition
2/ Tutorial
3
Node Red
• Node-RED is a programming tool for wiring together hardware devices, APIs
and online services in new and interesting ways.
• It provides a browser-based editor that makes it easy to wire together flows
using the wide range of nodes in the palette that can be deployed to its
runtime in a single-click.
• Built on Node.js
• The light-weight runtime is built on Node.js, taking full advantage of its event-driven,
non-blocking model. This makes it ideal to run at the edge of the network on low-
cost hardware such as the Raspberry Pi as well as in the cloud.
4
Outline
1/ Definition
2/ Tutorial
5
Node-Red
First install Node.JS : https://nodejs.org/en/download/
Then : Install Node-red :
https://nodered.org/docs/getting-started/windows
Install package in Node Red :
node-red-node-email
Install git : https://git-scm.com/downloads
6
Connecting to TTN
• Start NODE.js command prompt
• Run : node-red
• Open your web browser and go
to http://127.0.0.1:1880
7
Connecting to TTN
• You have the graphical Node-red
editor
• Add mqtt in node
• Edit mqtt
• Choose « Add new mqtt-broker
… » in App and click on edit
• Output is a parsed JSON object
8
Connecting to TTN
• Update security and topic:
• Go to you application in TTN
• Copy past the User name and keys (generate new
API Keys)
• Add topic :
v3/uca-project@ttn/devices/device_name/up
9
Connecting to TTN
var logMsgs = [];
logMsgs[0]=({payload: {
rssi: msg.payload.uplink_message.rx_metadata[0].rssi,
voltage: msg.payload.uplink_message.decoded_payload.analog_in_3,
temperature:msg.payload.uplink_message.decoded_payload.temperature_1,
humidity: msg.payload.uplink_message.decoded_payload.relative_humidity_2,
luminosity: msg.payload.uplink_message.decoded_payload.luminosity_4
}
});
return logMsgs; 10
Connecting to TTN
• If you want to extract only 1 data,
• As an exemple the RSSI (received
signal Strength indicator
• Use a function to extract the desired
data
var tmp = {};
tmp.payload = msg.payload.uplink_message.decoded_payload.luminosity_4
return tmp;
11
Connecting to TTN
• On the editor, click here
And go to palette editor
Install :
• node-red-dashboard
12
Add a Dashboard
• Go to Manage Palette, select Install
• Install : node-red-dashboard
• Add a function to extract sensor values
(Temp, Hum, luminosity…)
var tmp = {};
• Add Gauge and Graph for Dashboard tmp.payload = msg.payload.uplink_message.decoded_payload.luminosity_4
return tmp;
section
• Add a new UI group in the Gauge and
Graph
• Go to : http://127.0.0.1:1880/ui/
var tmp = {};
tmp.payload = msg.payload.uplink_message.decoded_payload.luminosity_4
return tmp;
13
Send an email
• Go to Manage Palette, select Install
• Install : node-red-node-email
• Configure your email with unice credential (use
your ENT account)
• Use a timestamp to test (click to trigger it)
• Email object is defined in msg.topic
• Email content is defined in msg.payload
14
Send an email triggered on luminosity level
• Add a function to detect is the
luminosity overpass a threshold
• Send an email with a sentence
var tmp = {};
var lum
=msg.payload.uplink_message.decoded_payload.luminosity_4;
tmp.topic = "information capteur";
if (lum>200)
tmp.payload = "il y a de la lumiere";
Else
tmp.payload = "il n'y a pas de lumiere";
return tmp; 15
Good luck for your projects !
16