Link Search Menu Expand Document

Dragino - LDS02

The LDS02 is a LoRaWAN Window/Door sensor.


Table of contents

  1. Specifications
  2. Documents
  3. Ordering Info
  4. Adding the Device to TTN
  5. Optional Settings
    1. Change TDC (Transmit Time Interval resp. Keep Alive Interval)
  6. Payload formatter

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


Ordering Info

  • Part Number: LDS02-XX
    • XX is frequency band, for ttn in Europe choose EU868
  • Ordering Link

Adding the Device to TTN

  • Before a device can communicate via “The Things Network” we have to add it to an application.
  1. Create a new application
  2. Under Overview click (+) Register device
  3. Under Input method select Select the end device in the LoRaWAN Device Repository
  4. Enter the following device information
    • End device brand select Dragino Technology Co., Limited
    • Model select LDS02
    • Hardware Ver. select Unknown Ver. or whatever is possible or on the sticker
    • Firmware select 1.5 or whatever is possible or on the sticker
      • Profile (Region) select EU_863_870
  5. Under Frequency plan select Europe 863-870 Mhz (SF9 for RX2 - recommended)
  6. Under JoinEUI enter the App EUI from the sticker
  7. Enter as well the DevEUI and the AppKey from the sticker
  8. Set an end-device name
  9. Press Register end device
  10. Open the case and take out the batteries
  11. Replace the batteries and close the case
  • Now the device should join the network and you can see the incoming telegrams in the Live data section
  • The payload formatter should already be preset. If not, you can copy/paste it from below

Optional Settings

Change TDC (Transmit Time Interval resp. Keep Alive Interval)

In some cases, the sensor has sent incorrect values. This can be remedied by reducing the TDC.

By default, the sensor sends a status message every day. This interval can be reduced to 1 hour (3600s -> HEX E10) as follows:

  1. In the TTN Console on the device view, select the device and change to the tab Messaging, select Downlink
  2. Change the FPort to 1
  3. Copy/paste the payload from the examples below, e.g. 01 00 0E 10 into the Payload field
  4. Press Send
  5. 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.

Payload formatter

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: 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 = doorStatus;
                    data.counter = times;
                    data.openDuration_min = duration;
                    data.alarm_state = alarm;
                    break;
                case 2: 
                    data.waterLeak_state = waterLeakStatus;
                    data.counter = times;
                    data.waterDuration_minutes = duration;
                    break;
                case 3: 
                    data.waterLeak_state = doorStatus || waterLeakStatus;
                    data.alarm_state = alarm;
                    break;
                default:
                    break;
            }
            break;
        default:
            return { errors: ["unknown FPort"] };
    }

    return { data: data };
}