image-20231110085342-2.png

Table of Contents: 

1. Introduction

1.1 What is LoRaWAN Smart Distance Detector

The Dragino DS20L is a smart distance detector base on long-range wireless LoRaWAN technology. It uses LiDAR sensor to detect the distance between DS20L and object, then DS20L will send the distance data to the IoT Platform via LoRaWAN. DS20L can measure range between 3cm ~ 200cm.

DS20L allows users to send data and reach extremely long ranges via LoRaWAN. It provides ultra-long range spread spectrum communication and high interference immunity whilst minimizing current 
consumption. It targets professional wireless sensor network applications such smart cities, building automation, and so on.

DS20L has a built-in 2400mAh non-chargeable battery for long-term use up to several years*. Users can also power DS20L with an external power source for continuous measuring and distance alarm / counting purposes.

DS20L is fully compatible with LoRaWAN v1.0.3 Class A protocol, it can work with a standard LoRaWAN gateway.

image-20240122174214-1.png

1.2 ​Features

  • LoRaWAN Class A protocol
  • LiDAR distance detector, range 3 ~ 200cm
  • Periodically detect or continuously detect mode
  • AT Commands to change parameters
  • Remotely configure parameters via LoRaWAN Downlink
  • Alarm & Counting mode
  • Firmware upgradable via program port or LoRa protocol
  • Built-in 2400mAh battery or power by external power source
      

1.3 Specification

LiDAR Sensor:

  • Operation Temperature: -40 ~ 80 °C
  • Operation Humidity: 0~99.9%RH (no Dew)
  • Storage Temperature: -10 ~ 45°C
  • Measure Range: 3cm~200cm @ 90% reflectivity
  • Accuracy: ±2cm @ (3cm~100cm); ±5% @ (100~200cm)
  • ToF FoV: ±9°, Total 18°
  • Light source: VCSEL
      

1.4 Power Consumption

Battery Power Mode:

  • Idle: 0.003 mA @ 3.3v
  • Max : 360 mA

Continuously mode:

  • Idle: 21 mA @ 3.3v
  • Max : 360 mA
      

1.5 Use Case

Regular Distance Detect

image-20231214100011-1.png

Counting / Alarm

image-20231214100036-2.png

image-20231214100057-3.png

1.6 LiDAR probe position

1701155390576-216.png

The black oval hole in the picture is the LiDAR probe.

1.7 Interface Definition

image-20231128151132-2.png

1.8 Program Cable Pin Mapping

image-20240314102509-1.jpeg

Usage For the Program Cable:

1) Configure DS20L via AT Command

2) Update Firmware

3) Input for external interrupt

4) Input for external power

1.9 Mechanical

image-20240515104600-1.png

image-20240515104614-2.png

2. Configure DS20L to connect to LoRaWAN network

2.1 How it works

The DS20L is configured as LoRaWAN OTAA Class A mode by default. It has OTAA keys to join LoRaWAN network. To connect a local LoRaWAN network, you need to input the OTAA keys in the LoRaWAN IoT server and press the button to activate the DS20L. It will automatically join the network via OTAA and start to send the sensor value. The default uplink interval is 20 minutes.

2.2 ​Quick guide to connect to LoRaWAN server (OTAA)

Following is an example for how to join the TTN v3 LoRaWAN Network. Below is the network structure; we use the LPS8v2  as a LoRaWAN gateway in this example. 

The LPS8v2 is already set to connected to TTN network , so what we need to now is configure the TTN server. 

image-20240122174214-1.png 

Step 1: Create a device in TTN with the OTAA keys from DS20L.

Each DS20L is shipped with a sticker with the default device EUI as below:

图片-20230426084152-1.png

You can enter this key in the LoRaWAN Server portal. Below is TTN V3 screenshot:

Register the device

image-20231207144600-2.png

Add DevEUI and AppKey

image-20231207145121-5.png

Step 2: Activate on DS20L

image-20231128133704-1.png

Press the button for 5 seconds to activate the DS20L.

The switch is switched to E and the external power supply is used.

The switch is switched to I and DS20L will be power by the built-in battery.

Green led will fast blink 5 times, device will enter OTA mode for 3 seconds. And then start to JOIN LoRaWAN network. Green led will solidly turn on for 5 seconds after joined in network.

After join success, it will start to upload messages to TTN and you can see the messages in the panel.

2.3 ​Uplink Payload

2.3.1 Device Status, FPORT=5

Users can use the downlink command(0x26 01) to ask DS20L to send device configure detail, include device configure status. DS20L will uplink a payload via FPort=5 to server.

The Payload format is as below.

Size(bytes)

12112
ValueSensor ModelFirmware VersionFrequency BandSub-bandBAT

Example parse in TTNv3

image-20231206151412-3.png

Sensor Model: For DS20L, this value is 0x21

Firmware Version: 0x0100, Means: v1.0.0 version

Frequency Band:

0x01: EU868

0x02: US915

0x03: IN865

0x04: AU915

0x05: KZ865

0x06: RU864

0x07: AS923

0x08: AS923-1

0x09: AS923-2

0x0a: AS923-3

0x0b: CN470

0x0c: EU433

0x0d: KR920

0x0e: MA869

Sub-Band:

AU915 and US915:value 0x00 ~ 0x08

CN470: value 0x0B ~ 0x0C

Other Bands: Always 0x00

Battery Info:

Check the battery voltage.

Ex1: 0x0B45 = 2885mV

Ex2: 0x0B49 = 2889mV

2.3.2 Uplink Payload, FPORT=2

AT+MOD=1 (Case: Regular Report Distance)

Regularly detect distance and report. When the distance exceeds the limit, the alarm flag is set to 1, and the report can be triggered by external interrupts.

Uplink Payload totals 10 bytes.

Size(bytes)21214
ValueBATMOD+ Alarm+ InterruptDistanceSensor StateInterrupt Count

MOD+ Alarm+ Interrupt:

Size(bit)[bit7:bit6]bit5bit4
ValueMODDigital Interrupt

Distance Alarm
0: No Alarm;
1: Alarm

Example parse in TTNv3

image-20231206195704-6.png

Battery Info:

Check the battery voltage for DS20L

Ex1: 0x0E10 = 3600mV

MOD & Alarm & Interrupt:

MOD:

Example:  (0x60>>6) & 0x3f =1

0x01:  Regularly detect distance and report.
0x02:  Uninterrupted measurement with counting(external power supply).

0x03:  Uninterrupted measurement with distance alarm(external power supply).

Alarm:

When the detection distance exceeds the limit, the alarm flag is set to 1.

Interrupt:

Whether it is an external interrupt.

Distance info:

Example:

If payload is: 0708H: distance = 0708H = 1800 mm

Sensor State:

Ex1: 0x00: Normal collection distance

Ex2 0x0x: Distance collection is wrong

Interript Count:

If payload is:000007D0H: count = 07D0H =2000

AT+MOD=2 (Continuously Measure with Counting)

The power consumption of uninterrupted measurement is high, and the device needs to use external power supply.(The switch is switched to E and the external power supply is used.)

image-20231214102129-1.png

Example: Measure with Counting
  • Set the person or object count mode: AT+MOD=2,0,50,200

Continuous measurement and counting, detect and count passing people or objects in distance limit mode.

Uplink Payload totals 13 bytes.

Size(bytes)21442
ValueBATMOD+Collection modeCountingPulse TimeCollection Threshold

MOD+Collection mode + Count flag:

Size(bit)[bit7:bit6]bit5
ValueMOD

Collection mode

Example parse in TTNv3

image-20240311135925-2.png

BAT & MOD & Collection mode & Interrupt Flag & Counting & Pulse_time & Collection_threshold:

BAT:

The current total battery voltage of the node.

Example: 0x0c 36(hex) =  3126(DEC)/1000 = 3.126V

MOD:

Example:  (0x80>>6) & 0x3f =2

0x01:  Regularly detect distance and report.

0x02:  Uninterrupted measurement with counting(external power supply).

0x03:  Uninterrupted measurement with distance alarm(external power supply).

Collection mode:

Interrupt pin input level signal flag.

Example: (bytes[2] >> 7) & 0x01 = 1

0x00: Low level acquisition.

0x01: High level acquisition.

Counting:

The total count from startup to this moment.

Example:0x 00 00 10 10(HEX) = 4112(DEC)

Collection_threshold:

Within the set pulse detection time, collection starts when the object or person enters the set detection range.

Example: 0x00 32(hex) = 50(DEC)(unit: mm)

Note: The minimum threshold is 10 and the maximum is 2000.(Unit:mm)

Pulse_time:

Within the set pulse detection time, the object or person enters the detection range and starts collecting.

Example: 0x00 00 00 C8(hex) = 200(DEC)(unit: ms)

Note: This threshold is unlimited.

AT+MOD=3 (Continuously Measure with Distance detection + Alarm )(Since firmware v1.0.2)

The power consumption of uninterrupted measurement is high, and the device needs to use external power supply.(The switch is switched to E and the external power supply is used.)

image-20231214102129-1.png

Example: Measure with Distance
  • Set the distance or object count mode: AT+MOD=3,0,50,200

Continuous measurement and distance detection, Detect the distance of a person or object in distance limit mode and alarm out of limit.

Uplink Payload totals 6 bytes.

Size(bytes)2121
ValueBATMOD+Interrupt flag+alarm flagdistance_mmdistance state

MOD+Alarm flag+Interrupt flag:

Size(bit)[bit7:bit6]bit5bit4
ValueMOD

Alarm flag

Interrupt flag

Example parse in TTNv3

image-20240411160810-1.png

BAT & MOD & Interrupt flag & alarm flag & distance & distance state:

BAT:

The current total battery voltage of the node.

Example: 0x0c 36(hex) =  3126(DEC)/1000 = 3.126V

MOD:

Example:  (0xC0>>6) & 0x3f =3

0x01:  Regularly detect distance and report.

0x02:  Uninterrupted measurement counting(external power supply).

0x03:  Uninterrupted measurement with distance alarm(external power supply).

Interrupt flag:

Example:  (0xC0>>4) & 0x01 = 0

0x00:  The pin is in a low state.

0x01:  The pin is in a high state.

Alarm flag:

Example:  (0xC0>>5) & 0x01 = 0

0x00:  Not in alarm state.

0x01:  In alarm state.

Distance info:

Example:

If payload is: 0708H: distance = 0708H = 1800 mm

Distance state:

Ex1: 0x00: Normal collection distance

Ex2 0x0x: Distance collection is wrong

2.4 Decode payload in The Things Network

While using TTN network, you can add the payload format to decode the payload.

image-20231206143515-1.png

The payload decoder function for TTN is here:

2.5 ​Show Data in DataCake IoT Server

DATACAKE provides a human friendly interface to show the sensor data, once we have data in TTN, we can use DATACAKE to connect to TTN and see the data in DATACAKE. Below are the steps:

Step 1: Be sure that your device is programmed and properly connected to the network at this time.

Step 2: To configure the Application to forward data to DATACAKE you will need to add integration. To add the DATACAKE integration, perform the following steps:

image-20231207153532-6.png

image-20231207155940-8.png

For more detailed instructions, refer to the following instructions: Welcome - Datacake Docs

image-20231207160733-11.png

Step 3: Create an account or log in Datacake.

Step 4: Search the DS20L and add DevEUI.

image-20231207160343-10.png

After added, the sensor data arrive TTN V3, it will also arrive and show in Datacake.

image-20231129100454-2.png

2.6 Frequency Plans

The DS20L uses OTAA mode and below frequency plans by default. Each frequency band use different firmware, user update the firmware to the corresponding band for their country.

http://wiki.dragino.com/xwiki/bin/view/Main/End%20Device%20Frequency%20Band/

3. Configure DS20L

3.1 Configure Methods

DS20L supports below configure method:

3.2 General Commands

These commands are to configure:

  • General system settings like: uplink interval.
  • LoRaWAN protocol & radio related command.

They are same for all Dragino Devices which support DLWS-005 LoRaWAN Stack. These commands can be found on the wiki:

End Device AT Commands and Downlink Command

3.3 Commands special design for DS20L

These commands only valid for DS20L, as below:

3.3.1 Set Transmit Interval Time

Feature: Change LoRaWAN End Node Transmit Interval.

AT Command: AT+TDC

Command ExampleFunctionResponse
AT+TDC=?Show current transmit Interval

30000
OK
the interval is 30000ms = 30s

AT+TDC=60000Set Transmit Interval

OK
Set transmit interval to 60000ms = 60 seconds

Downlink Command: 0x01

Format: Command Code (0x01) followed by 3 bytes time value.

If the downlink payload=0100003C, it means set the END Node's Transmit Interval to 0x00003C=60(S), while type code is 01.

  • Example 1: Downlink Payload: 0100001E       // Set Transmit Interval (TDC) = 30 seconds

  • Example 2: Downlink Payload: 0100003C      // Set Transmit Interval (TDC) = 60 seconds 

     

3.3.2 Set Interrupt Mode

Feature, Set Interrupt mode for pin of GPIO_EXTI.

When AT+INTMOD=0 is set, GPIO_EXTI is used as a digital input port.

AT Command: AT+INTMOD

Command ExampleFunctionResponse
AT+INTMOD=?Show current interrupt mode

0
OK
The mode is 0 =Disable Interrupt

AT+INTMOD=3

(default)

Set Transmit Interval
0. (Disable Interrupt),
2. (Trigger by falling edge)
3. (Trigger by rising edge)

OK

Downlink Command: 0x06

Format: Command Code (0x06) followed by 3 bytes.

This means that the interrupt mode of the end node is set to 0x000003=3 (rising edge trigger), and the type code is 06.

  • Example 1: Downlink Payload: 06000000       //  Turn off interrupt mode
  • Example 2: Downlink Payload: 06000003      //   Set the interrupt mode to rising edge trigger

Note:

1. This interrupt only takes effect in mode 1.

2. If set INTMOD=1, the interrupt mode will not work properly because the rising edge and falling edge cannot exist at the same time, which will affect the low power consumption of the motherboard and increase battery consumption.

3.3.3 Set work mode

Feature: Switch working mode(Note: After the modified mode is issued, the node will automatically reset and restart)

AT Command: AT+MOD  (1: Regular Measurement , 2: Continuous Measuring & Couting, 3: Continuous Measuring & Distance Alarm)

Command ExampleFunctionResponse
AT+MOD=?Get the current working mode.OK
AT+MOD=1Set the working mode to Regular measurements.OK
Attention: Take effect after ATZ

AT+MOD=2,0,50,200

 

Set the working mode to
Continuous measurement with counting.

OK
Attention: Take effect after ATZ

AT+MOD=3,0,1800,200Set the working mode to
Continuous measurement with distance alarm.
OK
Attention: Take effect after ATZ

Explanation of MOD=2

Command ExampleParametersExplanation

 

AT+MOD=2,aa,bb,cc

2: Set MOD=2

Continuous Measuring & Counting

AA: Counting Condition

0: Count while detect value Smaller than Distance Settings(Parameters BB)
1: Count while detect value Bigger than Distance Settings(Parameters BB)

BB: Distance setting10mm~2000mm
CC: Min Counting Time

The object is detected within the set distance for CC time, count +1 (unit :ms) (Unit: ms)

Example: AT+MOD=2,1,50,200

DS20L adopts uninterrupted measurement + counting mode.

Within a distance of 50 to 2000mm(bigger than 50mm), when DS20L detects an object for 200ms, count +1.

Downlink Command:

Format: Command Code (0x0A) followed by 6 bytes.

  • Example: 0A 01        //  Same as AT+MOD=1
  • Example: 0A 02 00 00 32 00 00 00 C8       //  Same as AT+MOD=2,0,50,200

Explanation of MOD=3

Command ExampleParametersExplanation

 

AT+MOD=3,aa,bb,cc

3: Set MOD=3

Continuous measurement with distance alarm

AA: Distance Alarm Condition

0: Distance alarm while detect value Smaller than Distance Settings(Parameters BB)
1: Distance alarm while detect value Bigger than Distance Settings(Parameters BB)

BB: Distance Setting10mm~2000mm
CC: Min Alarm Time

When continuous CC time detects the distance exceeds the set range, alarm (Unit: ms)

Example: AT+MOD=3,0,50,200

DS20L adopts uninterrupted measurement + distance alarm mode.

When the distance is detected to be less than 50mm for 200ms, node alarm.

Downlink Command:

Format: Command Code (0x0A) followed by 6 bytes.

  • Example: 0A 01        //  Same as AT+MOD=1
  • Example: 0A 03 00 00 32 00 00 00 C8       //  Same as AT+MOD=2,0,50,200

3.3.4 Set threshold and threshold mode(Valid only if AT+MOD=1)

Feature, Set threshold and threshold mode

When AT+DOL=0,0,0,0,400 is set, No threshold is used, the sampling time is 400ms.

AT Command: AT+DOL

Command ExampleFunctionResponse
AT+ DOL =?Get the current threshold mode and sampling time

0,0,0,0,400
OK

AT+ DOL =1,1800,100,0,400Set the distance limit range of 100~1800mm, detect once every 400ms, over-limit alarm.OK
Command ExampleFunctionParameter

 

AT+DOL=1,1800,3,0,400

The first bit sets the limit mode0: Do not use upper and lower limits
1: Use upper and lower limits
2: Less than the upper limit
3: Greater than the lower limit
The second bit sets the upper limit value3~2000MM
The third bit sets the lower limit value3~2000MM
The fourth bit sets the over-limit alarm or person or object count.0: Over-limit alarm, DO output is high
1: Person or object counting statistics
The fifth bit sets the sampling time100~10000ms

Downlink Command: 0x07

Format: Command Code (0x07) followed by 9 bytes.

If the downlink payload=07 01 0708 0064 00 0190, it means set the END Node's limit mode to 0x01,upper limit value to 0x0708=1800(mm), lower limit value to 0x0064=100(mm), to over-limit alarm(0x00), the sampling time to 0x0190=400(ms), while type code is 0x07.

  • Example 0: Downlink Payload: 07 00 0000 0000 00 0190      --->   AT+DOL=0,0,0,0,400             // No threshold is used, the sampling time is 400ms
  • Example 1: Downlink Payload: 07 01 0708 0064 00 0190      --->   AT+DOL=1,1800,100,0,400   //MOD1 uses distance alarm mode, when the TDC time arrives, the node sampling time is 400ms. When the node detects that the distance is lower than 100mm or higher than 1800mm, it sends an alarm packet. The alarm flag is 1. Otherwise, the node normally uplink and the alarm flag is 0.

Note: AT+DOL command is applied to MOD1. 

For example:

  • AT+MOD=1

         AT+DOL=1,500,244,0,300

Send data according to the normal TDC time. If the mode limit is exceeded, the alarm flag is set to 1:

image-20231214111618-1.png

4. Case Study

4.1 Detect the level for rabbish bin

4.1.1 Case Description

DS20L's ToF FoV angle: ±9°, total 18°, very suitable for object height acquisition. This case describes how to set up DS20L to calculate the amount of garbage in the trash can.

As shown in the figure below, DS20L detects the distance regularly. When the garbage in a trash can reaches the set capacity, it will issue a warning and regularly report the status of the trash can at that time.

Note: This mode uses scheduled collection, has very low power consumption and is powered

image-20240423203547-4.png

image-20240423203532-3.png

4.1.2 Software Configuration

  • Open the serial port assistant tool, enter the key, and set  AT+MOD=1 and AT+DOL=2,200,10,400
  • or send downlink command 0A 01 and  07 02 00 C8 00 0A 01 90

Every 20 minutes, DS20L will check rabish level of the trash can. If it exceeds the set threshold, it will alarm.

Detail explain for this command please see Working Mode .

Notice: To save battery life, user can ignore the alarm setting ( AT+DOL).

4.1.3 Test Result

image-20240423204346-7.png

4.2 Uses DS20L to Count object pass in the machine

4.2.1 Case Decription

DS20L has angle of ToF FoV: ±9°, Total 18°, which is good to use it for object counting. This case descript how to set up DS20L to count how many PCBA pass in the SMT machine.

As show below, DS20L keep checking the detect distance,  when there is a PCB pass the rail, the distance shown in DS20L will become a small value and DS20L will count PCB +1.

Notice: To continously count object, user need to use external power source to power DS20L, Use battery is not enough 

image-20240407214105-1.png

image-20240407214346-2.png

4.2.2 Software Configuration

  • Open the serial port assistant tool, enter the key, and set  AT+MOD=2,0,50,200
  • or send downlink command 0A 02 00 00 32 00 00 00 CB

This command will continouse read distance, if distance read below 5cm and last for more than 200ms. Counting + 1.

Detail explain for this command please see Working Mode .

4.2.3 Test Result

image-20240407221644-6.png

4.3 Distance Alarm

4.3.1 Case description

DS20L's ToF FoV angle: ±9°, total 18°, very suitable for object distance detection. This case describes how to set up DS20L to determine whether people enter prohibited areas.

As shown in the figure below, DS20L continuously checks the detection distance. When someone breaks into a prohibited area, the detection distance of DS20L becomes a small valu and sends an Alarm.

Notice: To continously count object, user need to use external power source to power DS20L, Use battery is not enough.

image-20240423204625-8.png

image-20240423204654-9.png

4.3.2 Software configuration

Open the serial port assistant tool, enter the key, and set AT+MOD=3,0,1800,200

Or send downlink command 0A 03 00 07 08 00 00 00 CB

This command will continue to read the distance,  if the reading distance is below 1800 cm and lasts longer than 200 ms. Then DS20L will send an Alarm.

Detail explain for this command please see Working Mode .

4.3.3 Test Result

image-20240423204928-10.png

5. Battery & Power Consumption

DS20L use built-in 2400mAh non-chargeable battery for long-term use up to several years*. See below link for detail information about the battery info and how to replace.

Battery Info & Power Consumption Analyze .

6. Firmware update

User can change firmware DS20L to:

  • Change Frequency band/ region.
  • Update with new features.
  • Fix bugs. 

Firmware and changelog can be downloaded from : Firmware download link

Methods to Update Firmware:

7. FAQ

7.1 What is the frequency plan for DS20L?

DS20L use the same frequency as other Dragino products. User can see the detail from this link:  Introduction

7.2 How to connect external power supply to DS20L?

Use the positive pole of the regulated power supply to connect the 3.3v pin of the interface;

Use the negative pole of the regulated power supply to connect the GND pin of the interface.

image-20240312104724-1.png

When using external power supply, the gear position is in E position

image-20240313091009-2.png

7.3 Why cannot Mode be modified?

If mode cannot be modified, upgrade the firmware version to v1.0.2 or later.

8. Trouble Shooting

8.1 AT Command input doesn't work

In the case if user can see the console output but can't type input to the device. Please check if you already include the ENTER while sending out the command. Some serial tool doesn't send ENTER while press the send key, user need to add ENTER in their string. 

8.2 Significant error between the output distant value of LiDAR and actual distance

Cause ①Due to the physical principles of The LiDAR probe, the above phenomenon is likely to occur if the detection object is the material with high reflectivity (such as mirror, smooth floor tile, etc.) or transparent substance. (such as glass and water, etc.)

Troubleshooting: Please avoid use of this product under such circumstance in practice.

Cause ②The IR-pass filters are blocked.

Troubleshooting: please use dry dust-free cloth to gently remove the foreign matter.

9. Order Info

Part Number: DS20L-XXX

XXX: The default frequency band

  • AS923: LoRaWAN AS923 band
  • AU915: LoRaWAN AU915 band
  • EU433: LoRaWAN EU433 band
  • EU868: LoRaWAN EU868 band
  • KR920: LoRaWAN KR920 band
  • US915: LoRaWAN US915 band
  • IN865: LoRaWAN IN865 band
  • CN470: LoRaWAN CN470 band
      

10. ​Packing Info

Package Includes:

  • DS20L LoRaWAN Smart Distance Detector x 1

Dimension and weight:

  • Device Size: cm
  • Device Weight: g
  • Package Size / pcs : cm
  • Weight / pcs : g
      

11. Support

  • Support is provided Monday to Friday, from 09:00 to 18:00 GMT+8. Due to different timezones we cannot offer live support. However, your questions will be answered as soon as possible in the before-mentioned schedule.
  • Provide as much information as possible regarding your enquiry (product models, accurately describe your problem and steps to replicate it etc) and send a mail to Support@dragino.cc.
Tags:
    
Copyright ©2010-2022 Dragino Technology Co., LTD. All rights reserved
Dragino Wiki v2.0