2019-10-08

Setup TTN Gateway using Raspi3 with RAK831 and converter board

Finally I was able to put my TTN Gateway into operation.


The first attempt a few month ago failed and therefore the project was on hold until now. An article in make 03/2019 gave me the impetus for a new attempt.

My essential setup steps:
  1. Put the parts together.
    Caution: Do not power up the RAK831 card without connecting the antenna.
  2. Prepare a SDCard with a Raspberry Image - I use "Raspbian Buster with desktop" (Release date: 2019-09-26, Kernel 4.19)
  3. Perform a general update
    sudo apt-get update && sudo apt-get upgrade
  4. Enable SPI using raspi-config
  5. Clone the ttn gateway repo
    git clone https://github.com/ttn-zh/ic880a-gateway.git
  6. Run the setup script
    cd ic880a-gateway
    sudo ./install.sh
  7. Register the gateway on TTN website
After the restart I check the service status:

pi@ttn-gateway:~ $ systemctl status ttn-gateway
● ttn-gateway.service - The Things Network Gateway
   Loaded: loaded (/lib/systemd/system/ttn-gateway.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2019-10-08 14:05:42 CEST; 779ms ago
  Process: 346 ExecStart=/opt/ttn-gateway/bin/start.sh (code=exited, status=1/FAILURE)
 Main PID: 346 (code=exited, status=1/FAILURE)

ttn-gw ttn-gateway[346]: INFO: Statusstream data is enabled
ttn-gw ttn-gateway[346]: INFO: Beacon is disabled
ttn-gw ttn-gateway[346]: INFO: Monitor is disabled
ttn-gw ttn-gateway[346]: INFO: Contact email configured to "my email"
ttn-gw ttn-gateway[346]: INFO: Description configured to "ttn-rak831"
ttn-gw ttn-gateway[346]: INFO: Successfully contacted server router.eu.thethings.network
ttn-gw ttn-gateway[346]: INFO: [main] Starting the concentrator
ttn-gw ttn-gateway[346]: ERROR: [main] failed to start the concentrator
ttn-gw systemd[1]: ttn-gateway.service: Main process exited, code=exited, status=1/FAILURE
ttn-gw systemd[1]: ttn-gateway.service: Failed with result 'exit-code'.

Damn - the same problem as at first try! :-(

An issue thread on github list some possible reasons, among other "the wiring might be wrong". You may also interpret it as "other then expected or as default" and this was the key. On another page about the setup I found the crucial clue: The converter board uses a different reset pin (it use pin 17 instead of 25).

After changing the corresponding setting in /opt/ttn-gateway/bin/start.sh
#! /bin/bash

# Reset iC880a PIN
# SX1301_RESET_BCM_PIN=25
SX1301_RESET_BCM_PIN=17
echo "$SX1301_RESET_BCM_PIN"  > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/direction

... it worked as expected. And I see the status "connected" on the TTN console (on TTN website).

To enable the GPS module I have to:
  1. Disable the serial login shell but keep the serial interface enabled - via raspi-config - interface setup.
  2. add the following lines to /opt/ttn-gateway/bin/local_conf.json
    "gps_tty_path": "/dev/ttyS0",
    "fake_gps": false,
    
  3. Reboot and check if it works (it may take some minutes to fetch the GPS position)
    pi@ttn-gateway:/opt/ttn-gateway/bin $ sudo tail -f /var/log/syslog | grep -i gps
    Oct  8 17:55:36 ...: INFO: GPS serial port path is configured to "/dev/ttyS0"
    Oct  8 17:57:39 ...: INFO: GPS is enabled
    Oct  8 17:57:39 ...: INFO: Using real GPS if available.
    Oct  8 17:57:39 ...: INFO: [main] TTY port /dev/ttyS0 open for GPS synchronization
    Oct  8 17:57:39 ...: INFO: GPS thread activated.
    Oct  8 17:57:39 ...: WARNING: [gps] GPS out of sync, keeping previous time reference
    Oct  8 17:57:39 ...: WARNING: [gps] GPS out of sync, keeping previous time reference
    Oct  8 17:57:39 ...: WARNING: [gps] GPS out of sync, keeping previous time reference
    Oct  8 17:57:39 ...: WARNING: [gps] GPS out of sync, keeping previous time reference
    Oct  8 17:57:39 ...: ### [GPS] ###
    Oct  8 17:57:39 ...: # Valid gps time reference (age: 0 sec)
    Oct  8 17:57:39 ...: # System GPS coordinates: latitude 50.94322, longitude 7.37443, altitude 272 m
    Oct  8 17:57:39 ...: ### [GPS] ###
    Oct  8 17:57:39 ...: # Valid gps time reference (age: 0 sec)
    Oct  8 17:57:39 ...: # System GPS coordinates: latitude 50.94322, longitude 7.37443, altitude 274 m
    
Used hardware:

Raspi3

The converter board with GPS support

RAK831 module

On the left side: 
top - the TTN antenna
bottom - the GPS module (optional)

Connection of the GPS signal

Update: The wiring of the converter board is available on the RAK website.