Automation Glossary • Modbus Function Code 05 Write Single Coil

Modbus FC05 (Write Single Coil)

Merobix Engineering • • 7 min read

Function code 05 writes a single coil, forcing one discrete bit on or off. It is the code you use to send one command, such as a start, a stop, or a reset, to a device. This reference explains the peculiar on/off encoding FC05 uses, how the device confirms the write, and when to reach for the multiple-coil write instead.

Back to Blog

Modbus Function Code 05 Write Single Coil in one line: Modbus function code 05 writes a single coil, forcing one discrete bit on or off. The request carries the coil address and a two-byte value that is 0xFF00 to turn the coil on and 0x0000 to turn it off; no other value is valid. On success the device echoes the request back unchanged. It writes only the coil table, since discrete inputs and registers are not coils.

The FF00 and 0000 On/Off Encoding

Function code 05 does not send a single bit. It sends a two-byte value where 0xFF00 means turn the coil on and 0x0000 means turn it off, and any other value is invalid and returns an illegal data value exception. This fixed encoding trips up newcomers who try to send 0x0001 for on. The request is simply the coil address followed by one of those two values.

On a successful write the device echoes the entire request back: the same coil address and the same value. That echo is the acknowledgment, so a master confirms the command took effect by matching the response to what it sent. Because FC05 acts on the coil table, it is the write partner of the coil read described in the Modbus function code overview.

When to Use FC05 Versus FC15

Function code 05 writes exactly one coil. When several coils must change together, or must change atomically as a group, function code 15 writes multiple coils in one request instead, which is faster and avoids a partially applied state. Use FC05 for a single discrete command like a pump start; use FC15 when setting a bank of outputs. The distinction mirrors the single-versus-multiple split on the register side.

A common failure is directing FC05 at a discrete input or a register address. Discrete inputs are read-only and are not coils, and registers are sixteen-bit words rather than bits, so either target returns an exception. If the value you intend to command is not actually a coil, no coil write will reach it. Confirm the target lives in the coil table using the Modbus register types reference before troubleshooting further.

The Request Frame, Byte by Byte

The FC05 request is one of the simplest frames in the protocol, and being able to read it raw pays off when staring at a capture:

FieldSizeContent
Server address1 byteTarget device (RTU) or unit ID (TCP)
Function code1 byte0x05
Coil address2 bytesZero-based address, high byte first
Output value2 bytes0xFF00 for on, 0x0000 for off
CRC2 bytesRTU only, low byte first

The address field is where the classic off-by-one lives: coil number 1 in vendor documentation is address 0 on the wire, because the traditional reference numbering is one-based while the protocol field is zero-based. When a write lands on the coil next to the one you intended, this is almost always why - check the numbering convention in the device manual before checking anything else.

Command Patterns: Pulses, Readback, and Permissions

An FC05 write sets a state; Modbus has no native momentary command. If a device needs a pulse - a start command that clears itself - that behavior lives in the device's logic, which may auto-reset the coil after acting on it. This matters for verification: writing 0xFF00, receiving a clean echo, and then reading the coil back as off can be perfectly correct behavior for a self-resetting command coil. Know which kind of coil you are commanding before declaring a fault.

For coils that hold state, the robust pattern is write-then-verify: send FC05, match the echo, then read the coil back with FC01 and confirm the state, because the echo proves the device accepted the request, not that the output ultimately changed. In supervisory systems, coil writes are the sharp end of remote control: write access should be restricted to the specific coils an operator legitimately commands, anything that starts or stops equipment must remain subordinate to the device's local interlocks and the site's operating procedures, and qualified personnel decide what may be commanded remotely at all. Where that command layer sits in a modern architecture is covered in the guide to connecting Modbus to cloud SCADA.

Reading FC05 Exception Replies

When FC05 fails, the device returns 0x85 - the function code with its high bit set - plus one exception byte. Exception 01, illegal function, means the device does not implement coil writes at all. Exception 02, illegal data address, means the coil address is not in the map; check the off-by-one first. Exception 03, illegal data value, is the FC05 special: you sent something other than 0xFF00 or 0x0000. Exception 04, server device failure, means the device accepted the frame but could not act, which on real equipment often means a local mode or a hardware fault. The general decoding habit is in the exception code reference; the FC05-specific heuristic is that 02 and 03 point at your configuration while 04 points at the device.

When a Successful Write Changes Nothing

The most confusing FC05 case is a clean echo with no effect on the physical output. The causes, in rough order of likelihood: the device's own logic immediately overwrites the coil (a PLC program that writes that bit every scan wins every time), the output is switched to local or hand mode, the coil maps to internal logic rather than a physical point, or you wrote the right address in the wrong device. The PLC program case deserves emphasis: a coil that running logic also writes is not remotely commandable in any meaningful sense, and the fix belongs in the program - a dedicated command bit the logic reads - rather than in the master retrying harder. And when several outputs must change as one, use function code 15 instead of a burst of FC05 requests.

Frequently Asked Questions

Why does FC05 use 0xFF00 instead of 1 for on?

The Modbus specification fixes the coil-on value as 0xFF00 and the coil-off value as 0x0000, and treats every other value as invalid. It is a protocol convention, not a bit. Sending 0x0001 or any value other than those two returns an illegal data value exception, so a master must use exactly 0xFF00 or 0x0000.

How does a device confirm an FC05 write succeeded?

The device echoes the request back unchanged: the same coil address and the same 0xFF00 or 0x0000 value. Matching that echo to what you sent is how the master confirms the coil was set. If instead an exception response comes back, the coil address or value was rejected and the write did not take effect.

When should I use FC15 instead of FC05?

Use function code 15 when you need to write several coils at once, especially when they should change together as a group. FC05 writes exactly one coil per request, so setting a bank of outputs with FC05 takes many round trips and can leave the outputs in a mixed intermediate state. FC15 writes them in a single atomic request.

Can FC05 be broadcast to all devices?

On serial Modbus, yes: a write sent to address 0 is a broadcast that every server executes and none replies to. That means no echo, no exception, and no confirmation of any kind, so broadcast coil writes are rare in practice and unsuitable for anything you need to verify. On Modbus TCP there is no true broadcast; each connection targets one device, and gateways handle unit ID 0 in vendor-specific ways.

Does FC05 work the same over Modbus TCP?

Yes. The protocol data unit - function 0x05, coil address, and the 0xFF00 or 0x0000 value - is identical; TCP simply wraps it in an MBAP header instead of a serial address and CRC. The echo response works the same way. The differences are transport-level: the unit ID stands in for the slave address, there is no CRC, and TCP's connection handling turns failure symptoms from silent timeouts into connection errors.

Sources and verification

This page references the protocol specifications published by the organizations below. Editions, product capabilities, and documentation change over time - confirm current requirements and specifications directly with the source.

Merobix is not affiliated with, endorsed by, or sponsored by these organizations; their names are used only to identify the standards and products discussed.

More in Industrial Protocols
Modbus Function Code 06 Write Single Register  •  Modbus Function Code 15 Write Multiple Coils  •  Modbus Function Code 16 Write Multiple Registers  •  Modbus Illegal Function (Exception 01)  •  Modbus Function Code  •  All Industrial Protocols →
Free SCADA operator training
Merobix University - 70 video lessons & 261 quiz questions, from first login to compliance reporting. No demo call required.
Start free →