Modbus Function Codes - Knowledge Base

Modbus function code reference covering FC01–FC16 for reading and writing coils, discrete inputs, holding registers, and input registers.

Categories:

What Function Codes Are

A Modbus function code is a single-byte instruction in every Modbus request that tells the server (slave) what operation to perform. The function code determines which register type is accessed and whether the operation is a read or a write.

Common Function Codes

These function codes cover the vast majority of building automation integrations:

CodeNameData TypeAccessMax Items
01Read CoilsCoil (1 bit)Read2,000
02Read Discrete InputsDiscrete Input (1 bit)Read2,000
03Read Holding RegistersHolding Register (16 bit)Read125
04Read Input RegistersInput Register (16 bit)Read125
05Write Single CoilCoil (1 bit)Write1
06Write Single RegisterHolding Register (16 bit)Write1
15Write Multiple CoilsCoil (1 bit)Write1,968
16Write Multiple RegistersHolding Register (16 bit)Write123

Register Type ↔ Function Code Mapping

Each register type has a fixed set of function codes. Using the wrong function code for a register type returns an Illegal Function exception (exception code 01).

Register TypeRead FCWrite FC
Coils (0xxxx)0105 / 15
Discrete Inputs (1xxxx)02— (read-only)
Input Registers (3xxxx)04— (read-only)
Holding Registers (4xxxx)0306 / 16

[!NOTE] The reference number ranges (0xxxx, 1xxxx, etc.) are Modicon conventions. Actual PDU addresses are always 0-based. See Modbus Addressing & Register Reference for details.

Diagnostic and Special Function Codes

CodeNameUse
07Read Exception StatusSerial diagnostic (8 exception bits)
08DiagnosticsSerial loopback and bus diagnostics
11Get Comm Event CounterSerial event counting
17Report Server IDDevice identification
23Read/Write Multiple RegistersCombined read+write in one transaction
43Read Device IdentificationMEI transport — device metadata

Exception Responses

When a function code fails, the server returns an exception response with the function code OR’d with 0x80 and an exception code:

Exception CodeMeaning
01Illegal Function — FC not supported
02Illegal Data Address — register doesn’t exist
03Illegal Data Value — value out of range
04Server Device Failure — internal device error
06Server Device Busy — retry later

[!TIP] Exception code 02 (Illegal Data Address) paired with FC03 or FC04 is the most common error in integration work — it usually means the register address is off by one. See Modbus Addressing & Register Reference.

Need more help?

If this page does not resolve the issue, contact Chipkin support with the product model, protocol details, and any diagnostics you have already captured.

Open Chipkin Support