Supports LoRaWAN. Measure distance and water level with Dragino and The Things Network(TTN V3).
Takahiro-Y01
Posted on May 30, 2022
Table of Contents
- Devices and Services Used
- Gateway Settings
- TTN settings
- Code changes and Communication frequency settings
1. Devices and Services Used
This article shows you how to upload data to The Things Network V3 using Dragino's sensors and gateways.
- End Nodes : LDDS75-8(Dragino)
- Concentrator / Gateway : LIG16(Dragino)
- Network Server : TTN V3(The Things Network V3)
2. Gateway Settings
2.1 Connect via Wifi
When you turn on the gateway,"dragino-xxxxxx" will be displayed in the Wifi SSID. Please connect to this.
The Wifi network password is "dragino+dragino".
2.2 Access to Management Screen
Enter "http://10.130.1.1" in your browser.
User Name: root
Password: dragino
2.2.1 LoRa Settings
Select "LoRa" from "LoRa" in the menu.
- Change the "Frequency Plan" to suit your country. I live in Japan, so I set it up for Japan.
Click "Save & Apply" when the settings are complete.
2.2.2 LoRaWAN Settings
Select "LoRaWAN" from "LoRaWAN" in the menu.
Do not change the "Gateway ID". This ID is used in the TTN settings.
Select "The Things Network V3" for "Service Provider".
Then, for "Server Address", select "Cluster" of "TTN V3". I chose "eu1.cloud.things.network".
Click "Save & Apply" when the settings are complete.
2.2.3 WiFi Settings
Select "WiFi" from "Network" in the menu.
- Enable "Enable WiFi WAN Client".
- Please enter the information of the Wifi to connect.
- Please use 2.4GHz band WiFi.
Click "Save & Apply" when the settings are complete.
3. TTN settings
3.1 Access to TTN
Go to "https://www.thethingsnetwork.org".
After registering for free, click "Start building"
- Select the Cluster set in the gateway. I chose "Europe 1".
3.2 Gateway Registration
- Select "Register a gateway".
Set the "gateway ID" and "gateway EUI". Any "gateway ID" is OK.
For the "gateway EUI", enter the "gateway ID of the Dragino gateway".
- Choose "Frequency Plan" that suits your country. I chose "Asia 920-923 MHz with LBT".
- Click "Create gateway" when the settings are complete.
- After waiting for a while, the gateway will be connected.
3.3 Application Registration
- Select "Go to applications".
- Click "add application"
- Any "Application ID" is OK.
- Click "add end device".
- Enter the information for your end device.
- If the end device is turned on, communication will start.
- If the data is not displayed, for example "No Sensor", you need to change the code. If you want to change the code, please refer to "4.1".
4. Code changes and Communication frequency settings
4.1 Code changes
- If you are using LDDS75 and "No Sensor" is displayed, change the program as follows.
- If you look at this table, you can see that the values are stored in the 3rd and 4th.
- Select "Payload formatters" for the end device.
- Then select "Custom Javascript formatter" for "Formatter type". Now you can edit the code.
Click "Save changes" and you're done.
Please change it according to the type of end device to be used.
function decodeUplink(input) {
var data = {};
var len=input.bytes.length;
var value=(input.bytes[0]<<8 | input.bytes[1]) & 0x3FFF;
var batV=value/1000;//Battery,units:V
var distance = 0;
var interrupt = input.bytes[len-1];
switch (input.fPort) {
case 2:
if(len==8)
{
distance=input.bytes[2]<<8 | input.bytes[3];
data.distance=distance;//distance,units:mm
if(distance<=20)
data.distance = "Invalid Reading";
}
else
data.distance = "No Sensor";
return {
data:data,
};
default:
return {
errors: ["unknown FPort"]
}
}
}
- Here is the code I used.
4.2 Communication Frequency Settings
- If you want to change the time interval on a Dragino end device, do the following.
How was that?
If you have any questions, please feel free to comment.
Posted on May 30, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.