LoRaWAN – Data Storage

Data Storage

The LoRaWAN Application Server is a gateway for your data packages, but they still need to be collected for storage and downstream use. 

In this project, we use open-source software applications to allow for easy data collection from CemTore.

  • CemTore publishes application data to an MQTT broker
  • Applications subcribe to the published MQTT topic to retrieve application data
  • InfluxDB is used to store the payload and meta data in a time-series database (TSDB) 
  • Node-RED is used as a single host (container) for visual flow-based programming and easy service deployment to collect and store data

MQTT Broker

MQTT is a simple protocol of Publish and Subcribe to Topics.

  • application server publishes data to MQTT topics
  • client subscribes to the same MQTT topics
  • start with free MQTT broker at HiveMQ
  • deploy a private MQTT broker using Eclipse Mosquitto
  • use MQTT Explorer on your desktop to subscribe to Topics

MQTT Explorer can be used to monitor device data from your desktop. It even provides simple graphing, as shown in the example below.

InfluxDB – Time Series Database

InfluxDb is simple to deploy for storing your time series data.

The query language is easy to work with. 

> select device,rssi,snr,frequency,bandwidth,spreading,fcnt 
from iotdashdb..tester where device=~/204/
group by device
order by time desc limit 6

tags: device=647fda000000204b
time device rssi snr frequency bandwidth spreading fcnt
---- ------ ---- --- --------- --------- --------- ----
2020-12-23T21:54:21.282996682Z 647fda000000204b -58 10.5 904.7 125000 10 8
2020-12-23T21:54:18.264155673Z 647fda000000204b -71 11 904.3 125000 10 7
2020-12-23T21:54:14.767602693Z 647fda000000204b -69 11.5 903.1 125000 10 6
2020-12-23T21:54:11.852766683Z 647fda000000204b -69 9.5 903 500000 8 4
2020-12-12T23:39:29.658226434Z 647fda000000204b -88 -1 903 500000 8 25
2020-12-12T22:39:29.753285858Z 647fda000000204b -88 -0.2 903 500000 8 24

 

Node-RED

Node-RED provides “low-code programming for event-driven applications“.
Learn more at https://nodered.org/

 

Program Node-RED using “flows”:

  1. Subscribe to MQTT topic
  2. Transform data from source for storage
  3. Write data to InfluxDB measurement

Node-RED Example:

In the “refactor” step, the data from MQTT is transformed for storage in the InfluxDB database.

Example:

Once you “Deploy” the Node-Red application (flow), you should start seeing the data collected in InfluxDB. Use the Node-RED debug messages to help show you what is being collected and stored.

LoRaWAN Data Journey - A Trip Report