RAK833 and PiSupply LoRa Gateway Hat with RAK Gateway Source
Background
As of this writing, PiSupply’s iot-lora-image releases stop almost 2 years ago: https://github.com/PiSupply/iot-lora-image/releases .
As such, I wanted to see if I could get my PiSupply hat, plus RAK833 (w/ Raspberry Pi 3 B+) working with RAK Wireless’s rak_common_for_gateway
component in GitHub.
As of this writing, this
Fix
For the impatient: here is the fix you need to make after completing setup. If you’d like to get more info on the “more complete” setup continue to the sections below:
The fix is actually pretty simple. By default, the system enables and then disables GPIO 17 to reset the hardware at start up. However, the PiSupply uses GPIO for this purpose. After completing installation of the RAK common gateway component, simply run this (single) command to update the start script:
sudo sed -i 's/^SX1301_RESET_BCM_PIN=17$/SX1301_RESET_BCM_PIN=22/' /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/start.sh
Setup
I won’t dive deep in to the setup here, but I will provide a few useful pieces of information:
- You can find the installation process here: https://github.com/RAKWireless/rak_common_for_gateway#installation-procedure
- In step 4 (or, if the process changes, when it asks you for your gateway model) select RAK2247(SPI)
- The RAK833 seems to be an older version of the RAK2247
- The PiSupply IoT LoRa Gateway Hat interfaces with the card via SPI, not USB
- There are plenty of useful tutorials out there on setting up a gateway in The Things Network / The Things Stack
- After installing the RAK gateway component you can get your device EUI by running:
sudo gateway-version
- After installing the RAK gateway component you can get your device EUI by running:
- After creating the gateway in TTN / TTS you can export the global config file, and replace
/opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf.json
with its contents
Debug
The short version of debugging:
- I originally saw that my configuration looked correct, but I wasn’t seeing the device as “connected” on TTN/TTS.
- When I followed syslog via
tail -f /var/log/syslog
I saw that systemd was constantly trying to restart the ttn-gateway. The messages looked like:May 15 15:41:20 rak-gateway ttn-gateway[802]: ERROR: [main] failed to start the concentrator May 15 15:41:20 rak-gateway systemd[1]: ttn-gateway.service: Main process exited, code=exited, status=1/FAILURE May 15 15:41:20 rak-gateway systemd[1]: ttn-gateway.service: Failed with result 'exit-code'.
- I went looking in to the PiSupply IoT LoRa Range GitHub and found (in the file linked) the call to
reset-22.sh
- I went looking for a script like that, figuring it was simply switching a GPIO, likely number 22, on and off. I was right.
- I dug in to the startup of the ttn-gateway code provided with the RAK gateway component and saw in
start.sh
that it does something similar, but with pin 17 - To address it, I simply changed pin 17 to 22 (see command previously), fully powered off and on, and saw the device is now reporting as online.