An application to map and store your IoT devices data Nov 29, 2019 go geo

Here in Quebec, winter is so cold it can drain your phone battery very fast.

I wanted a private and secure solution for my hikes, so I can be followed on a map.

This post will introduce you to LoRaWAN and how to install your own IoT mapping application using open source tools and a new project I’m working on written in Go.

Radio Network

LoRaWAN is a network layer protocol for managing communication between LoRa devices and gateways.

The Things Network is an open and free to use LoRaWAN network.

Anyone can contribute to the coverage by installing a gateway (a small radio devices) connected to the internet.

This network is for IoT and only allows a few bytes to be transmitted every several minutes per devices, do not expect browsing the Internet through LoRaWAN.

All transmissions are ciphered using AES and only you and The Things Network can then read the data.

Gateways

Gateways are radio emitter/receiver, it can be as small as a $10 devices or a more complete solutions like the The Things Indoor Gateway and more

An ESP32 with a LoRa chip can act as a one channel gateway.

You don’t need to own a gateway, to use the network, as long as your area is covered already.

Devices

A devices is a small transceiver, that can generally run on battery or USB consuming a few mA, it’s coupled to captors providing humidity, temperature, GPS…

Another simple and cheap device you can program: a TTGO T-Beam, an ESP32 + LoRa module with a 18650 battery holder.

Here is the code I use for a TTGO T-Beam code for v0.7 (the 2 push buttons one)

Map

The Thing Network is acting as a hub and provides API for third parties integrations to consume the data.

Some of them are providing storage and mapping services, but you have to give them your data.

That’s why I’ve developed GeoTTN, a simple self hosted solution to gather and store your devices data.

GeoTTN

GeoTTN is a multi components app put all together:

A Badger storage database using S2 as a geographical indexing system

A client of the Things Network gRPC API to receive uplink messages

A gRPC API to query the Badger database

A web frontend to display the devices on a map

It’s shipped in one app on purpose to run inside a one Docker instance, without resorting to complex admin tasks.

It should be fine for thousands of devices until you want to break the components apart, contact me for a more robust clustered solution.

The code is modular so you can change it for your own purpose.

But most important you can deploy it yourself and own your data.

Deployment

You need to create an “application” on The Thing Network Console and register your devices with this application.

Then start GeoTTN by simply passing your appID & appAccessKey on the command line or via environment.

You can also use the docker image as follow:

docker run -it akhenakh/geottn:latest -e APPID=myappid -e APPACCESSKEY=xxxxxxxxxx -e DBPATH=/data/geo.db -e TILESKEY=pk.eyJxxxxxxxxxxxxxxxxxxxx -v /mysafesotorage/volume:/data

For the map to show up register with MapBox for a free token and pass it as tilesKey .

Note that you can use the self hosted map solution described on this very same blog with selfHostedMap=true .

Notes

For your devices registrations, it’s recommended to use Over The Air Activation: OTAA, but it could be easier to use ABP mode.

Feel free to contribute, GeoTTN is on Github.