The Modbus protocol specifies the use of big-endian byte order at the byte level. However, for data types larger than 16 bits (i.e., 2 bytes) such as 32-bit floating-point numbers and 32-bit integers, the protocol does not define the order of words, leading to different implementations by various device manufacturers.
Here is a detailed explanation:
1. Basic Rule: 16-bit Data (Single Register) – Big-Endian Byte Order
The fundamental storage unit in Modbus is a 16-bit register. For 16-bit data stored in a single register (e.g., INT16, UINT16), the Modbus protocol explicitly states that big-endian byte order is used.
This means:
The most significant byte (MSB) is sent first (in the earlier transmitted message or at a lower storage address).
The least significant byte (LSB) is sent last.
Example: Storing a decimal number 0x1234 (hexadecimal) in a holding register.
The complete binary/hexadecimal representation of this value is: 0x12 (high 8 bits) and 0x34 (low 8 bits).
In the Modbus message or memory, the storage and transmission order is:
[0x12] [0x34]
First sending/storing 0x12 (MSB), then sending/storing 0x34 (LSB).
This is clear and uniform; all Modbus devices that comply with the standard adhere to this rule.
2. Complex Cases: 32-bit and Longer Data (Multiple Registers) – Byte Order and Word Order
When representing 32-bit data (such as FLOAT32, INT32, UINT32), it occupies two consecutive 16-bit registers. The problem arises: how should these four bytes be arranged?
This involves two levels of order:
Byte Order: Within each register, are the bytes in big-endian or little-endian? (Answer: big-endian, confirmed)
Word Order: Among these two registers, which comes first (high word first or low word first)?
Since the Modbus protocol does not specify word order, several common arrangements arise, often referred to as “Modbus data formats” or “byte-swapping” modes.
The four most common formats (using 32-bit data 0x44332211 as an example):
Assuming this data needs to be stored in registers at addresses n and n+1.
ABCD (Big-Endian / High Word First)
Description: The highest byte is sent first. This is the most intuitive, directly extending the 16-bit big-endian rule.
Register n: 0x44 0x33
Register n+1: 0x22 0x11
Modbus message flow: [44] [33] [22] [11]
BADC (Byte-Swapped)
Description: Within each 16-bit register, the byte order is swapped (becoming little-endian), but the order of the registers is maintained (high word first).
Register n: 0x33 0x44 (0x4433 after byte-swapping)
Register n+1: 0x11 0x22 (0x2211 after byte-swapping)
Modbus message flow: [33] [44] [11] [22]
CDAB (Word-Swapped)
Description: The order of registers is swapped (low word first), but each register maintains big-endian byte order.
Register n: 0x22 0x11 (low word)
Register n+1: 0x44 0x33 (high word)
Modbus message flow: [22] [11] [44] [33]
DCBA (Little-Endian / Low Word First)
Description: Complete little-endian order. The lowest byte is sent first. First, the order of words is swapped (low word first), then the byte order within each word is swapped.
Register n: 0x11 0x22 (0x2211 after byte-swapping low word)
Register n+1: 0x33 0x44 (0x4433 after byte-swapping high word)
Modbus message flow: [11] [22] [33] [44]
Summary and Practical Advice

How to Determine the Format of the Device?
Check the device manual! This is the most accurate and primary method. The manual usually clearly states the data format, such as “32-bit data, Modbus format: ABCD” or “Float: CDAB”.
Conduct Testing: If the manual is unavailable, connect to the device, read a known exact value of 32-bit data (e.g., a fixed temperature value or yield value), and then try parsing it using the four formats mentioned above to see which format yields the correct value.
Rule of Thumb:
ABCD (pure big-endian) is very common, especially in devices that strictly adhere to standards.
BADC and CDAB are also very common, particularly in many PLCs and industrial instruments.
DCBA (pure little-endian) is relatively rare.
For 64-bit data (occupying 4 registers), the situation becomes more complex, but the principle remains the same, with more combinations. The solution is the same as for 32-bit data: refer to the device manual.
In summary, the Modbus protocol is big-endian at the byte level, but for multi-register data, you must confirm the correct word order and byte order combination based on the device manual.