Originally I was planning on this being a post detailing how to setup a single channel nano gateway for The Things Network, Doing some distance testing etc. However this quickly wasn't the case as I was only able to get approximately a range of Meters before loosing signal. Not great.
Range of the Nano Gateway, The furthest was approximately 245 Metres, We should easily be getting over 1KM of range.

Step 0 - Funding a proper gateway

The first step was to budget and raise the funds for a proper gateway.

There are two main options, buy the Official The Things Network Gateway, Or make one yourself. The Things Network Gateway is available for ~ £300 INC Vat from Farnell. However is more expensive.

The DIY Route is slightly cheaper depending on what you have, For this while you can use other micro controllers I believe a Pi is the best due to it's built in network capabilities.

To show the costing I've split it into a spreadsheet table.

As you can see the cost for me is just the actual Gateway module, The rest I already have.

Notes - Here's all of the notes.

  1. Some tutorials mention a Raspberry Pi 2 or 3, Some reference a B+ or even a Zero as acceptable. I'll be using a Pi 2. You can use a Pi 3 if you want Wi-Fi however this could cause interference so if you can use LAN it's best.
  2. You don't need a big SD Card. I have lots of 8GB Cards, However for possible increased reliability might use a USB Pen Drive.
  3. Price correct at time of writing based on exchange, price offered, taxes and PNP
  4. Price varies greatly based on what size and type of antenna you use. I'm using one of the ones I got with one of my LoPy modules.
  5. This is to connect the concentrator from the board to a SMA Antenna. Different lengths and types are available depending on what you require.
  6. You can buy a PCB To connect it or just use jumper wires. I'll be going the jumper wire method as I already have these.
  7. This is the most important bit which varies. As mine is going to be indoors to begin with (and possibly later on if outdoors just have the antenna outdoors and still have the electronics inside). For this I will be possibly 3D Printing one.

Funding it
To fund it I did a clear out of other electronics I don't use. As I just needed to get £140 it was rather easy and quick to do.

Step 1 - Buying it all

Another rather easy step, buy it all!

Step 1.5 - Prototyping a case

So as I mentioned I want to make a simple case for it to go in, I don't go for fancy looking cases but instead I go for quick to make and practical. While I don't have the concentrator board I found the dimensions of it and also know the Raspberry Pi's. I also only know how to use TinkerCAD (My 3D cad skills are terrible).

However once I got a rough outline I put it into Cura to see how many grams of plastic it was going to use and it was over 150, Which is around £3s worth of plastic. However if it required multiple prototypes it could quickly start to add-up. So instead I opted for this £10 box from Toolstation, While it's also waterproof I'm not putting my Gateway outside and maybe in the future put it outside.

#Step 2 - Assembly The next set of steps are broken down into each step I took to set the gateway up. This is correct at the time of writing which is the 13th of December. ###2.1 - Preparing the Raspberry Pi To begin I first downloaded the Raspbian OS, I used the Raspbian Stretch Lite version 2017-11-29 which can be downloaded from https://www.raspberrypi.org/downloads/raspbian/ , I also find torrent quicker.

Next you need to image the OS onto an SD Card. OR USB Drive. While a USB Drive could offer more stability I'm going to use an SD Card for ease.

First I formatted the drive with Zero's using Ubuntu's Built in tool. I wouldn't usually do this but thought it would (and weather it will or not I'm not sure) provide some reliability.

Second I then used Etcher.io to image the SD Card.
TOP TIP - After imaging make sure you then create a file called ssh on the boot partition.

2.2 - Wiring The Pi

I have three things I want to wire to the Pi, Power, Network & the gateway to the Pi.
For power and network I connected a network cable and power cable to the Raspberry Pi. Make sure your power supply can provide at least 2A. I'm using a 2.4A Power supply.

For the Gateway board you will require 7 Jumper wires, The shorter the better.
I've used 20CM Jumper wires however you can use shorter if you have them or even buy a PCB to fit it all on.

I connected a strip of 2 jumpers to connect between the Pi's 5V and GND Pins to the gateway board's 5V and GND Pins.
I then connected another strip of 4 to the Pi's SPI 0 Bus Pins + CE0, And then finally a single wire to pin 27. I then connected the strip of 4 to the Gateway's SPI Bus and the single pin to the reset pin of the gateway. You can see as pictured.

Next I connected my antenna jumper to the IMST Board ready to put in the box

2.2 - Putting it all in the box

Using some double sided sticky tape I put it in my box. This I find is strong enough for most cases and allows me to take it out if I require. The box I brought had injection moulded mounting pieces which I didn't expect so I instead chose to stick it all to the lid and it work's perfectly fine as long as you leave some slack.

2.3 - Finishing up assembly

Once everything is plugged in and in the box, with the antenna connected and cables routed it's time to plug it in. Do not power it up unless an antenna is plugged in!!!!

I connected mine to a 2.4A PSU and into the switch next to where it's located.

Step 3 - Setup

Next we need to setup the software.
I did the following steps

  • Find the Raspberry Pi on my network and SSH in
  • Run sudo raspi-config
  • First I changed the Pi's password. I used a randomly generated one.
  • Because I have a lot of Pi's on my network I went into the network config and changed the hostname to rtk-gy-1 which is also going to be my gateway's ID.
  • Next I went into the boot config menu and in wait until network connection is established selected yes.
  • In the interfacing options I then enabled SPI
  • In interface options I used the feature to expand the filesystem to the size of the SD Card and changed the GPU Ram from 64MB to 32MB.
  • I then finished in Raspi-config but selected that I didn't want to reboot yet
  • Next I ran sudo apt update && sudo apt upgrade to update and upgrade the OS on the Pi. And then run sudo apt install git
  • Unlike the ttn-zh guide I'm not creating a new user account but keeping the default with a different password. This Pi won't have SSH open to the internet.
  • I then downloaded the things network packet forwarder using wget https://github.com/TheThingsNetwork/packet_forwarder/releases/download/v2.0.2/imst-rpi-pktfwd.tar.gz and then extracted it using tar -xzvf imst-rpi-pktfwd.tar.gz
  • After this reboot and re-ssh back in
  • Next I ran sudo ./packet-forwarder configure and followed the configuration wizard.
  • From this it then saved a configuration file to /root/.pktfwd.yml
  • Next I then moved the packet-forwarder command to root's home using sudo mv packet-forwarder /root/
  • I can then install the startup script using chmod +x install-systemd.sh to first allow the file to be executed then sudo ./install-systemd.sh /root/packet-forwader /root/.pktfwd.yml
  • I then needed to edit the configuration file to change the reset-pin to be pin 26 as this is the pin I used. I used sudo nano /root/pktfwd.yml and added reset-pin: 26 to the end of the file

I then saved it, rebooted and then ran the following commands:

sudo systemctl daemon-reload
sudo systemctl enable ttn-pkt-fwd
sudo systemctl start ttn-pkt-fwd

But then got an error, For some reason even root couldn't execute the init file I created so I sudo chmod 777 /root in the root directory and tested it and it worked fine. I then tried starting the service again and it worked!, Or did it?

I'm currently with Virgin Media for broadband and it seems that the port that TTN uses is one which virgin media seem to have blocked. So for now I'm using the cheapest VPS available as a budget VPN and it's working fine. However because of this I've had to disable the service and start the internet and then the gateway manually.

Step 4 - Test range!

Step 4 is the simplest, for now I setup a LoPy to transmit a packet every 6 seconds to the gateway and then used the TTN Mapper application on my phone to re-map it. And...........

:'( , Great improvement, But still literally kiliometers away from being right. I'll be working on this in Part 2.


This guide is made up from multiple sources I used to put together this project and try and make it simpler being all in one place. Here's a list of resources used:

Other Notes

This guide was written as I assembled my gateway and may already have changes required.

Enjoy this blogpost? - I'm currently funding for a RAK831 LoRa Concentrator. This will lead to another series of blogposts on setting up a different LoRa Board and possibly include a development series of a Backpane I'm developing. You can donate via Ko-Fi by using the button below