Modbus Function Code Reference

Reference and search common Modbus RTU function codes, request formats, and exception responses in one page.

Function and exception code lookup

Type a function code, hex value, object type, or exception name. Search is case-insensitive and tolerant to spaces and punctuation.

Quick filters
- -

Modbus function code table

Code HEX Name Object Access Typical request Common use
010x01Read CoilsCoilsReadstart address + quantityRead digital outputs (coil status).
020x02Read Discrete InputsDiscrete inputsReadstart address + quantityRead digital inputs.
030x03Read Holding RegistersHolding registersReadstart address + quantityRead writable holding registers.
040x04Read Input RegistersInput registersReadstart address + quantityRead input registers (read-only values).
050x05Write Single CoilCoilWriteaddress + valueWrite one digital output.
060x06Write Single RegisterHolding registerWriteaddress + valueWrite one holding register.
070x07Read Exception StatusStatus byteReadfunction onlyLess common serial-line status read.
080x08DiagnosticsDiagnosticsRead/Writesub-function + dataDiagnostics and loopback operations.
110x0BGet Comm Event CounterCounterReadfunction onlySerial-line communication event counter.
120x0CGet Comm Event LogEvent logReadfunction onlySerial-line communication event log.
150x0FWrite Multiple CoilsCoilsWritestart address + quantity + byte count + dataWrite multiple digital outputs.
160x10Write Multiple RegistersHolding registersWritestart address + quantity + byte count + dataWrite multiple holding registers.
170x11Report Server IDServer identificationReadfunction onlyLegacy serial-line identification response.
200x14Read File RecordFile recordReadsub-request reference + lengthLess common file record read.
210x15Write File RecordFile recordWritesub-request reference + dataLess common file record write.
220x16Mask Write RegisterHolding registerWriteaddress + AND mask + OR maskBit-mask update for one register.
230x17Read/Write Multiple RegistersHolding registersRead/Writeread range + write rangeCombined read/write in one transaction.
240x18Read FIFO QueueFIFO queueReadFIFO pointer addressRead FIFO queue content from server.
430x2BEncapsulated Interface TransportMEI / device identificationReadMEI type + dataDevice identification and MEI transport.

Modbus exception code table

Code HEX Name Meaning Common cause
010x01Illegal FunctionThe server does not support this function code.Using a function the device firmware does not implement.
020x02Illegal Data AddressAddress is out of valid range for this object.Wrong register map base, offset, or object type.
030x03Illegal Data ValueOne or more request values are invalid.Quantity/value out of allowed limits.
040x04Server Device FailureServer failed while processing the request.Internal firmware fault or temporary failure.
050x05AcknowledgeAccepted, but operation is taking more time.Long-running programming command.
060x06Server Device BusyServer is busy and cannot process now.Device is processing another task.
080x08Memory Parity ErrorMemory parity or consistency error occurred.Memory integrity issue on the server device.
100x0AGateway Path UnavailableGateway path is not available.Gateway routing or network segment issue.
110x0BGateway Target Device Failed to RespondGateway did not get response from target.Target server offline or no response path.

What are Modbus function codes?

A Modbus function code is a one-byte operation identifier in the PDU. It tells the server which object to access and how to process request data.

Common Modbus RTU function codes

Functions 01, 02, 03, 04, 05, 06, 15, and 16 are the most common in field devices. They cover coil and register read/write transactions.

Modbus exception codes

When a request fails, Modbus returns an exception response with an exception code that indicates the reason, such as illegal function or illegal address.

Exception response: function code + 0x80

In RTU exception responses, the returned function byte is the original function code plus 0x80. For example, 0x03 request errors return 0x83.

Function 03 vs 04

Function 03 reads holding registers, usually writable values. Function 04 reads input registers, usually read-only measured values.

Function 06 vs 16

Function 06 writes a single holding register. Function 16 writes multiple contiguous holding registers in one request.

Modbus RTU request/exception examples

Function 03 example

Request frame

01 03 00 00 00 02 C4 0B

01 is server/slave address, 03 is Read Holding Registers, 0000 is start address, 0002 is quantity, and C4 0B are CRC low/high bytes.

Function 06 example

Request frame

01 06 00 01 00 64 D9 E1

Writes value 0x0064 into register 0x0001. D9 E1 are CRC low/high bytes for this request.

Exception response example

Response frame

01 83 02 C0 F1

0x83 means function 0x03 exception response, and 0x02 means Illegal Data Address.

FAQ

What is Modbus function code 03?

Function 03 reads holding registers from a server/slave device.

What is the difference between Modbus function 03 and 04?

Function 03 reads holding registers, while function 04 reads input registers. Device register maps define which addresses are valid.

What is Modbus function code 16?

Function 16 (0x10) writes multiple holding registers in one request frame.

What does exception code 02 mean?

Exception code 02 is Illegal Data Address, typically caused by an invalid register or object range.

Why is the exception function code 0x83 for function 0x03?

Modbus RTU exception responses set bit 7 of the original function code. 0x03 therefore becomes 0x83.

Related tools