Volt Docs

Reference

PCF8574

I2C GPIO expander (8 pins).

Connects over
I²C
Address
0x27 (or 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x3F, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E)
Made by
Texas Instruments / NXP
Datasheet
ti.com

Use it

main.volt
hardware {
    device pcf8574: PCF8574
}

every 1s {
    let value: int = pcf8574.read()
    log("pcf8574", "read={value}")
}

On its own, the declaration puts the PCF8574 on the first I²C bus (SDA 21, SCL 22 on the ESP32) at 0x27. To choose the pins or the address, declare the bus and attach the device: device pcf8574: PCF8574 on i2c0 at 0x20 with i2c i2c0(sda: 21, scl: 22).

Methods

  • pcf8574.write(value: int)

    Write all 8 pins

  • pcf8574.read() -> int

    Read all 8 pins

  • pcf8574.set_pin(pin: int, level: int)

    Set one pin

Wiring

PinConnect to
VCC3.3V or 5V
GNDGround
SDAPull-up to VCC (often on breakout board)
SCLPull-up to VCC
A0..A2Address select (8 unique addresses 0x20 – 0x27)
INTFalls on any input change — wake-on-press for buttons

Specifications

Voltage
2.5V – 6.0V
Current
10 μA standby
Io pins
8 quasi-bidirectional
Interface speed
I²C up to 100 kHz

Tips

  • Quasi-bidirectional pins: weak high-side pull-up, strong low-side drive. To use as input, write 1 first then read.
  • Total of 8 chips on one bus → 64 GPIO over two MCU pins.
  • Most LCD I²C backpacks are PCF8574 underneath.

Alternatives worth knowing:

  • MCP23017: 16 pins, true push-pull outputs, faster (1.7 MHz).
  • PCF8575: 16-bit version of the same chip.