LoRa and LoRaWAN is getting the de-facto wireless IoT network in my area. No surprise that traditional telecom providers like Swisscom trying to monetize the ‘Internet of Things’ area. Luckily there is an open and free alternative: https://www.thethingsnetwork.org/. Volunteers, enthusiasts and members in the different TTN communities build gateways and offer free LoRaWAN network access. I wanted to contribute to that grassroots movement with building my gateway, providing LoRaWAN access to my neighborhood.
RAK831 Semtech SX1301 LoRaWAN Gateway Module
RAK Wirless sells the RAK831 module (https://www.rakwireless.com/en/WisKeyOSH/RAK831).
As host I’m using a Raspberry Pi which then will be able act as multi-channel LoRaWAN gateway supporting 10 channels (8 downlink, 1 uplink and 1 FSK channel). The GPS module is used as timestamp interface for the SX1301.
I ordered my RAK831 868 MHz kit from AliExpress without a Raspberry Pi. I’m using it with a Raspberry Pi 3 Model B V1.2.
The LoRA and the GPS module are connected with an antenna cable:
I opted for the kit with the external GPS antenna and the aluminium enclosure with heat sink. To fit the LoRa Gateway module into the case, the two sides brackets of the gateway PCB need to be removed.
💡 Never (never!) power the gateway without the antenna attached, otherwise it might burn the transceiver!
Raspberry Pi Setup
I assume basic knowledge about how to setup a Raspberry Pi: set up your system with a recent distribution, see https://www.raspberrypi.org/
I recommend not to fully assemble the enclosure during software installation, as otherwise the LED of the LoRa board cannot be monitored:
Because the Semtech chip produces a lot of heat, that blue heat transmission material is placed on top of the heat-sink via’s to transmit the heat to the enclosure.
The Raspberry Pi gateway software communicates with the LoRa transceiver. The SPI peripheral is not turned on by default. To enable it, do the following.
- run ‘sudo raspi-config’
- Select ‘Interfacing Options’
- Select ‘SPI’:
- Select ‘yes’ to enable SPI:
- Confirm as well with ‘yes’ if it ask to automatically load the kernel module.
- Then exit and finish the dialog
First, get a general update:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install git -y
Next, cd to the user account
Clone the gateway from git:
git clone https://github.com/ttn-zh/ic880a-gateway.git ~/ic880a-gateway
cd into that directory:
By default, the gateway is using pin 25 to reset the gateway. This was the problem why I was not able to use the gateway out of the box and took me a while to realize. So: change the reset pin setting from pin 25 to 17! There are actually two scripts: one in ~/ic880a-gateway/start.sh and one in /opt/ttn-gateway/bin/start.sh. Both files need to be modified!
The one in the ic880a-gateway folder can be modified right away and is copied to /opt/ttn-gateway/bin/start.sh durinig inistallation.
Run the script inside the ic880a-gateway folder:
It shall report the EUI number: write it down or copy it:
Now stop here for a while. First we need to setup the TTN side…
Register for a The-Things-Network (TTN) account at: https://account.thethingsnetwork.org/register
Go to the ‘Console’ area on your TTN account where you can register a new gateway. Enter all the information, but make sure you select ‘I’m using the legacy packet forwarder’. And here we have now to enter that EUI number we have noted down from the previous step:
Fill out the other fields, e.g.:
Remember the GPS coordinates as you will need them on the Raspberry Pi for an initial setup, then proceed with the registration with pressing ‘N’. then enter all the information:
The information entered gets stored in /opt/ttn-gateway/bin/local_conf.json. In that same folder there is a global_conf.json which configures the other parts of the gateway.
At the end, the machine gets rebooted.
Don’t forget to verify the reset pin number in /opt/ttn-gateway/bin/start.sh!
Reboot and check the logs with:
systemctl status ttn-gateway.service
It should report something like this:
Feb 24 17:20:29 LoRaWanGW ttn-gateway: INFO: [down] for server router.eu.thethings.network PULL_ACK re Feb 24 17:20:29 LoRaWanGW ttn-gateway: ##### 2019-02-24 16:20:29 GMT ##### Feb 24 17:20:29 LoRaWanGW ttn-gateway: ### [UPSTREAM] ### Feb 24 17:20:29 LoRaWanGW ttn-gateway: # RF packets received by concentrator: 0 Feb 24 17:20:29 LoRaWanGW ttn-gateway: # CRC_OK: 0.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00% Feb 24 17:20:29 LoRaWanGW ttn-gateway: # RF packets forwarded: 0 (0 bytes) Feb 24 17:20:29 LoRaWanGW ttn-gateway: # PUSH_DATA datagrams sent: 1 (241 bytes) Feb 24 17:20:29 LoRaWanGW ttn-gateway: # PUSH_DATA acknowledged: 100.00% Feb 24 17:20:29 LoRaWanGW ttn-gateway: ### [DOWNSTREAM] ### Feb 24 17:20:29 LoRaWanGW ttn-gateway: # PULL_DATA sent: 3 (100.00% acknowledged)
At the end and with yet another reboot, the RX LED shall be now on:
Check the status of the gateway in the TTN Router console:
Congratulations, you have a LoRaWAN gateway!
Monitoring UDP Port 1700
A good way to check that everything is working is to use ‘tcpdump’. If not already installed, install it with
sudo apt-get install tcpdump
Then I can monitor the traffic with
sudo tcpdump -AUq port 1700
which should show something like this:
Another good way to verify the system is to check the syslog:
sudo tail -f /var/log/syslog
As seen above, my GPS is not configured properly, so this is something I have to cover next.
For me the GPS module was attached to ttyS0. Use the following to see the NMEA messages coming in:
sudo cat /dev/ttyS0
Which should show some GPS messages coming.
What is missing is that the messages are consumed to the gateway. For this I have to edit the /opt/ttn-gateway/bin/global_conf.json configuration file. Below what I had installed:
I changed this to
/* GPS configuration */ "gps_tty_path": "/dev/ttyS0", "fake_gps": false, "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1,
The other thing is that I have to disable the login shell on the UART. This is a setting in the configs:
then Interfacing Options:
Then select Serial:
Disable the Login Shell:
With the Serial Port Hardware Enabled:
Confirm and reboot:
And now I have a working GPS 🙂
Contributing to an open source and community network is fun and a learning experience the same time. The gateway is now working for several days and is handling LoRaWAN packets from my neighborhood. A next step is to attach a long fiberglass antenna and put that gateway with a fiberglass antenna on top of my house for a larger coverage 🙂
Happy LoRaWANing 🙂
- Wikipedia: https://en.wikipedia.org/wiki/LoRa
- RAK Wireless: https://www.rakwireless.com/
- RAK831: https://www.rakwireless.com/en/WisKeyOSH/RAK831
- RAK831 on AliExpress: search for “Lora Gateway Concentrator Module Kit, RAK831, base on SX1301, 433/470/868/915MHz, Wireless Spread Spectrum Transmission”
- The Things Network: https://thethingsnetwork.org
- Detect the GPS module of the official RAK831 shield for Raspberry Pi 3: https://github.com/ch2i/LoraGW-Setup/issues/2
- TTN Mapper: https://ttnmapper.org/