---
name: "modbus_write_bit"
section: "3"
platform: "linux"
package: "libmodbus-dev"
version: "3.1.6-2.1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/modbus_write_bit"
---

# modbus\_write\_bit(3)

write a single bit

## NAME

modbus\_write\_bit - write a single bit

## SYNOPSIS

**int modbus\_write\_bit(modbus\_t \****ctx***, int** *addr***, int** *status***);**

## DESCRIPTION

The **modbus\_write\_bit()** function shall write the status of *status* at the address *addr* of the remote device. The value must be set to TRUE or FALSE.

The function uses the Modbus function code 0x05 (force single coil).

## RETURN VALUE

The function shall return 1 if successful. Otherwise it shall return -1 and set errno.

## SEE ALSO

[**modbus\_read\_bits**(3)](/modbus_read_bits/3.md) [**modbus\_write\_bits**(3)](/modbus_write_bits/3.md)

## AUTHORS

The libmodbus documentation was written by Stéphane Raimbault \<stephane.raimbault@gmail.com\>
