Setting Up a Single Channel LoRa Gateway

LoRa is the latest hype in radio communication and integrates with a framework for an internet of things. That’s why I thought I have to try it too.

But it proved to be very difficult to setup. The problem is the lack of documentation and the fragmentation of all the available software packages.

The Things Network tries to be the single point of the network and the information around it. It does a good job managing gateways and applications, the registry of those and the communication backend. But it fails miserable regarding documentation. Either things are documented in a way you would speak to a five year old leaving away all the important details, or they are just completely lacking content, for example the communication documentation. I found a few bits and pieces here and there, but I still have not found the specification for the new (non-legacy) gateway-server communication protocol.

The first software for a single channel gateway seems to be single_chan_pkt_fwd by Thomas Telkamp but it’s not updated anymore. There are a few forks of this software with added features. The most polished seems to be LowCostLoRaGw by Congduc Pham. Unfortunately LowCostLoRaGw uses an obfuscation layer called arduPi and I could not get it working at all.

A problem with all the softwares was their use of obfuscation layers like arduPi and wiringPi which hide the real hardware pin names behind funny numbers somebody made up. It took a lot of time to find out which pin combination actually works. There were a few documentations containing pin numbers but almost all were wrong.

The Hardware

I use an old Raspberry Pi B+ (version 1) and a Dragino HAT I bought from AliExpress. Unfortunately the module comes with the wrong spacers, screws and nuts. They sent M3 but for the RasPi M2.5 is needed, its mounting holes have a diameter of 2.75mm.

Assembling it is pretty simple, just add one spacer in the corner next to the LoRa module and then plug the HAT onto the Raspberry Pi. Later I will add a power supply and a nice waterproof enclosure, and screw it to a pole somewhere on the roof.

The Software

I installed the single_chan_pkt_fwd by Charles Hallard. Before starting it the configuration file global_conf.json has to be edited. The only difficult part is the SX127x_conf configuration containing the pin configuration and the frequency:
"freq": 865062500,
"spread_factor": 7,
"pin_nss": 6,
"pin_dio0": 7,
"pin_rst": 0,

Because the software uses wiringPi it has to be started as root, it will not work as normal user.

I wrote this little script which restarts the gateway should it stop for whatever reason:
while true; do
echo "Startging up LoRa gateway `date '+%Y-%m-%d %H:%M:%S'`"
sleep 5

I then start it in a screen session:
screen -dmS loragw
This way I can join the session whenever I want and watch the output of the process:
screen -r
To detach from the session press ctrl+A ctrl+D.

Registering the Gateway

The gateway has to be registered on the things network website. There are only two important things:

  1. The gateway has to be registered with “legacy packet forwarder” checked. The software only supports this “legacy” protocol.
  2. When the gateway software starts up it shows some information. One line contains the gateway ID. This ID has to be entered into the “Gateway EUI” field.

The Future

There are a few parts of the software which need improvement. I don’t want the gateway to run as root so wiringPi has to go. Support for the GPS would be nice. It would also be nice if I could add two or three additional LoRa modules to be able to support more channels. There is a dual module version dual_chan_pkt_fwd by bokse001 that could be improved.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>