How to decode a Sigfox payload without writing code
Every Sigfox uplink arrives as a short hex string such as 0a1b64c8000f. That string is the whole message: up to 12 bytes, chosen by whoever wrote the device firmware. The Sigfox backend stores it, but it doesn’t know what the bytes mean. Turning them into readings is up to you.
Start from the payload layout
Every device has a payload layout, even if it only lives in a datasheet or in the firmware engineer’s head. A typical layout for a temperature sensor might look like this:
| Bytes | Field | Type | Scale |
|---|---|---|---|
| 0–1 | Temperature | signed 16-bit, big-endian | ÷ 10 → °C |
| 2 | Battery | unsigned 8-bit | % |
| 3 | Flags | bit field | bit 0 = door open, bit 1 = tamper |
With that table, 00e7 5a 01 reads as 23.1 °C, 90 % battery, door open. Most decoding bugs come from three details:
- Byte order. Big-endian and little-endian give completely different numbers for the same bytes. Check the datasheet; don’t guess.
- Signedness. A temperature of
ff38is −20.0 °C as a signed value and 6,532.0 °C as an unsigned one. - Scale and offset. Firmware often sends integers and expects you to divide by 10 or 100, or to subtract a fixed offset.
Different message types in one payload
Many devices send more than one kind of message: a regular measurement, a daily status and an alarm. The first byte, or a few bits of it, often says which kind it is. A decoder has to check that byte first and then read the rest of the message the right way. If it doesn’t, a status message gets read as a measurement and you get impossible numbers.
Why hand-written decoder scripts become a problem
The usual first step is a small script in a callback handler or a serverless function. It works until:
- the firmware changes and the script has to know which devices run which version,
- someone fixes a scaling bug and the historical readings are still wrong,
- a second device type arrives and the script sprouts
ifstatements.
Write the decoder down as a description of the layout rather than as code, and it’s easier to review, test and version. When a new firmware version changes the layout, you publish a new decoder version instead of editing the old one, and the old readings stay exactly as they were until you choose to re-decode them.
Test against real messages
Before you trust a decoder, run it against a handful of real payloads from the field, including the edge cases: a negative temperature, an empty battery, every message type. If the device has a vendor-supplied example, check that your decoder gives the same result.
In Foxwatch, decoders are declarative and versioned, with a test harness so you can paste real payloads and see the decoded readings before a decoder goes live. A device profile ties a decoder to a whole class of devices, so a new device of a known type decodes correctly from its first message.
Foxwatch keeps your Sigfox devices and their history, decodes their payloads and tells you when something needs attention. Try it on your own Sigfox account.