Part

I/O expander, PCF8574

Eight more pins on two wires. No registers: a byte out is the pins, a byte in is what they read.

See every part
  • 13 pins
  • 1 setting
  • In 2 projects
  • In 1 lesson
Drawn live by the editor's own code, at the size you see it.
At a glance

The I/O expander, PCF8574 in brief

What it is, and every setting the properties panel gives it.

The PCF8574 adds eight pins to a board over two I2C wires, and it is the same chip that sits on the back of every I2C LCD backpack. It is about as simple as a chip can be: there are no registers. Each byte written after the address appears on its eight pins, P0 in bit 0; each byte read is their levels. A pin written 0 pulls hard to ground and can sink an LED’s current; a pin written 1 is only held up weakly, so anything outside can pull it down, which is how a pin becomes an input. The board’s jumpers set the address from 0x20 to 0x27, or 0x38 to 0x3F on the PCF8574A. Mokxi models the port in both directions, power-up with every pin high, and the INT pin falling when an input changes and releasing on the next read or write.

Family
Logic
Pins
13
address
32
Pins

13 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
GND
Ground.
VCC
Supply, 2.5 to 6 V.
SDA
I2C. The module carries the pull-ups.
SCL
I2C. The module carries the pull-ups.
INT
Open drain, low when an input has changed. Needs a pull-up.
P0
P1
P2
P3
P4
P5
P6
P7
How to use it

How to add eight pins to an Arduino with a PCF8574

VCC to 5 V, GND to ground, SDA to A4 and SCL to A5. The More pins project leaves the address at 0x20 and puts an MCP23017 on the same bus, so you can compare the two expanders side by side.

No library is needed. Wire.beginTransmission(0x20), Wire.write() one byte, Wire.endTransmission(), and the eight pins take its bits. The project writes a byte with one 0 in it and moves that 0 along P0 to P3 every 250 ms; the other pins stay at 1. To see it, add LEDs that run from 5 V through a resistor into P0 to P3, since a PCF8574 lights an LED by pulling its pin low. To read buttons, write 1 to their pins first, wire each button from the pin to ground, and Wire.requestFrom(0x20, 1) returns a byte where a pressed button is a 0.

Part pin
Board pin
VCC
5 V
GND
GND
SDA
A4
SCL
A5
INT
Not wired
P0 to P3
The walking bit (add LEDs from 5 V to see it)

The chip runs from 2.5 to 6 V, so on a 3.3 V board power it from 3.3 V and use the board’s own SDA and SCL; the bytes are the same.

Arduino Uno: a PCF8574 and an MCP23017 on one buslive0.000 s 0.00x
Hold the button
This is the simulator itself, running here. Click anything to open it in the editor.
One dark bit walking, from the More pins sketch
Wire.beginTransmission(0x20);
Wire.write((uint8_t)~(1 << step));   // one pin low, the rest high
Wire.endTransmission();
step = (step + 1) % 4;
Common errors

Common I/O expander, PCF8574 errors and fixes

What goes wrong
The fix
LEDs wired from the pins to ground stay dark.
A pin at 1 only offers a weak pull-up, about 100 µA. Wire each LED from VCC through a resistor into the pin, and write 0 to light it.
A button always reads as pressed.
The pin was last written 0, and a pin written 0 reads 0 whatever is on it. Write 1 to every input pin before reading.
Nothing answers at the address you expected.
The PCF8574 lives at 0x20 to 0x27 and the PCF8574A at 0x38 to 0x3F. Run an I2C scanner, or check the chip’s marking and the three jumpers.
INT never changes.
It is open drain and only pulls low. Give it a pull-up to VCC, and read the port after it falls so it can release.
Questions

Questions and answers

Does the PCF8574 need a library?

No. Wire is the whole driver: one byte out sets all eight pins and one byte in reads them. Libraries such as Rob Tillaart’s PCF8574 add per-pin calls on top.

How many PCF8574 boards can I put on one bus?

Eight of the PCF8574 and eight of the PCF8574A, since their address ranges do not overlap: up to 128 extra pins on two wires.

Is the PCF8574 the chip on an I2C LCD backpack?

Yes. The backpack wires its eight pins to the display’s data and control lines, which is why those displays usually show up at 0x27 or 0x3F.

Can a PCF8574 pin drive an LED from the pin to ground?

Not usefully. A high pin only supplies about 100 µA, so the LED barely glows. Sink the current instead: LED from VCC into the pin.

How it is modeled

What is true about the I/O expander, PCF8574, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

The port, both ways, as above; power-up with every pin high. INT goes low when a pin's level stops matching what it was at the last read or write, and a read or write lets it go, which is the datasheet's rule. A write's own pins settling do not raise it.

Not modeled

The brief strong pull-up a real chip gives a pin as it is written from 0 to 1. The weak pull-up is a 50 kΩ resistor here rather than a current source. The 25 mA sink limit: a pin pulled low sinks whatever the circuit asks.

From PCF8574 I/O expander, in full.

Projects

See the I/O expander, PCF8574 in a project

2 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

One lesson places it in its own circuit.

Boards

The boards it is shown on

This board has a built-in project with the I/O expander, PCF8574 in it.

Libraries

Arduino libraries for the I/O expander, PCF8574

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the I/O expander, PCF8574

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.