Building LoRaWAN TTN gateway

1. Hardware

  • Used Hardware: Banana-Pi M2U quad-core mini single board computer  + iC880a LoRaWAN Concentrator 868MHz (bought here)
  • Banana-Pi advantage: internal 8 GB eMMC storage
  • OS Raspbian 2017-05-25-raspbian-jessie-preview3-bpi-m2u-sd-emmc.img, how to burn it to MMC find here
    • Step 1: Start up the computer with the SD card which has been burnt with the Linux images.
    • Step 2: Put the images which you’d like to burn to the EMMC Storage to the USB drive.
    • Step 3: Run “fdisk -l” command line on your BPI-M3 and you can see the EMMC path as “/dev/mmcblk1”
      sudo fdiskfa -l
    • Step 4:Switch to the path of images, and run the command.
      sudo dd if=2017-05-25-raspbian-jessie-preview3-bpi-m2u-sd-emmc.img of=/dev/mmcblk1 bs=10MB

see also video on youtube.

2. Customise OS

uninstall Xserver:
sudo apt-get remove --auto-remove --purge 'libx11-.*'
sudo apt-get autoremove --purge

(Repeat apt-get autoremove --purge until no orphans remain)

update OS:
# rpi-update
# apt-get dist-upgrade
# apt-get update
# bpi-update
# bpi-tools -u
# bpi-tools -U
delete default user PI:
# adduser new-user
# deluser pi
install Persistent IPtables:
# apt-get install iptables-persistent
# vi /etc/iptables/rules.v4

# Generated by iptables-save v1.4.21 on Thu Feb 16 18:14:59 2017
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 22,80 -j ACCEPT
-A INPUT -p udp --dport 1700 -m state --state NEW -j ACCEPT
set NTP time:

1. Go to and click the host name corresponding to your area. Assuming the area is North America, the servers are:


2. Open /etc/ntp.conf in a text editor. If you use the nano editor, run sudo nano /etc/ntp.conf

You should see a list of servers similar to the one below, replace the servers with the ones from step 1::

server iburst
 server iburst
 server iburst
 server iburst

3. Comment out (by adding a # in front of the line) the following two lines:

  restrict ::1

4. Save the file and exit

5. Set the correct time zone by running # sudo cp /usr/share/zoneinfo/US/Pacific /etc/localtime. Replace US/Pacific with your time zone. If you are not sure about the possible values, look in /usr/share/zoneinfo

6. Restart the ntp server: sudo /etc/init.d/ntp restart

7. Run date in a terminal

8. If the time is not correct, you might have to force update it. This is because, by default, ntp will not sync if the difference between the system time and the real-time is greater that 1000 seconds. Run sudo ntpd -gq and the restart ntp

Turn off WiFi:
# iwconfig wlan0 txpower off (if needed tun on: # iwconfig wlan0 txpower auto)

check status:

# rfkill list all

3. Assemble it all together

step by step here

Connect the jumper wires between the two boards using the following table:
iC880a pin Description RPi physical pin
21 Supply 5V 2
22 GND 6 (14, 25)
13 Reset 11
14 SPI CLK 23
15 MISO 21
16 MOSI 19
17 NSS 24

OK! We’re now ready to power up and start configuring our gateway!

4. Setting up the software

  • Use raspi-config utility to enable SPI> ([5] Interfacing options -> P4 SPI) and also expand the filesystem ([7] Advanced options -> A1 Expand filesystem):
     $ sudo raspi-config
  • Reboot (it will ask on exit, but you can do it manually with sudo reboot)
  • Configure locales and time zone:
      $ sudo dpkg-reconfigure locales
      $ sudo dpkg-reconfigure tzdata
  • Make sure you have an updated installation and install git:
    $ sudo apt-get install git
  • Create new user for TTN and add it to sudoers
     $ sudo adduser ttn
  • Logout and login as ttn and remove the default pi user
    $ sudo userdel -rf pi
  • Configure the wifi credentials (check here for additional details)
      $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf 

And add the following block at the end of the file, replacing SSID and password to match your network:

  • Clone the installer and start the installation
      $ git clone -b spi ~/ic880a-gateway
      $ cd ~/ic880a-gateway
      $ sudo ./ spi
  • If you want to use the remote configuration option, please make sure you have created a JSON file named as your gateway EUI (e.g. B827EBFFFE7B80CD.json) in the Gateway Remote Config repository. EUI folows MAC addr of eth0 (or wlan0)
  • By default, the installer changes the hostname of your Raspeberry Pi to ttn-gateway (to prevent collisions with other Raspberry Pis in your network). You can override this in non-remote configuration mode.
  • reset iC880a on boot (GPIO 17 = pin 11 conected to reset pin 13 on iC880a):

put simlink to /etc/rc2.d to following script:


echo "17" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction
echo "1" > /sys/class/gpio/gpio17/value
sleep 5
echo "0" > /sys/class/gpio/gpio17/value
sleep 1
echo "0" > /sys/class/gpio/gpio17/value (END)


5. Checking connection to TTN (The Things Network)

The best way to check if the gateway is working is registering it on the TTN Console.

  • Login to Console
  • Click on Gateways -> Register gateway
  • Select the Packet forwarder protocol
  • Enter your Gateway EUI (if is printed on start and end of the installer)
  • Enter any description
  • Select Europe 868 MHz as frequency plan
  • Select the correct antenna placement according to your plans
  • Confirm clicking Register gateway

Now you can see the status (which at this point should be connected if we did everything right) and traffic of your gateway!

And now we’re really done!

6. Backups

RPI – save SD card

RPI backup img:
# dd if=/dev/mmcblk0 | gzip -1 - | ssh user@backup-server dd of=image.gz
Raspi UPS HAT Board: