What Byte Order Is
Byte order (endianness) defines the arrangement of bytes within a multi-byte value. In Modbus and other industrial protocols, the source and destination devices must agree on byte order for values larger than 8 bits.
Big-Endian vs Little-Endian
| Order | Byte Layout (16-bit) | Also Called |
|---|---|---|
| Big-endian | Most significant byte first | Network byte order |
| Little-endian | Least significant byte first | Intel byte order |
For a 16-bit value 0x0102:
- Big-endian:
01 02 - Little-endian:
02 01
Byte Order vs Word Order
For 32-bit and 64-bit values spanning multiple registers, there are two independent ordering layers:
- Byte order — arrangement of bytes within each 16-bit word
- Word order — arrangement of 16-bit words within the multi-word value
This creates four possible combinations, all of which appear in real devices.
[!WARNING] Most field issues labeled as “bad scaling” or “wrong data” are actually endianness mismatches. Always validate with a known-good engineering value.
How to Determine Byte Order
- Read the raw bytes from the device
- Decode the value in both byte orders
- Compare to a physically verifiable measurement
- The order producing the correct value is the device’s byte order
Common Problems
- Values are wildly wrong or appear scrambled — Byte or word order mismatch between the source device and the gateway. This is almost never a scaling error. See Modbus Data Types & Byte Order Reference to identify the correct combination.
- 32-bit float reads as garbage — The gateway is configured with the wrong word order for the FLOAT32 value. The device may use big-endian words with little-endian bytes (or any other combination). See Modbus Data Types & Byte Order Reference.
- Value only correct when reading as two separate 16-bit registers — The multi-register data type is enabled but word order is inverted. See Word Order - Knowledge Base.