Power meter display on a panel, next to a laptop showing Modbus register values
TECHNICAL NOTE

Modbus Values Look Wrong? 32-⁠Bit Numbers, Floats and Byte Order

The power meter display shows 1234.5, yet the value read over Modbus is astronomically large. The data is fine; the two registers are just being combined in a different order from the one the device uses.

Published
REGISTER & DATA TYPE

From registers to 32-⁠bit values

Modbus returns registers, and hex makes their bytes easy to see. Using 1234.5 as the example, we go from one register to a 32-bit value, then look at the data types common in register maps.

One register = 16 bits = 2 bytes

8 bits make a byte. A register is 16 bits, or 2 bytes, written as 4 hex digits with 2 digits per byte: 449A is the high byte 44 followed by the low byte 9A.

32 bits take two consecutive registers

Floating-point numbers, and values that keep growing such as accumulated energy, don’t fit in 16 bits. They use 32 bits: two consecutive registers, or 4 bytes.

Common data types

The register map gives a data type for every point. It tells you how many registers to read and how to interpret the number.

TypeFull nameRegistersRange
UInt16Unsigned 16-bit Integer10 to 65,535
Int16Signed 16-bit Integer1−32,768 to 32,767
UInt32Unsigned 32-bit Integer20 to 4,294,967,295
Int32Signed 32-bit Integer2−2,147,483,648 to 2,147,483,647
Float3232-bit Floating Point (IEEE 754)2About ±3.4×10³⁸, with decimals, about 7 significant digits
BYTE ORDER

Byte order: Big and Little

The Modbus specification only fixes the order inside a register: high byte first. Which of the two registers holds the high-order word is up to each vendor. With the 4 bytes labeled A, B, C and D from high to low, the two common layouts are Big-⁠endian (ABCD) and Little-⁠endian (CDAB).

The two registers a device sends for 1234.5 (44 9A 50 00):

AddressValue
0x0000
44
A
9A
B
High word
0x0001
50
C
00
D
Low word

Big-endian (ABCD): high word first

Two other layouts exist: BADC (bytes swapped inside each register) and DCBA (fully reversed). Some software uses the name Little-⁠endian for DCBA instead, so go by the byte layout when you configure. On CGate, Little means CDAB.

CONVERTER

Paste what you read and find the byte order and type

Enter the register values in hex, in the order they were read (only the first one for a 16-bit point), then the number the device display showed at the same moment. Matching cells are highlighted.

Leave empty for a 16-bit point

Byte orderRearrangedFloatUnsignedSigned
ABCD449A 50001234.5 Match11509637121150963712
CDAB5000 449A8.607918e+913421948421342194842
1 matching cell
IN PRACTICE

Example: reading a power meter with CGate

Below is a sample register map, not from a specific brand; use the addresses and types in your own power meter’s manual. Select a point or one of its registers to see how that point is set up on our CGate gateway.

How many registers each point takes

Total active energy· UInt32

Start address
0x0002
Registers used
0x0002–0x0003 (2 registers)It occupies two registers, 0x0002 and 0x0003.
Data type
32-bit unsigned integer, length 2, scale factor 0.01, unit kWh
Set on CGate
Data type32-bit unsigned integer