Modbus register decoder

Decode Modbus registers as a float or integer, and see the value in every byte and word order side by side.

Have the register values? Decode them here. To go from a number to registers, use the IEEE 754 float converter.

Modbus and serial Updated Free, no sign-up

Registers

Examples

Four hex digits per register, in the order read

Interpretation
Byte order

Value, ABCD order

2.004137

CDAB, word swap
400.5
BADC, byte swap
5.949312e−39
DCBA, little-endian
−199681
Bytes decoded, in order
40 00 43 C8

NaN or infinity usually means the wrong type or order, or a documented “no value” state in the register map.

How it’s calculated

The registers are laid out as bytes in the chosen order (ABCD is the first register high byte first) and read as an IEEE 754 float or a two’s-complement integer

In ABCD order the bytes are 40 00 43 C8, which as a 32-bit IEEE 754 float is 2.004137.

Tip: Check against a value you know, such as a voltage near 230 or 400. The order that gives it is the order for the whole device.

How to decode a Modbus float (IEEE 754)

A Modbus register holds 16 bits, so a 32-bit float or integer takes two registers and a 64-bit value takes four. The Modbus specification fixes the byte order inside each register (high byte first) but not the order of the registers, so devices differ. Enter the registers as read and the decoder shows the value in all four orders side by side; the one that gives a sensible reading is usually obvious.

Put the bytes in order

ABCD: A B from the first register, C D from the second

Big-endian ABCD is the most common. CDAB swaps the two registers (word swap), BADC swaps the bytes inside each register, and DCBA reverses all four.

Split the 32 bits

1 sign bit | 8 exponent bits | 23 fraction bits

IEEE 754 single precision. The first bit is the sign, the next eight the exponent with a bias of 127, and the last 23 the fraction after an implied leading 1.

Work out the value

value = (−1)s × 1.f × 2(e − 127)

For 43 6A 00 00 the sign is 0, the exponent is 0x86 = 134, so the scale is 27 = 128, and the fraction 0x6A0000 gives 1.828125. 1.828125 × 128 = 234.

Integers

value = high word × 65536 + low word

An unsigned 32-bit integer joins the two registers. A signed integer uses two’s complement: if the top bit is set, subtract 232 (or 216 for one register). FF38 as a signed 16-bit integer is −200.

Modbus float decoding examples

A voltage of 234 V in two registers

A meter returns 436A and 0000 for a phase voltage. Read big-endian (ABCD), the bytes 43 6A 00 00 decode to 234. Read with the registers swapped, the same data gives 2.4184e‑41, a clear sign of the wrong order.

Value, ABCD order 234 Open in the calculator

A word-swapped float

Another device returns 4000 then 43C8. In ABCD order that is 2.004137, which looks plausible but is wrong. With the registers swapped (CDAB) the bytes are 43 C8 40 00, which is 400.5. Check one register you can confirm, such as a line voltage, before trusting the rest of the map.

Value, CDAB order 400.5 Open in the calculator

An energy counter as an unsigned 32-bit integer

Energy registers are often unsigned 32-bit integers. 0001 E240 is 1 × 65,536 + 57,920 = 123456. The register map gives the scale, for example 0.1 kWh per count, which would make this 12,345.6 kWh.

Value, ABCD order 123456 Open in the calculator

Common values as 32-bit float registers

The registers for everyday readings in big-endian order, and what the same registers give if they are read word-swapped. A tiny number such as 2.4e‑41 is the usual symptom of the wrong order.

Registers (hex)Read as ABCDRead as CDAB
0000 000000
3DCC CCCD0.1−107605600
3F73 33330.954.1734392e−8
3F80 000012.278e−41
BF80 0000−16.8697e−41
4248 0000502.3777e−41
4366 00002302.4178e−41
43C8 00004002.4315e−41
447A 000010002.4565e−41

Download this table (CSV)

Questions about Modbus float decoding

Why does my Modbus value read as a huge or tiny number?

Almost always the wrong register order or the wrong data type. A float read in the wrong order tends to give values like 2.4e‑41 or 5.9e+25. Try each order here and compare with a value you can check on the device display.

Is Modbus big-endian?

Within a register, yes: the specification sends the high byte first. For values spread across two or more registers it says nothing, so each manufacturer chooses. The device’s register map should state the order.

What is the difference between ABCD and CDAB?

The order of the two registers. In ABCD the first register holds the high half of the value; in CDAB it holds the low half. The bytes inside each register stay the same way round.

How do I read a 32-bit value?

Read two consecutive registers in one request, for example function 03 with a quantity of 2, starting at the address in the map. The Modbus address converter turns a manual’s 40001-style number into the address to send.

What does NaN mean in a register?

Not a number. Some devices use it, or 0xFFFFFFFF, to mean a reading is not available. It can also mean the type or order is wrong, so check the map before assuming a fault.

Limits of this result

  • The tool does not infer a correct order from a plausible-looking number.
  • NaN and infinity may represent documented invalid, unavailable or overflow states, or an incorrect type/order. Consult the device register map.

Read Modbus devices on the Gateway

Once the type and order are known, a ZMB reads the registers from an RS-485 device and sends them to the Gateway over the wireless mesh, with no data cable back to the panel.

Related guides

Sources

  1. MODBUS Application Protocol Specification V1.1b3 (opens in a new tab) (PDF) Modbus Organization, 2012-04-26
  2. TeSys Tera Modbus RTU communication guide: UINT32 frame example (opens in a new tab) Schneider Electric, DOCA0355EN-01