The Things Network US setup with Lopy as a Nano Gateway and Lopy Node

I finally was able to configure my Lopys in the US to communicate with The Things Network(TTN). I will show you how to set it up since some changes are needed to make it work in North America. 

I am using the same code of this tutorials from Pycom with some adaptations so you can connect to TTN in the US.

I recommend you watch this video for some good explanation on how they did it.

 

 

The first thing we will need to do is to setup TTN. Open an account if you don't have it, once the account is created go to the console and click on Gateway.

 

Next on your right click on "register gateway"

 

You will see the following form. Make sure to mark "I m using the legacy packet forwarder", on Gateway EUI write a random identifier of 8 bytes,  Select 915 Mhz United States and set the router as the picture. Finally, click Register Gateway on your bottom right.

 

 After filling the form you will see this screen.

 

 

Now that we have registered a Gateway, let's register an Application, go to the console  and click on Application

 

Find the Add Application button and click it.

Fill the form, give the application a random ID and select ttn-handler-us-west. Click on Add Application

 

 

Now click on "Register Device"

 

Now we will proceed to register the Device. On device Id put the number you want. On device EUI is recommended that you put the LoRa MAC of your LoPy, use this Code go get it. now click on "Register"

 

 

Now that the device is registered we need to change a few things

 

On your upper right click on settings and this screen will appear. Change the Activation Method to ABP by clicking on it. 

 

 

You will notice that some other fields appeared, that is ok just click on "Save".

 

 

Your device is now ready, you will use the following parameters on the LoPy Code:

  • Device Address
  • Network Session Key
  • App Session Key

 

 

 

 

Looks like everything is setup on TTN. Now you will need to download the code that will run on the Nanogateway and on the Node

 

For the Nanogateway use this code. 

For the Node use this code

 

After downloading and modifying the code, go back to the console gateway, click on the gateway you created and check that it boot ok by monitoring your lopy on the serial port.

My gateway looks connected and communicating with TTN.

 

Now, lets check TTN and the status is Connected. Turn on the Node. 

This is the output of the Node Code

Now navigate to the console again and select applications. Go to the application that you just created and click on DATA, you should be able to see the payload you just sent.

 

 

I hope everything went well and if you have any questions you can contact me on my twitter @SeaSlugLabs

 


Leave a comment