Build a TTN LoRa Gateway with balenaFin and balenaCloud

Set up a gateway for The Things Network using plug-and-play parts with the balenaFin Raspberry Pi Compute Module carrier board.

Story
We’ve taken a look at deploying a gateway for TTN on our blog in the past, but this time we’re going to look at setting one up using the new balenaFin with plug-and-play hardware! We’ll use the on-board mPCIe slot to interface with a RAK Wireless LoRa module, and use an Adafruit GPS HAT on top to give us location and timing information, then we’ll deploy the software using balenaCloud to allow us to remotely manage and update the gateway.

Introduction
The Things Network (TTN) is a connectivity alternative perfect for the IoT. It’s a community supported network of gateways based on LoRaWAN, a wireless data transmission technology combining Long Range (LoRa) with low power and bandwidth requirements.

LoRaWAN is most suited to small data packets, as would be found in monitoring applications, along with triggering and alarm signals. Therefore, TTN and LoRaWAN can be used in those situations where you need to gather small amounts of data over a long distance or wide area. For example; in a farm or crop monitoring scenario, a gateway would be installed centrally and then nodes could be installed widespread across the farm. The range is longer than WiFi and comes without the costs associated with cellular data networks. Typical ranges vary from anything up to 10 km on average, up to a record 702 km (436 miles).

Coverage for the network is provided largely by community-owned gateways, and so here we’re going to take a look at setting up one of these gateways. The gateway can be used to boost the TTN coverage in your area of interest to provide connectivity for your own devices, whilst simultaneously expanding the network and allowing other users to take advantage of the extra coverage. By using balenaCloud to deploy our gateway, we’re able to remotely manage and update it, as well as being able to very quickly and easily add more gateway devices to expand coverage as required.

Hardware required
This project has been built to use only readily-available hardware that you can simply plug together. It’s a nice way to get started and gives you some customizability in terms of how you go about deploying the hardware. We’re not going to look at permanent installation and antennae in this post, but we will be looking at that next time!

A balenaFin with compute module (CM3L/3+L) - balena store
RAK833-USB/SPI mPCIe LoRa gateway concentrator module - AliExpress linkNote: be sure to select the correct frequency for your country!
Adafruit Ultimate GPS Pi HAT (optional) - Adafruit
Software required
There are a lot of TTN gateway projects on GitHub already, some based around the use of the Raspberry Pi 3. As the balenaFin is designed to be a direct replacement and compatible with all the software that the Raspberry Pi runs, it’s really simple to take one of these projects and run it on the Fin. We need to make some minor changes this time as we’re using the mPCIe socket for this project, which is an extra feature on the Fin that the Raspberry Pi does not have, and so the interface for the LoRa radio module is different.

I’ve forked one of the more popular Raspberry Pi TTN gateway projects by @jpmeijers and made some changes to get it to work with the balenaFin, so you’ll need:

A free balenaCloud account - sign up here
A TTN account - sign up here
Copy of the ttn-gateway-balenafin repo
balenaEtcher to flash your balenaFin
balena CLI tools to push the project to balenaCloud”

Link

Related Content