LoRaWAN Setup using Dragino Gateway and TheThingsNetwork

0 50410 Medium

Hey, what's up, Guys! Akarsh here from CETech.

In some of my previous projects, I was regularly using LoRa modules and came across a lot of advantages and applications of LoRa modules which I showcased in those projects. In this project, I am going to take the use of the LoRa technology one step further. Till now we were using only LoRa but in this project, we are going to use LoRa WAN in which we will use LoRa in combination with the Internet. For this purpose, we are going to use a LoRa WAN Gateway from Dragino and with that, we will be using The ThingsNetwork as the Server for this project. What we are going to do is that we will set up our Dragino LoRaWAN gateway and connect it to the Arduino which also has a LoRa module mounted to it. Then we will upload a code that will create a connection between the gateway and the Arduino through TheThingsNetwork server and as the connection is established, the Arduino will generate random numbers and send them to the server which can be received and observed there.

So go through the article and you will gain some good knowledge about LoRa WAN and of course about the Dragino Gateway Setup and TheThingsNetwork.

You can get your own Dragino Kit from the links given below:

In India: https://www.enthutech.in/shop/product... 

Outside: http://www.dragino.com/products/lora/...

Now Let's get started.

projectImage

Get PCBs for Your Projects Manufactured

projectImage

PCBGOGO, established in 2015, offers turnkey PCB assembly services, including PCB manufacturing, PCB assembly, components sourcing, functional testing, and IC programming.

Its manufacturing bases are equipped with the most advanced production equipment such as YAMAHA pick and place machine, Reflow oven, Wave soldering Machine, X-RAY, AOI testing machine; and the most professional technical personnel.

Though it’s only five years old, their factories have experience in the PCB industry for over 10 years in Chinese markets. It is a leading specialist in surface-mount, thru-hole, and mixed technology PCB assembly and electronic manufacturing services as well as turnkey PCB assembly.

PCBGOGO provides the order service from prototype to mass production, join them now.

 

What Is LoRa WAN?

projectImage

The LoRaWAN specification is a Low Power, Wide Area (LPWA) networking protocol designed to wirelessly connect battery operated ‘things’ to the internet in regional, national, or global networks, and targets key Internet of Things (IoT) requirements such as bi-directional communication, end-to-end security, mobility and localization services.

LoRaWAN network architecture is deployed in a star-of-stars topology in which gateways relay messages between end-devices and a central network server. The gateways are connected to the network server via standard IP connections and act as a transparent bridge, simply converting RF packets to IP packets and vice versa. The wireless communication takes advantage of the Long Range characteristics of the LoRaÒ physical layer, allowing a single-hop link between the end-device and one or many gateways. All modes are capable of bi-directional communication, and there is support for multicast addressing groups to make efficient use of spectrum during tasks such as Firmware Over-The-Air (FOTA) upgrades or other mass distribution messages.

projectImage

Security is a primary concern for any mass IoT deployment and the LoRaWAN specification defines two layers of cryptography:

A unique 128-bit Network Session Key shared between the end-device and network server.

A unique 128-bit Application Session Key (AppSKey) shared end-to-end at the application level.

AES algorithms are used to provide authentication and integrity of packets to the network server and end-to-end encryption to the application server. By providing these two levels, it becomes possible to implement ‘multi-tenant’ shared networks without the network operator having visibility of the user's payload data.

The Dragino IoT Kit

projectImage


The Dragino IoT Kit is a well-designed kit to facilitate beginners and developers to quickly learn LoRa and IoT Technology. With the help of this kit, you can make a lot of LoRa based project and also learn about the IoT applications of LoRa. This kit comes in two versions V1 and V2. We are using the V2 kit in our project as it is the latest one. This Kit comes with the following items in it:

1 x LG01-N Single Channel LoRa Gateway

1 x (LoRa Shield + Arduino UNO)1 x (LoRa/GPS Shield + Arduino UNO)

1 x flame sensor

1 x Relay

1 x photosensitive sensor

1 x Buzzer

1 x Ultrasonic Sensor

1 x DHT11 Temperature and Humidity Sensor

10 x DuPont wire (male to male)

10 x DuPont wire (female to female)

10 x DuPont wire (female to male)

With all these tools you can build a number of projects based on LoRaWAN and can equip them for IoT applications.

You can get a more detailed description of the Kit from here.

About Dragino LG01-P IoT Gateway Featuring LoRa Technology

projectImage

Dragino offers a range of LoRa WAN Gateways which are meant for different purposes but the one we are going to use here is the LG01-P IoT Gateway featuring LoRa Technology.

It is an open-source single channel LoRa Gateway. It lets you bridge LoRa wireless network to an IP network via WiFi, Ethernet, Or 3G/4G cellular via optional LTE module. TheLoRa wireless allows users to send data and reach extremely long ranges at low data-rates. It provides ultra-long range spread spectrum communication and high interference immunity. LG01-P offers a number of internet connection methods such as WiFi interface, Ethernet port, and USB host port. These Interfaces provide flexible methods for users to connect their sensor networks to the Internet. It can support limited LoRaWAN protocol in single frequency and customized LoRa transmit protocol.

projectImage

Some of the main features of this gateway are that It consumes Low Power, has a built-in webserver, has a failsafe design providing a robust system, is compatible with Arduino IDE, etc. It also supports WiFiAP, Client, or Ad-Hoc(Mesh) mode.

You can read the datasheet of the LG01-P from here to get a detailed view of its technical specifications.

For other details, you can refer to their website from here.

Looking at TheThingsNetwork Server

projectImage

TheThingsNetwork Server is an open-source platform that offers Secure, Scalable, and reliable LoRa routing of your valuable IoT data. The main features of TheThingsNetwork are Secure routing, Device management, User management, Data Storage, Monitoring, etc.

This Network server allows the encryption to run from the sensor to the application without any third party having access to the keys which is also known as end-to-end secured. This is made possible by allowing the user to run the network server or its components on their premises or in the private cloud. Talking about Integration, TheThingsNetwork server supports deep integration which allows easy integration with existing billing or user management systems while building network operated services. Apart from these features, TheThingsNetwork Server is scalable. It can be scaled horizontally as well as vertically as the data stream from and to the devices increases and the server load increases. So we will be using this Network Server for our project.

Setting Up the LoRaWAN Gateway With TheThingsNetwork

projectImage

In this step, we will set up the LoRa WAN gateway with TheThingsNetwork Server and will make it ready for use. For that purpose we need to follow the steps given below:-

1) Take the LG01-P Gateway and connect its antenna and after that connect the gateway to power with the help of the adapter that comes with the gateway. The adapter needs to be connected to the 12V-1A port.

2) Connect one side of the LAN cable to the LAN port of the Gateway and the other side to your PC/Laptop which is being used for the setup.

3) Now, head over to your web browser and type the IP address "10.130.1.1" this will take you to the Dragino Login page. There you need to enter the username as "root" and password as "dragino" and then press the Login button.

4) Now we need to connect our gateway to the Internet using WiFi for that we need to go to the Network tab. In that, we need to select the Wireless option. It will open a page where there will be an option named "radio0". You need to click the scan button in front of that "radio0" option.

projectImage

5) This will open a list of available WiFi networks in the range of Gateway. Hit the "Join Network" button corresponding to your WiFi SSID. This will open a joining network page.

6) On that page there will be a block named WPA passphrase. In that block, you need to enter the password of your WiFi network, and below that there is another field where you need to enter the name of the new network. In that block, you can give any name of your choice that will be the name of your network. After that click the submit button and on the next page click the Save and apply button.

7) After the completion of the above steps, Your gateway will be connected to your Wifi network. As the gateway is connected to the Wifi we need to disable the dragino SSID because it essentially makes the gateway an Access Point. So we need to disable that dragino SSID to get connected to the Wifi.

8) Now open TheThingsNetwork console and hit the Gateways button. Here we need to register a new network for that click the Register Network button. This will open the Register Network page on that page select the Legacy Packet forwarder option.

projectImage

9) After that head back to the dragino page. On that page go to the services tab and under that select the LoRaWAN Gateway option. A webpage will open up on that page there will be a Gateway ID present. Copy that Gateway ID and paste that in the Gateway EUI option on the ThingsNetwork console page.

10) After that enter any description in the description block on the ThingsNetwork console page, Select the frequency Plan(In my case, It is INDIA), Select the location on the map where your gateway is present, select the Antenna Placement option(In my case, It was Indoor) and then click the register gateway button.

11) This will register the network and that can be verified by looking at the status which should say "Connected".

projectImage

12) Now we can go back to the dragino gateway page. There we need to set the radio power to 20 and the frequency value to "865402500 Hz". We don't need to change the other values. After that click the Save and apply button and this will wrap up our Gateway Setup.

There are a number of steps that may seem confusing That's why I refer you to watch the ​video of this project once before you start doing. It will help you in following the process step by step.

Creating Application and Coding the Arduino

projectImage

The Dragino Kit comes with two Arduino Uno. One mounted with the Lora module and the other mounted with the GPS module along with the LoRa module. For our project, we will be using the one without the GPS module.

In this step, we will create an application using TheThingsnetwork Console to obtain the data from the Arduino and also code the Arduino to send data. For that we need to follow the below steps:-

1) Go to the TheThingsNetwork console page. On that page click on the Applications button. This will open up the Add Application page. There you need to enter the Application ID and Description. These can be of anything of your choice. Other than these, there is a handler registration field which is set to "ttu-handler-eu" by default. We have to leave it as it is and then click the Add Application button. This creates the Application.

2) Now we need to make the application capable of interpreting the data received from the Arduino. For that purpose, you need to open the GitHub page from here. On that page, you will see a file named "Payload Script". Open that file and copy the script given there. Now go back to the Applications page open the Payload Formats tab and copy the script there. Now hit the save button and you are good to go.

projectImage

3) Our application is ready for use. Now we need to upload the code to our Arduino board. This code will create a connection between the gateway and the Arduino through the LoRa module and then the Arduino will generate some random numbers which can be received and seen at TheThingsNetwork server setup.

4) To get the code for this you have to go to the Github age again there you will see a file named "Arduino_Hello_world.ino". This is the code that is to be uploaded to the Arduino copy this and paste it in your Arduino IDE.

5) Now head back to the console page of TheThingsNetwork there you will see an option saying "Register Device". Click on that option because for adding nodes to the gateway we first need to register the device. On the registration page, you need to enter a Device ID and a Device EUI. This can be random and anything of your choice. After entering these you need to click the Register button.

projectImage

6) A new device is now created on TheThingsNetwork. It is by default created in the OTAA method, you need to change the method to ABP by going to the Activation Method option in the device settings and then clicking the save button.

7) Now go back to the device overview page. On that page, you will see three different fields namely, Network Session Key, App Session Key, and Device Address. Copy these fields one by one and paste them into the code at their respective places.

8) Now we need to connect the Arduino to our PC. Select the correct COM port and Board and after that click the upload button.

In this way, the setup for the project is complete now all we need to do is to play around with our newly settled gateway.

Testing the New Gateway link

projectImage


Before uploading the code when we see the TheThingsNetwork console page. We observe that there is a ​status field that says "never seen" but as soon as we upload the code the Arduino gets connected to the Gateway through LoRa and the status changes to just now and after that, it changes to 1 second ago, 2 seconds ago and so on. This shows that the Arduino is sending data and it is successfully received at the Server end.

Talking about the code. It is designed in such a manner that it continuously sends random numbers to the server the number received can be seen on the server-side by going to the Data tab on the console page where the received data is visible. We can also see the data sent by the Arduino on the Serial Monitor to cross-check that the numbers are transmitted correctly.

In this way, We used the Dragino LG01-P IoT gateway to create a LoRaWAN and successfully transmitted data over that. Hope you liked the project.

License
All Rights
Reserved
licensBg
0