-
Notifications
You must be signed in to change notification settings - Fork 210
Home
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.
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 1 | EUR 6.5 (excl. tax) | IMST Webshop |
Raspberry Pi 2 | EUR 32.- | RPi2: Farnell and RPi3: Farnell |
Antenna 3 | 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 | |
RPi to iC880a interface | ~ EUR 5 | Four options:
|
WiFi dongle 5 |
[1] 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.
[2] 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.
[3] The choice of antenna is huge, pick any of your liking, as long as it is 1/2 wavelength and has 3dBi or higher.
[4] Using any of the backplane boards listed 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.
[5] 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.
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.
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.
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:
- Download Raspbian Jessie Lite
- Follow the installation instructions to create the SD card
- Create a new empty file named
ssh
(without extension) onto theboot
partition of the SD card. This enables ssh on the RPi upon startup.
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 |
We're now ready to power up and start configuring our gateway!
-
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
israspberry
. -
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 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
-
Logout and login as
ttn
and remove the defaultpi
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!
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.
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!