Open the text reading version
The most common mistake engineers make when moving from Wi-Fi or cellular IoT to LoRaWAN is sending raw JSON over the radio: {"temp":24.6,"hum":58.2,"bat":3.62}. It looks convenient on a test bench and saves ten minutes of decoder work—at the cost of cutting battery life, dropping frames at cell edges, and failing outright at the lowest regional data rates.
In LoRa SF, BW and CR we examined how spreading factors govern airtime, and in ThinkLink Payload Decoders we walked through platform-side parsing. This guide starts upstream: how to design a compact, versioned, maintainable binary payload format at the device or collector.
1. The Hard Ceiling: Maximum Payload Size by Region and Data Rate
LoRaWAN enforces strict per-data-rate maximum application payload sizes (typical values without piggybacked FOpts MAC commands):
| Region | Lowest Data Rate (Max Range) | Max App Payload | Higher Data Rate Example | Max App Payload |
|---|---|---|---|---|
| CN470 | DR0 (SF12 / 125 kHz) | 51 bytes | DR5 (SF7 / 125 kHz) | 222 bytes |
| EU868 | DR0 (SF12 / 125 kHz) | 51 bytes | DR5 (SF7 / 125 kHz) | 222 bytes |
| US915 | DR0 (SF10 / 125 kHz) | 11 bytes | DR3 (SF7 / 125 kHz) | 242 bytes |
| AS923 | DR0 (SF12 / 125 kHz) | 51 bytes | DR5 (SF7 / 125 kHz) | 222 bytes |
Notice that US915 DR0 allows only 11 bytes, and CN470/EU868 DR0 allow 51 bytes. When MAC commands occupy up to 15 bytes inside FOpts, available application space shrinks further. Any multi-region product whose uplink exceeds 11 bytes without fragmentation or DR floors will fail silently on weak North American links.
2. Same Telemetry, Very Different Cost: JSON vs. Binary
Consider a sensor reporting temperature (24.65 °C), relative humidity (58.2 %RH), battery voltage (3.62 V), and one leak-alarm bit:
- JSON string:
{"t":24.65,"h":58.2,"v":3.62,"a":0}— 35 bytes (slightly longer key names easily cross 51 bytes). - Compact binary: 1-byte version + 2-byte signed temperature (×100) + 2-byte unsigned humidity (×10) + 2-byte battery millivolts + 1-byte status bitmask = 8 bytes.
At SF12 / 125 kHz / CR 4/5, an 8-byte payload takes roughly 1.3 seconds of Time on Air, whereas a 35-byte payload stretches past 2.1 seconds. That 60% airtime penalty drains batteries faster, increases collision probability across shared channels, and extends EU868 1% duty-cycle cooldown windows.
The golden rule is simple: JSON belongs on northbound APIs, not on LoRaWAN RF links. Let the platform decoder—such as a ThinkLink thing-model script—reconstruct human-readable field names once the packet arrives safely on the server.
3. Six Engineering Rules for Binary LoRaWAN Payloads
1. Prefer Scaled Fixed-Point Integers Over IEEE-754 Floats
Most industrial and environmental readings do not need 32-bit floating-point dynamic range. Storing temperature ×100 as an int16 covers −327.68 °C to +327.67 °C at 0.01 °C resolution in 2 bytes instead of 4. Store humidity ×10 in a uint16 (or ×2 in a uint8) and battery voltage in millivolts as a uint16. Reserve 32-bit integers or floats for cumulative flow totals or high-precision coordinates.
2. Pack Booleans and Alarm Flags into a Bitmask
Eight dry-contact channels, door states, leak flags, low-battery indicators, and sensor fault flags fit inside a single uint8. Grouping flags into one byte saves airtime and simplifies bitwise alarm rules upstream.
3. Route Message Types with FPort
Every LoRaWAN application frame carries a 1-byte FPort (1–223 for applications; 0 reserved for MAC commands; 224 for certification testing). Assign distinct ports—for example, FPort 10 for periodic telemetry, FPort 11 for immediate alarms, FPort 20 for heartbeat/config, and FPort 30 for downlink commands—instead of spending extra payload bytes on message-type headers.
4. Choose Fixed Structs vs. TLV Deliberately
| Framing Style | Header Overhead | Strength | Best Fit |
|---|---|---|---|
| Version + Fixed Struct | 1 byte | Smallest size, predictable length, trivial parsing | Dedicated sensors with fixed channels (temp/humidity, leak, 4-ch analog) |
| TLV / Channel-Type-Value (e.g., CayenneLPP style) | ~2 bytes per item | Flexible channel subsets across hardware variants | Configurable field collectors and multi-meter retrofits |
In legacy-meter retrofits, running EdgeBus directly on collectors such as KC21 or KC25 lets the edge device parse RS-485 registers locally and transmit only the needed scaled metrics in a compact binary frame, rather than forwarding raw multi-register serial dumps over the air.
5. Standardize Endianness and Signed Representation
Pick one endianness across the product family (network byte order / Big-Endian is widely adopted, or consistent Little-Endian) and document two's-complement rules explicitly. Publish at least three golden hex test vectors covering negative readings, zero, full scale, and sensor-fault sentinels.
6. Plan for Schema Evolution and Explicit Fault Sentinels
Reserve a version nibble or separate FPort for schema changes so legacy devices and upgraded firmware can coexist on the same decoder without breaking live dashboards. Equally critical: define an unmistakable sentinel value (such as 0x7FFF plus a fault flag bit) for open probes or RS-485 timeouts—never encode a broken probe as 0, which is indistinguishable from 0 °C.
4. Reference 10-Byte Telemetry Frame
FPort = 10 (Periodic Telemetry)
Byte 0 : 0x01 // Protocol version v1
Byte 1..2 : 0x09 0xA1 // Temperature int16 BE, 2465 => +24.65 °C (0x7FFF = probe fault)
Byte 3..4 : 0x02 0x46 // Humidity uint16 BE, 582 => 58.2 %RH
Byte 5..6 : 0x0E 0x24 // Battery uint16 BE, 3620 => 3.620 V
Byte 7 : 0x01 // Bitmask: bit0=leak, bit1=low_bat, bit2=probe_fault
Byte 8..9 : 0x00 0x1A // Event counter uint16 BE, 26
Raw hex: 0109A102460E2401001A (10 bytes total — fits even inside US915 DR0)
This 10-byte frame clears the strictest regional MTU, avoids floating-point math on MCUs, and decodes cleanly into ThinkLink thing-model properties in twenty lines of JavaScript.
5. Pre-Release Payload Review Checklist
- Does the maximum frame length stay under the lowest target regional MTU (leaving room for
FOpts)? - Have all floats, ASCII strings, and standalone boolean bytes been converted to fixed-point integers or bitmasks?
- Are telemetry, alarms, configuration, and downlinks cleanly separated by
FPort? - Are probe faults and serial bus timeouts encoded with explicit sentinels instead of zero?
- Are endianness, signedness, scaling factors, and engineering units identical in firmware docs and platform decoders?
- Are negative, boundary, and fault hex vectors committed as decoder regression tests?
Conclusion
Every unnecessary byte in a LoRaWAN payload taxes battery life, gateway airtime capacity, and edge-of-cell reliability simultaneously. Keeping readability in the platform decoder and compactness on the air interface is one of the highest-leverage engineering habits in LPWAN design.
Prepared from LoRaWAN Regional Parameters specifications and IoT engineering practices. Refer to official ThinkLink and ManThink documentation for platform decoder and EdgeBus details.
Buildings, HVAC & campuses · Global partners · Send an enquiry ↗
Explore more technical notes and field practices.
Back to articles ↗