Dragino - LDS02
The LDS02 is a LoRaWAN Window/Door sensor.
Table of contents
- Specifications
- Documents
- Ordering Info
- Adding the Device to TTN
- Important Comissioning Steps
- Optional Settings
- Payload Decoder
Specifications
- indoor device
- Price ca. CHF 22.- (03.08.2023)
- Built-in sensors
- Magnetic reed switch, [open/close]
- Power Supply: 2 common AAA batteries, 1.5 V
- Expected life time: depending on usage, 16’000 ~ 70’000 state changes
- LoRaWAN version: 1.0.3
- LoRaWAN device class: A
- Size: 69.2 × 29.2 × 15 mm
- Weight: 55 g
Documents
- Payload description ttn v1.5 (2023-08-03)
- Datasheet from dragino.com (2023-08-03)
- User Manual (online)
Ordering Info
- Part Number: LDS02-XX
- XX is frequency band, for ttn in Europe choose EU868
- Ordering Link
Adding the Device to TTN
- The
JoinEUI
,App EUI
and theDevEUI
should be on a sticker on the cardboard box. - Before a device can communicate via “The Things Network” we have to add it to an application.
- Create a new application
- Under
End devices
in the application click(+) Register end device
- Under
Input method
selectEnter end device specifics manually
- Under
Frequency plan
selectEurope 863-870 Mhz (SF9 for RX2 - recommended)
- Under
LoRaWAN version
select1.0.3
- Under
JoinEUI
enter theApp EUI
from the App and pressConfirm
- Enter as well the
DevEUI
and theAppKey
from the App - Set an end-device name
- Press
Register end device
- Add the payload formatter from below, either to the device itself or if all devices in the app are from the same type, to the application
- Open the case and take out the batteries
- Replace the batteries and close the case
- After Configuration, the device restarts automatically and tries to join the network
- Now the device should join the network and you can see the incoming telegrams in the
Live data
section
Important Comissioning Steps
Here are important settings you have to make at comissioning.
Once at first commissioning:
- Set LoRaWAN Uplink Mode to confirmed, see Set LoRaWAN Uplink Mode
- Enable Adaptive Data Rate, see Set ADR and Data Rate
Every time the device gets assigned to a new project:
- Clear Counter, see Clear Counting
Optional Settings
To change settings of the device, you have to send downlink-messages:
- In the TTN Console on the device view, select the device and change to the tab
Messaging
, selectDownlink
- Change the
FPort to 1
- Copy/paste the payload from the examples below, e.g.
01 00 0E 10
into thePayload
field - Press
Send
- In the
Data
tab you should now see the scheduled telegram. The wisely sensor only receives downlink data after a transmission. Therefore wait max 1 day or manually open/close the window to trigger a new transmission.
Change Transmit Time Interval / Keep Alive Interval (type code 0x01)
By default, the sensor sends a status message every day. This interval can be reduced to e.g. 1 hour (3600s -> HEX E10).
01 00 0E 10
= 3600 seconds. 01 01 51 80
= 3600 seconds.
Reset LDS02 (type code 0x04)
If the payload is 04FF
, it will reset the LDS02.
Set LoRaWAN Uplink Mode (type code 0x05)
05 00
: Set uplink to LoRaWAN unconfirmed mode05 01
: Set uplink to LoRaWAN confirmed mode
Clear Counting (type code 0xA6)
Example: A6 01
– Clears both the count number and time for the LDS02.
Enable/Disable Alarm (type code 0xA7)
A7 01
: EnableA7 00
: Disable
Set ADR and Data Rate (type code 0xA8)
Format: A8 aa bb
- aa:
1
– Enable ADR (Adaptive Data Rate);0
– Disable ADR - bb: Set a fixed DR (only valid after
ADR=0
)
Examples:
A8 00 02
– Deactivate ADR and set it DR1 (SF10)A8 01 00
– Enable ADR
Payload Decoder
function mapBatteryVoltageAbs(voltage) {
if (voltage < 2.45) {
return 0; // Critical, needs replacement
} else if (voltage < 2.60) {
return 1; // Warning, running low
} else if (voltage < 2.90) {
return 2; // Good
} else {
return 3; // Very Good
}
}
function decodeUplink(input) {
const bytes = input.bytes;
const batteryVoltage = ((bytes[0] << 8 | bytes[1]) & 0x3FFF) / 1000;
const doorStatus = (bytes[0] & 0x80) ? 1 : 0; // 1: open, 0: close
const waterLeakStatus = (bytes[0] & 0x40) ? 1 : 0;
const mode = bytes[2];
const alarm = bytes[9] & 0x01;
let data = {
battery_volt_abs: batteryVoltage,
battery_state_abs: mapBatteryVoltageAbs(batteryVoltage)
};
switch (input.fPort) {
case 10:
const times = bytes[3] << 16 | bytes[4] << 8 | bytes[5];
const duration = bytes[6] << 16 | bytes[7] << 8 | bytes[8]; // units: min
switch (mode) {
case 1:
data.open_state_abs = doorStatus;
data.counter_impulse_inc = times;
data.openDuration_min_abs = duration;
data.alarm_state_abs = alarm;
break;
case 2:
data.waterleak_state_abs = waterLeakStatus;
data.counter_impulse_inc = times;
data.waterleakDuration_min = duration;
data.alarm_state_abs = alarm;
break;
case 3:
data.waterleak_state_abs = doorStatus || waterLeakStatus;
data.alarm_state_abs = alarm;
break;
default:
break;
}
break;
default:
return { errors: ["unknown FPort"] };
}
return { data: data };
}