Ga naar hoofdinhoud
DIY LoRa-WAN gateway

You can make yourself a LoRa-WAN gateway using a Raspberry Pi Model B+ and a LoRa concentrator board RAK831.

Step 1: connect RAK831 to Raspberry Pi

TTN LoRaWAN gateway based on Raspberry Pi Model B+ and the RAK831 concentrator board.

Make these connections:

Step 2: prepare the Raspberry Pi
  1. Download raspbian_stretch_lite:
  2. Unzip and write image file to 4Gb micro SD-card using Etcher (
  3. Within /boot directory create a new file ssh (without extension). This will activate ssh during first boot.
  4. Start up Raspberry. Default username/op: pi/raspberry.
  5. Look up the Raspberry’s IP-adres by using advanced-ip-scanner (
  6. Install putty on your PC: and create a shortcut to putty.exe on your desktop.
  7. Open putty.exe and in the Host Name field fill in Raspberry’s IP-address (see step 6, in my case
  8. Type passwd to change the default password.
  9. Type sudo raspi-config (you can past this to Putty using the right mouse button).
  10. Select 5 Interfacing Options > P4 SPI and select ‘Yes’.
  11. Select 7 Advanced Options > A1 Expand Filesystem and choose <Select> using the Tab-button).
  12. Select <Finish> and reboot.
  13. Use putty to contact via SSH again and check if SPI is enabled: ls /dev/*spi*
    Raspberry’s response:  /dev/spidev0.0  /dev/spidev0.1
  14. Update, upgrade and install git: sudo apt-get update && sudo apt-get upgrade && sudo apt-get install git -y
  15. Install TTN software: git clone ~/ic880a-gateway
  16. Open this new directory: cd ic880a-gateway
  17. Ask for Gateway EUI: sudo ./ spi
    Stop here and copy the given EUI code (for example: B827EBFFFED8B28D).
  18. Register your gateway on TTN:
    1. Gateway EUI: fill in EUI code (see step 18)
    2. I’m using the legacy packet forwarder: Yes
    3. Description: choose your own
    4. Frequency Plan: Europe 868MHz
  19. Via SSH: Do you want to use remote settings file: N
  20. Fill in:
    1. Gateway EUI: fill in EUI code (see step 18)
    2. Descriptive name: see step 19
    3. Contact email: your e-mail address
    4. Latitude: copy this from TTN
    5. Longitude: copy this from TTN
    6. Altitude: copy this from TTN
  21. After a few minutes the Raspberry will reboot and your gateway is on line!
  22. Shutdown Raspberry: sudo shutdown
Adding ‘save shutdown button’

To prevent the SD-card getting corrupted you could add a button to shutdown the Raspberry Pi safely.
Open Terminal (via SSH or local) and type:

mkdir Scripts
cd Scripts


Edit python script:


Type the script content:

# Simple script for shutting down the raspberry Pi at the press of a button.
# by Inderpreet Singh  

import RPi.GPIO as GPIO
import time
import os  

# Use the Broadcom SOC Pin numbers
# Setup the Pin with Internal pullups enabled and PIN in reading mode

GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_UP)  

# Our function on what to do when the button is pressed  

def Shutdown(channel):

   os.system(“sudo shutdown -h now”)  

# Add our function to execute when the button pressed event happens  

GPIO.add_event_detect(18, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)  

# Now wait!  

while 1:  



Save file by pressing CTRL+X, type y and Enter.

Connect a push button between Raspberries GND and GPIO18  (Pin 12 and 14).

Test the the python script:

sudo python

Add python script to startup:

sudo nano /etc/rc.local

Add after fi:

python /home/pi/Scripts/

Save file by pressing CTRL+X, type y and Enter.


sudo reboot

Adding ‘Shutting gateway down safely button’

Removing power source to fast may lead to data corruption.
Connect LED (with 470 Ohm resistor in series) between Pin 6 (GND) and Pin 8 (TXD) of the Raspberry Pi.

Only when the LED is out it’s safe to remove power source.

Adding ‘Reboot button’

Connect Raspberry Pin 5 to ground.
Total boot time (from idle): 50 s.

Adding 3G-connection

Just add a 3G dongle to the Raspberry Pi. Be aware of the rather high power consumption of the 3G connection. Better use a powered USB-hub.

Connecting RAK831 and Raspberry Pi Model B+
Back To Top