Milesight WS202: LoRaWAN PIR & Light Sensor
Milesight WS202 LoRaWAN PIR & light sensor: own ChirpStack/ThingsBoard decoder, decoded example and occupancy-based lighting for the smart office.
- LoRaWAN
- Class A, OTAA
- Band / port
- EU868 / port 85
- Detection
- Passive infrared (PIR), up to 8 m, 120 deg horizontal / 100 deg vertical
- Light sensing
- Built-in daylight sensor (dim / bright)
- Ingress protection
- IP30 (indoor)
- Battery
- 1x 1650 mAh ER14335 Li-SOCl2
- Configuration
- NFC (Milesight ToolBox)
What the WS202 measures
PIR motion
Passive infrared occupancy detection, reports normal or trigger.
Daylight
Built-in light sensor reports a dim or bright state for lighting logic.
Battery level
Reported as a percentage, with local storage and retransmission.
Integration
Sensor / controller
Measures or controls in the field and sends LoRaWAN uplinks.
LoRaWAN gateway
Receives the radio packets and forwards them to the server.
ChirpStack
Network server: manages sessions and decodes the payload.
ThingsBoard / Grafana
Dashboards, alarms, rules and reports.
function decodeUplink(input) {
var bytes = input.bytes;
var data = {};
for (var i = 0; i < bytes.length; ) {
var channel = bytes[i++];
var type = bytes[i++];
// Device info (join / power-on): IPSO version, SN, hw/fw version, class
if (channel === 0xff) { i += deviceInfoLen(type); continue; }
if (channel === 0x01 && type === 0x75) { // battery (%)
data.battery = bytes[i]; i += 1;
} else if (channel === 0x03 && type === 0x00) { // PIR: 0 normal, 1 trigger
data.pir = bytes[i] === 1 ? "trigger" : "normal"; i += 1;
} else if (channel === 0x04 && type === 0x00) { // daylight: 0 dim, 1 bright
data.daylight = bytes[i] === 1 ? "bright" : "dim"; i += 1;
} else {
break;
}
}
return { data: data };
}
function deviceInfoLen(type) {
// 0xFF segment lengths from the published spec (skip device-info bytes)
var map = { 0x01: 1, 0x08: 6, 0x09: 2, 0x0a: 2, 0x0b: 1, 0x0f: 1 };
return map[type] || 1;
}
Implemented from the published Milesight byte specification (Communication Protocol / User Guide).
Channel format: 01 75 battery (%), 03 00 PIR (0 normal, 1 trigger), 04 00 daylight (0 dim, 1 bright). The light reading is a binary daylight state, not a lux value. 0xFF channels carry device info (protocol, serial, hardware/firmware version, class) on join or power-on and are skipped. Implemented from the published Milesight byte specification. For ThingsBoard the same logic goes into an uplink converter.
Uplink (hex)
017564030001040001Decoded JSON
{ "battery": 100, "pir": "trigger", "daylight": "bright" }Use cases
Configuration & pitfalls
NFC setup
Keys, reporting interval and PIR/light behaviour are set over NFC with the Milesight ToolBox before rollout.
Mounting and range
PIR detects motion up to 8 m across a 120 degree horizontal field. Mount at the recommended height and aim away from heat sources and HVAC outlets to avoid false triggers.
Daylight is a state, not lux
The light channel reports dim or bright, not a calibrated lux value. Build lighting rules on the state, do not expect a numeric brightness reading.
Event-driven uplinks
Motion and daylight changes are sent as events outside the heartbeat interval, so dashboard rules should treat them as priority occupancy events.
How merkaio supports your WS202
From sourcing to day-to-day operation, all from one partner on our own European infrastructure.
Pre-staging & provisioning
We configure the WS202, set keys, intervals and alarms, and ship it ready to deploy.
Own decoder
Payload codec for ChirpStack v4 and ThingsBoard, implemented from the Milesight specification.
Dashboard integration
Data lands in your ThingsBoard or Grafana, with alarms and reports.
Operations & monitoring
We run the LoRaWAN stack and dashboards on European infrastructure, you just use the data.
Frequently asked questions
Let's discuss your infrastructure. Digital and on-site.
Whether it's IoT platform development, hardware selection, managed hosting for ChirpStack, ThingsBoard, Grafana or NetBird VPN, or migration from a self-hosted setup - we'll find the right solution for your use case. Book a free 30-minute consultation, no commitment required.
Your contact
Timo Wevelsiep
Founder, merkaio
15 minutes, no commitment, directly with Timo.
Decoder for ChirpStack v4. merkaio is an independent integrator and is not affiliated with Milesight.