AN-204 LoRaWAN Water Leak Detector User Guide

Device Information: Model AN-204, devEui ffffff1000048428, gateway IP 192.168.31.205, Modbus Slave ID 11, BACnet Device ID 111

1 Protocol Overview

The AN-204 reports water leak event, water status, water duration, battery voltage, tamper status, and signal quality on Fport 210.

Payload format (Fport 210):

Byte Field Description
0 Reserved Always 0x00 (protocol version)
1 … N TLV pairs [Type(1 B)][Value(N B)] … repeating until end

Each Type byte determines the field name and the number of following value bytes:

Type Value Bytes Field Name Encoding Scale Unit Notes
0x01 1 model uint8 Model code = 0x11
0x85 1 waterStatus uint8 0=no water 1=leak detected (status)
0x73 2 waterDuration uint16 BE min Continuous leakage duration
0x21 1 waterEvent uint8 0=no water event 1=leak event triggered
0x05 1 batteryLowEvent uint8 0=normal 1=low-voltage event
0x77 1 tamperState uint8 0=normal 1=tampered

JavaScript Decoder Example:

// AN-204 Water Leak Detector — Fport 210 uplink decoder
function decodeUplink(bytes) {
  var i = 1, r = {};
  function u16(b,o){ return (b[o]<<8)|b[o+1]; }
  while (i < bytes.length) {
    var t = bytes[i++];
    switch (t) {
      case 0x01: r.model           = bytes[i++]; break;
      case 0x05: r.batteryLowEvent = bytes[i++]; break;
      case 0x21: r.waterEvent      = bytes[i++]; break; // 0=no event  1=leak
      case 0x73: r.waterDuration   = u16(bytes,i); i+=2; break; // minutes
      case 0x77: r.tamperState     = bytes[i++]; break;
      case 0x85: r.waterStatus     = bytes[i++]; break; // 0=dry  1=wet
      default:   i++; break;
    }
  }
  return r;
}
// Example payload (hex): 00 01 11 85 01 73 00 0A 21 01 05 00 77 00
// → { model:17, waterStatus:1, waterDuration:10, waterEvent:1, batteryLowEvent:0, tamperState:0 }

Script download: LPP.zip

Compatibility note: LPP.js is developed and tested against ChirpStack v4.17.0. The ChirpStack JavaScript codec API may differ across versions — if you are running a different ChirpStack version, review and adjust the script as needed before deployment.
⚠️ The IP addresses (192.168.31.205 / 192.168.31.193), ChirpStack API token, Slave ID, BACnet Device ID, and devEui in the examples below are for demonstration only. Replace them with your actual gateway IP, ChirpStack API token, and device parameters.

2.1 ChirpStack MQTT Subscription

Subscribe to the MQTT topic to receive real-time uplink frames:

Application ID3ef9e6b9-ec54-4eda-86b8-a5fb46899f39 is the factory-default ChirpStack
application built into the gateway. Replace it with your actual application
ID if you have created a different one.

Gateway IP192.168.31.205 is the gateway WAN port IP shown as an
example. Replace it with your actual gateway IP address.

Device EUIffffff1000048428 is the EUI of the example device.
Replace it with the EUI shown in the gateway device list, or use +
as a wildcard to subscribe to all devices at once.
# Subscribe to one specific device
mosquitto_sub -h 192.168.31.205 -p 1883 \
  -u gateway -P mqtt88888888 \
  -t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000048428/event/up"

# Subscribe to ALL devices on ALL applications (wildcard)
mosquitto_sub -h 192.168.31.205 -p 1883 \
  -u gateway -P mqtt88888888 \
  -t "application/+/device/+/event/up"

Example uplink payload (JSON):

{
  "devEui": "ffffff1000048428",
  "fPort": 210,
  "object": {
    ...  (decoded LPP fields)
  }
}

2.2 IoT Hub HTTP API

Send a GET request to retrieve the latest device state:

curl -s "http://192.168.31.205:8070/api/getStatus?devEui=ffffff1000048428"
{
  "success": true,
  "result": {
    "batteryVoltage": 2.66,
    "waterStatus": false,
    "waterDuration": 0,
    "batteryLowEvent": false,
    "waterEvent": false,
    "model": "AN-204"
  }
}

2.3 IoT Hub Modbus TCP — Python Script

Script download: modbus_tcp_read.py

Use modbus_tcp_read.py to poll all registers at once:

python3 modbus_tcp_read.py --ip 192.168.31.205 --port 502 \
    --slaveId 11 --sensorType AN-204
Target: 192.168.31.205:502 | Slave ID: 11 | Sensor: AN-204
================================================================================================================================================================
Attribute                | Addr   | FC  | Format     | Order        | Cnt | Scale    | Raw(Hex)            | Value              | Unit
----------------------------------------------------------------------------------------------------------------------------------------------------------------
online                   | 6      | 03  | Bit/Bool   | Big(ABCD)    | 1   | x1       | 0001                | true               | none
lastOnlineTime           | 7      | 03  | UnixTime   | Big(ABCD)    | 2   | x1       | 69CC CD02           | 1775029506         | second
batteryVoltage           | 9      | 03  | Int16(S)   | Big(ABCD)    | 1   | /100     | 010A                | 2.66               | volt
waterStatus              | 10     | 03  | Bit/Bool   | Big(ABCD)    | 1   | x1       | 0000                | false              | none
waterDuration            | 11     | 03  | Int16      | Big(ABCD)    | 1   | x1       | 0000                | 0.0                | minute
batteryLowEvent          | 12     | 03  | Bit/Bool   | Big(ABCD)    | 1   | x1       | 0000                | false              | none
waterEvent               | 13     | 03  | Bit/Bool   | Big(ABCD)    | 1   | x1       | 0000                | false              | none
model                    | 38     | 03  | String(24B) | ASCII        | 12  | x1       | 414E 2D32 3034 0000 ... | AN-204             | none
rssi                     | 50     | 03  | Int16      | Big(ABCD)    | 1   | x1       | FFBB                | -69.0              | none
snr                      | 51     | 03  | Int16      | Big(ABCD)    | 1   | x1       | 000D                | 13.0               | none

2.4 IoT Hub Modbus TCP — Modbus Poll

Tool download: Modbus Poll 9.5.0.1507.zip

  1. Open Modbus Poll, connect to 192.168.31.205:502, Slave ID 11
  2. Menu Setup → Read/Write Definition, set Function Code = FC03, Start Address = 6, Length = 46
  3. Click OK — values update in real-time

2.5 IoT Hub BACnet BIP — Python Script

Script download: bacnet_read.py

Use bacnet_read.py to read all BACnet objects:

python3 bacnet_read.py --ip 192.168.31.205 --port 47808 --id 111
Target: 192.168.31.205:47808 | BACnet ID: 111 | Scan: 11100-11199
------------------------------------------------------------
Type | Instance | Offset | Value                    | Object Name
------------------------------------------------------------
BI   | 11102    | 2      | active                   | ffffff1000048428.online
AI   | 11103    | 3      | 1775029504.00            | ffffff1000048428.lastOnlineTime
AI   | 11104    | 4      | 2.66                     | ffffff1000048428.batteryVoltage
BI   | 11105    | 5      | inactive                 | ffffff1000048428.waterStatus
AI   | 11106    | 6      | 0.00                     | ffffff1000048428.waterDuration
BI   | 11107    | 7      | inactive                 | ffffff1000048428.batteryLowEvent
BI   | 11108    | 8      | inactive                 | ffffff1000048428.waterEvent
CV   | 11109    | 9      |                          | ffffff1000048428.mainVersion
CV   | 11110    | 10     |                          | ffffff1000048428.appVersion
CV   | 11111    | 11     |                          | ffffff1000048428.hardwareVersion
CV   | 11112    | 12     | AN-204                   | ffffff1000048428.model
AI   | 11113    | 13     | -69.00                   | ffffff1000048428.rssi
... (13 objects total)

2.6 IoT Hub BACnet BIP — YABE

Tool download: SetupYabe_v2.1.0.exe

  1. Open YABE, connect to 192.168.31.205:47808
  2. Expand Device 111 in the device tree
  3. Browse AI/BI/AV/BV/CV objects to view real-time values