AN-305 LoRaWAN Door/Window Contact Sensor User Guide
Device Information: Model AN-305, devEui ffffff100004bcf0, gateway IP 192.168.31.193, Modbus Slave ID 2, BACnet Device ID 101
1 Protocol Overview
The AN-305 reports door/window open-close state, open-close event, battery voltage, tamper status, and signal quality on Fport 210.
1.1 Uplink Data Protocol (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 = 0x24 or 0x25 |
0x76 |
1 | doorState |
uint8 | — | — | 0=closed 1=open (state, primary) |
0x18 |
1 | doorState |
uint8 | — | — | 0=closed 1=open (state, alternate) |
0x24 |
1 | doorEvent |
uint8 | — | — | 0=close event 1=open event triggered |
0x77 |
1 | tamperState |
uint8 | — | — | 0=normal 1=tampered |
0x04 |
2 | batteryVoltage |
uint16 BE | ÷1000 | V | mV raw ÷1000 = V |
0x05 |
1 | batteryLowEvent |
uint8 | — | — | 0=normal 1=low-voltage event |
0x03 |
1 | tamperEvent |
uint8 | — | — | 0=normal 1=tamper event |
JavaScript Decoder Example:
// AN-305 Door/Window Contact Sensor — 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 0x03: r.tamperEvent = bytes[i++]; break;
case 0x04: r.batteryVoltage = u16(bytes,i)/1000; i+=2; break;
case 0x05: r.batteryLowEvent = bytes[i++]; break;
case 0x18: r.doorState = bytes[i++]; break; // 0=closed 1=open
case 0x24: r.doorEvent = bytes[i++]; break; // 0=close event 1=open event
case 0x76: r.doorState = bytes[i++]; break; // same meaning, primary field
case 0x77: r.tamperState = bytes[i++]; break;
default: i++; break;
}
}
return r;
}
// Example payload (hex): 00 01 24 76 01 24 01 77 00 04 0D AC 05 00
// → { model:36, doorState:1, doorEvent:1, tamperState:0, batteryVoltage:3.50, batteryLowEvent: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.
2 Getting Uplink Data
⚠️ 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 ID —3ef9e6b9-ec54-4eda-86b8-a5fb46899f39is the factory-default ChirpStack
application built into the gateway. Replace it with your actual application
ID if you have created a different one.
Gateway IP —192.168.31.193is the gateway WAN port IP shown as an
example. Replace it with your actual gateway IP address.
Device EUI —ffffff100004bcf0is 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.193 -p 1883 \
-u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff100004bcf0/event/up"
# Subscribe to ALL devices on ALL applications (wildcard)
mosquitto_sub -h 192.168.31.193 -p 1883 \
-u gateway -P mqtt88888888 \
-t "application/+/device/+/event/up"
Example uplink payload (JSON):
{
"devEui": "ffffff100004bcf0",
"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.193:8070/api/getStatus?devEui=ffffff100004bcf0"
{
"success": true,
"result": {
"doorState": 1,
"batteryVoltage": 3,
"batteryVoltageState": 0,
"tamperStatus": true,
"model": "AN-305"
}
}
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.193 --port 502 \
--slaveId 2 --sensorType AN-305
Target: 192.168.31.193:502 | Slave ID: 2 | Sensor: AN-305
================================================================================================================================================================
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 C6F5 | 1775027957 | second
doorState | 9 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0001 | 1.0 | none
batteryVoltage | 10 | 03 | Int16(S) | Big(ABCD) | 1 | /100 | 012C | 3.00 | volt
batteryVoltageState | 11 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0000 | 0.0 | none
tamperStatus | 12 | 03 | Bit/Bool | Big(ABCD) | 1 | x1 | 0001 | true | none
batteryLevel | 13 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0000 | 0.0 | percent
tamperEvent | 14 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0000 | 0.0 | none
doorEvent | 15 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0000 | 0.0 | none
model | 40 | 03 | String(24B) | ASCII | 12 | x1 | 414E 2D33 3035 0000 ... | AN-305 | none
rssi | 52 | 03 | Int16 | Big(ABCD) | 1 | x1 | FFB2 | -78.0 | none
snr | 53 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0009 | 9.0 | none
2.4 IoT Hub Modbus TCP — Modbus Poll
Tool download: Modbus Poll 9.5.0.1507.zip
- Open Modbus Poll, connect to
192.168.31.193:502, Slave ID2 - Menu Setup → Read/Write Definition, set Function Code = FC03, Start Address =
6, Length =48 - 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.193 --port 47808 --id 101
Target: 192.168.31.193:47808 | BACnet ID: 101 | Scan: 10100-10199
------------------------------------------------------------
Type | Instance | Offset | Value | Object Name
------------------------------------------------------------
BI | 10102 | 2 | active | ffffff100004bcf0.online
AI | 10103 | 3 | 1775027968.00 | ffffff100004bcf0.lastOnlineTime
BI | 10104 | 4 | active | ffffff100004bcf0.doorState
AI | 10105 | 5 | 3.00 | ffffff100004bcf0.batteryVoltage
AI | 10106 | 6 | 0.00 | ffffff100004bcf0.batteryVoltageState
BI | 10107 | 7 | active | ffffff100004bcf0.tamperStatus
AI | 10108 | 8 | 0.00 | ffffff100004bcf0.batteryLevel
AI | 10109 | 9 | 0.00 | ffffff100004bcf0.tamperEvent
AI | 10110 | 10 | 0.00 | ffffff100004bcf0.doorEvent
CV | 10114 | 14 | AN-305 | ffffff100004bcf0.model
AI | 10115 | 15 | -78.00 | ffffff100004bcf0.rssi
AI | 10116 | 16 | 9.00 | ffffff100004bcf0.snr
2.6 IoT Hub BACnet BIP — YABE
Tool download: SetupYabe_v2.1.0.exe
- Open YABE, connect to
192.168.31.193:47808 - Expand Device 101 in the device tree
- Browse AI/BI/AV/BV/CV objects to view real-time values