DEV Community

Cover image for Supports LoRaWAN. Measure distance and water level with Dragino and The Things Network(TTN V3).
Takahiro-Y01
Takahiro-Y01

Posted on • Updated on

Supports LoRaWAN. Measure distance and water level with Dragino and The Things Network(TTN V3).

Table of Contents

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.

Image description

  • 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.

Image description

  • 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.

Image description

  • 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

Image description

  • Select the Cluster set in the gateway. I chose "Europe 1".

Image description

3.2 Gateway Registration

  • Select "Register a gateway".

Image description

  • Set the "gateway ID" and "gateway EUI". Any "gateway ID" is OK.

  • For the "gateway EUI", enter the "gateway ID of the Dragino gateway".

Image description

Image description

  • Choose "Frequency Plan" that suits your country. I chose "Asia 920-923 MHz with LBT".

Image description

  • Click "Create gateway" when the settings are complete.
  • After waiting for a while, the gateway will be connected.

Image description

3.3 Application Registration

  • Select "Go to applications".

Image description

  • Click "add application"

Image description

  • Any "Application ID" is OK.

Image description

  • Click "add end device".

Image description

  • Enter the information for your end device.

Image description

Image description

  • If the end device is turned on, communication will start.

Image description

  • 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.

Image description

  • 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.

Image description

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"]
    }
}
}
Enter fullscreen mode Exit fullscreen mode
  • 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 to Time Interval Setting

Image description

How was that?
If you have any questions, please feel free to comment.

Top comments (0)