Chirpstack Relay

Although it is convenient and popular to use The Things Network (TTN) to receive LoRaWan messages I decided not to go this route for a couple of reasons. First when I received my RAK2245 gateway I tried to register it but was not able to because the gateway’s EUI was already registered. Perhaps I received a device that someone returned or maybe someone typed in the wrong EUI but bad luck for me. I’m sure there is a way to resolve this but the other issue is that my use case is to have a stand-alone system that does not depend on an internet connection. So the approach I have taken is to have a stand-alone gateway that can receive LoRaWan messages from a number of sensor nodes and process and display that data at the gateway. Fortunately the Chirpstack application server is easy to install on a Raspberry Pi 3B and uses MQTT. So it is very easy to subscribe to the MQTT broker and process the received messages.

I started doing this in order to determine the range of the sensors. This testing involved creating a small program that would receive MQTT messages from the gateway and send them as UDP messages to a server which in turn would display these messages in a simple web page. This way I could take the LoRa sensor out for a walk and monitor on my phone whether messages were being received. This simple setup worked quite well and has formed the basis for my Chirpstack relay system.

Source code for both the program that subscribes to the Chirpstack MQTT messages and sends them as UDP messages as well as the system that receives these messages and saves them in a database can be found on my GitHub repository here. The receiving system is set up as a Window service and is written in C#.

Receiving messages from Chirpstack via MQTT is made easy using the Eclipse Paho MQTT C++ client library. This data is received in JSON format and I used the excellent nlohmann/json library. The data element in this received message is encoded as a base 64 string and I use the taomykaira Base64.h header file.

As an extra step I have started to encode my sensor data in Cayenne LPP format so I started with the gizmocuz/CayenneLPP-Decoder which I simplified for my own use.

So all in all I have been successful in my experiments acquiring data using both cores of the RP2040 on a RAK11310, sending the message as a Cayenne LPP LoRaWan message, receiving the message on a Raspberry Pi 3B, decoding the message, forwarding it to a remote server and storing the data in a database. This forms the skeleton of a remote data acquisition system.


Posted

in

by

Tags:

Comments

Leave a Reply