Deploying a gateway for The Things Network using

This article was written by Matthew Macdonald-Wallace of Mockingbird Consulting. Mockingbird Consulting provides workshops on a wide range of topics and is committed to inspiring the next generation of engineers. Their "Internet of Threes" program helps organizations understand how people, places, and things are all part of a successful IoT project.

The Things Network (TTN) is a low cost, community supported alternative to 3G and WiFi. It is powered by LoRaWAN, a new wireless data transmission technology, which combines long range with low power and bandwidth requirements, making it an ideal choice for the Internet of Things. The network can be expanded by anyone willing to deploy a gateway.

This guide explains how can be used to install and configure a LoRaWAN gateway based on a Raspberry Pi and the IMST iC880A gateway board. Be sure to check out this full list of parts before moving on to these steps:

Step 1: Create an application
  • Log in to the dashboard and create a new application. Make sure that you pick the appropriate model of Raspberry Pi—a Raspberry Pi 2 works perfectly well, but if you can stretch to a 3 then we'd recommend doing so.

Step 2: Configure the application
  • Once the application has been created, click on the Environment Variables button in the menu on the left of the screen:

  • Create the variables as follows:
Variable Name Value
GW_CONTACT_EMAIL The email address you want to show on the TTN map for your gateway
GW_REGION The region you should connect to for the TTN (EU/US/CN/AU/AS/KR)
GW_RESET_PIN The GPIO Pin used to reset the iC880A Gateway board (this should be set to 25 if you've purchased any of the interface boards)
GW_TYPE imst-ic880a-spi
SNMP_COMMUNITY Only used if you want to enable SNMP for network monitoring
Step 3: Connect the device
  • From the main application page, click Download resinOS:

  • Flash the image to an SD card using a tool such as Etcher. Put the SD card into your Pi. Make sure the Pi can connect to the internet, either via ethernet or Wifi. Turn on the Pi.

  • While you wait for the Pi to make itself know to, you can connect the hardware and register your gateway on The Things Network console.

  • After about 10 minutes, the Pi should show up on your dashboard with a random name. Click on the name, and you'll find yourself on the main screen for that device. Change the name if you need to, then click on Environment Variables again to set the device-specific settings.

Step 4: Configure the device
  • As with the application, the device is configured using environment variables. Make sure you set the following:
Variable Name Value
GW_DESCRIPTION The description of this particular gateway
GW_ID The ID as configured in The Things Network console
GW_REF_ALTITUDE A fake altitude in meters above sea level if you're not using GPS
GW_REF_LATITUDE The latitude of your device if you're not using GPS
GW_REF_LONGITUDE The longitude of your device if you're not using GPS
SNMP_SYS_CONTACT The SNMP System Contact if you're using SNMP
SNMP_SYS_LOCATION The SNMP Location if you're using SNMP
  • Save these variables, and you'll end up back at the main screen for the device.
Step 5: Push the application to the device

In order to turn the Pi into a gateway, we need to create a Dockerfile, install the packet forwarder, set it to start on boot, and configure it using the environment variables that we set in the preceeding steps.

Fortunately, Mockingbird Consulting has done the vast majority of this work already, so we can get up and running fast.

git clone  
  • In the top right corner of the dashboard there is a text box that starts git remote add resin .... Use this information to add a new remote repository to your existing clone, pointing at's servers:
git remote add resin <USERNAME><USERNAME>/<APPNAME>.git  
  • Push the code from your repository to the servers:
git push resin master  
  • You will see the code build, and if everything is successful you'll be presented with a unicorn letting you know that the build is complete:

Step 6: Verify
  • Change back to the dashboard and click on the device. You should see the status turn from green to blue as it updates with the new software, and then back to green as it comes online again. Logs are displayed in the console panel on the right of the screen.

  • Once the device shows as being online, switch to The Things Network console, and you should see the gateway as online, with a last seen time of within 60 seconds.


If you've made it this far, then you're well on your way to deploying a fleet of gateways.

For each additional gateway that you deploy, just repeat steps 3 and 4—all new devices added to the application will automatically receive the gateway code when they connect. Any updates you push in the future will automatically be sent to all the gateways, upgrading them in place.

And when you're ready to tackle more IoT projects, we've got a long list of tutorials to help you get started!