Skip to content
Gonzalo Casas edited this page Nov 2, 2016 · 55 revisions

From zero to LoRaWAN in a weekend

So you want to extend the coverage of The Things Network in your neighborhood but missed the kickstarter to buy a gateway?

Worry not! It's really easy to build one yourself that is on par with most other gateways when it comes to specs, but is significantly cheaper.

Ordering the parts

Our gateway will be based on the IMST iC880a board. This is the most important piece, the rest are components you might even have already lying around.

Here's our shopping list:

Part Price Order/link
iC880a concentrator board EUR 155.- (excl. tax) IMST Webshop
Pigtail for antenna 5 EUR 6.5 (excl. tax) IMST Webshop
Raspberry Pi 1 EUR 32.- RPi2: Farnell and RPi3: Farnell
Antenna 2 EUR 3.50 - EUR 8 3dBi: Farnell, 5dBi: Aliexpress, 7dBi: Aliexpress, 7.5dBi Aliexpress
Power Supply 2A with micro USB EUR 7.84 Farnell
MicroSD Card (4Gb or more) ~ EUR 8
Backplane board OR dual female jumper wires 3 Options: Simple backplane: OSHPark, Advanced backplane: pcbs.io, or 7 dual female jumper wires.
WiFi dongle 4

[1] It works with RPI 3, RPi 2 B, RPi B+ and even RPi Zero; but avoid the original revisions because the polyfuse might cause problems.

[2] The choice of antenna is huge, pick any of your liking, as long as it is 1/2 wavelength and has 3dBi or higher.

[3] Using a backplane board instead of jumper wires is strongly recommended. Jumper wires can cause interference, and even thou the software will handle it, the performance of your gateway will be sub-optimal.

[4] e.g. Edimax EW-7811UN. Only required if you connect via WiFi instead of Ethernet and not using the Raspberry Pi 3, which already comes with built in WiFi. The alternative is to power the device via the Ethernet cable using a PoE splitter/injector.

[5] Normally, the pigtail is SMA, but on some orders IMST shipped one with a RP-SMA Female connector. Since the linked antennas are SMA Male, you need an RP-SMA Male to SMA Female adapter in this case.

That will get you a functional gateway, but you most likely want to have it in a box. There are plenty of options, here's just one suggestion:

  • IP67 Enclosure (we got ours from decentlab.com)
  • Mounting plate, screws and spacers

Now sit and wait for the postman to make you happy.

Choosing the backhaul

What is a backhaul? Backhaul refers to how the Raspberry Pi will be connected to the Internet.

This guide focuses on using Wifi as backhaul, but you could also use Ethernet or 3G/4G.

If you do have Ethernet available near the gateway, then prefer it over WiFi or 3G/4G. This is because having an additional radio signal inside the enclosure will cause noise. The software can handle the noisy environment, so it's not a big issue, but the less noisy, the better. You can combine this choice with Power-over-Ethernet to minimize the cabling going all the way up to the gateway.

On the other hand, if you choose WiFi instead of Ethernet, then try to use a dongle with external antenna and move the antenna outside the enclosure to have less noise inside the box.

Putting it all together

And now comes the fun part!

First, let's prepare the SD card so that we can insert it on the RPi and be ready to boot:

Some things won't be easily accessible once we mount the boards, so better connect them before hand:

  • Install the SD card in the RPi
  • Connect the WiFi dongle to RPi
  • Connect ethernet cable to RPi
  • Connect the pigtail to iC880a

The stage is set! We can start mounting our gateway:

  • Drill the mount holes for both boards on the mounting plate
  • Mount both boards on the mounting plate (add spacers between board and mounting plate for ventilation)
  • Mount the mounting plate in the enclosure
  • Install the antenna (WARNING: never power up without the antenna!)
  • 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
13 Reset 22
14 SPI CLK 23
15 MISO 21
16 MOSI 19
17 NSS 24

Pinout Mounted boards

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

Setting up the software

  • Plug the power supply of the RPi which will also power the concentrator board

  • From a computer in the same LAN, ssh into the RPi using the default hostname:

      local $ ssh [email protected]
    
  • Default password of a plain-vanilla RASPBIAN install for user pi is raspberry.

  • Use raspi-config utility to enable SPI (9 Advanced options -> A6 SPI or A5 SPI for v3) and also expand the filesystem (1 Expand filesystem):

      $ sudo raspi-config
    
  • Reboot (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 update
      $ sudo apt-get upgrade
      $ sudo apt-get install git
    
  • Create new user for TTN and add it to sudoers

      $ sudo adduser ttn
      $ sudo adduser ttn sudo
    
  • To prevent the system asking root password regularly, add TTN user in sudoers file

      $ sudo visudo
    

Add the line ttn ALL=(ALL) NOPASSWD: ALL

⚠️ Beware this allows a connected console with the ttn user to issue any commands on your system, without any password control. This step is completely optional and remains your decision.

  • 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:

	network={
	    ssid="The_SSID_of_your_wifi"
	    psk="Your_wifi_password"
	}
  • Clone the installer and start the installation

      $ git clone -b spi https://github.com/ttn-zh/ic880a-gateway.git ~/ic880a-gateway
      $ cd ~/ic880a-gateway
      $ sudo ./install.sh 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.

  • 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.

  • Unplug the Ethernet cable and close the enclosure

  • Big Success! You should now have a running gateway in front of you!

Gateway ready

Wrapping up

Depending on the kind of enclosure you selected, you might still need to do one more thing: put the power cable through the weather-proof cable holes.

For this purpose, we will cut the micro USB end of the power supply, pass it through the hole, solder the wires to jumper wires, and finally connect 5v and GND to the Raspberry Pi:

Micro USB RPi physical pin
Supply 5V 4
GND 9

In the following image, I used a tiny, generic breakout board with pin header to connect the wires. That is not really required, it's only to keep the cabling neatly arranged inside the box.

Gateway powered via RPi GPIOs

And now we're really done!

Here's our final product!

Now go install the gateway in a nice location to give your neighborhood the joy of IoT!

Clone this wiki locally