Workshop at The Things Conference UK 2019 - how to collect your IoT data via MQTT, store in a NoSQL database, then display data as a graph
This assumes you already have a LoRaWAN device and a registered account on thethingsnetwork.org with access to the TTN console and a suitable application already created.
Also required is Node.js - tested with LTS (currently version 10.16.3) installed
You should be familiar with Node.js to follow these instructions!
Just a hint - basic items are named differently in SQL and NoSQL databases. database in both is the same, tables in SQL are collections in NoSQL, records in SQL are documents in NoSQL.
- Create your own MongoDB Atlas database instance in the cloud: - https://www.mongodb.com/cloud/atlas - accept the defaults
- Take a note of your username, password, and server connection (similar to: ncbttn-f3ftfg.mongodb.net)
- Decide on names for your database (I chose thinnovation) and collection (I chose ttndata)
- Open up your TTN console to the applications page, choose your application - https://console.thethingsnetwork.org/applications and make a note of your APPLICATION name and ACCESS KEY
- Copy config.template to config.js and replace the parameters in <> with the values obtained above.
- Copy your config.js into both collector and viewer folders
- Change to the collector folder and run npm install to install the required nodejs libraries. When this has completed successfully - run npm start to run the collector.
- You will see a message 'db connected' each time a LoRaWAN device reports into TTN - a new document is inserted into your collection.
- Change to the viewer folder and run npm install to install the required nodejs libraries - run npm start
- You will see a message 'my app listening on PORT 3000'
- Open up a web browser (I tested with both Firefox and Chrome) and display the Web Developer Tools Console
- Enter a URI similar to localhost:3000/?device=&count=50 - replace with that of your LoRAWAN device.
- You should see a chart grid with valid data, red for rssi and green for snr values