Using The PCF8575 i2c i/o Expander To Read Inputs With Arduino

This Instructable will show you just how easy it is to add extra inputs to your Arduino. You can use this technique to add hundreds of extra inputs to your Arduino with only two wires by using a fancy communication protocol called i2c (eye-squared-see).

Read Inputs

Step 1: Build The Circuit

The SDA and SCL lines enable i2c communication.Which pins are SDA and SCL?
Uno, Ethernet: A4 (SDA), A5 (SCL)
Mega2560: 20 (SDA), 21 (SCL)
Leonardo: 2 (SDA), 3 (SCL)
Due: 20 (SDA), 21 (SCL), SDA1, SCL1

The PCF8575 is not available in a breadboard-friendly form (only surface mount). The handy Sparkfun breakout boards allow you to plug this chip into the breadboard for prototyping.

You need to connect a 10kOhm resistor between SDA/SCL and PWR (see image).

Also note that push-buttons need resistors. If you want an i2c i/o expander in which you don’t need resistors on the switches check out the MCP23017.

If you are having troubles hooking up your switches try this for reference.

I included the LEDs only to provide some feedback. They add no functionality.

Step 2: The Code

Okay now the scary part – the code.If you want to use i2c devices it is best to understand how the code works otherwise you are going to have many problems down the road.

i2c is handled using the Arduino wire library.

To understand i2c you are going to have to do a bit of reading. Expect to be very confused at first. If you plan to do any intermediate and advanced electronics learning i2c is imperative.

READ  Balance Beam Controller

I will try to give a very simple explanation of i2c.

One thing you will notice, as you begin to work with electronics, is that you always have a mess of wires. A long time ago Phillips said ‘hell with all these wires – we need a way for all the devices to talk to eachother with only two wires’. Shortly after, i2c was created. Now you can buy i2c chips which do just about everything, and all these chips are able to communicate with eachother using only two wires. i2c is often called the ‘two wire interface’.
So how do these devices talk to each other? Well, they all have an address, much like you have a mailing address at your house. With this unique address you can talk to each device individually. The Arduino, which would be the master-i2c-device, can send instructions to the individual slave-i2c-devices using a fancy communication protocol. In Arduino, the send-communication looks like this:

Wire.beginTransmission(aDeviceAddress); //who are you talking to?
Wire.send(someDate); //what data are you sending this device
Wire.endTransmission(); //end communication

Major Components in Project

For more detail: Using The PCF8575 i2c i/o Expander To Read Inputs With Arduino

This Post / Project can also be found using search terms:

  • pcf8575 arduino
  • pcf8575 arduino example
  • pcf8575 arduino library
  • google conectar pcf 8575 a arduino

Comments (2)

  • rené

    With which version of the Wire library and Arduino IDE did you make this work?
    conflicts with the definition for read in the Wire library (which takes _no_ arguments).

    I changed it to dt = lowByte(;

    This compiles, but I have no idea what the consequences are..

  • rené

    Forgot to add, I am using Arduino 1.0.3


Leave a Comment

= 5 + 1

(Spamcheck Enabled)

Read previous post:
ZMDI uses digital chip to improve MEMS sensor accuracy

Dresden, Germany, February 25, 2013 – ZMD AG (ZMDI), a Dresden-based semi­conductor company that specializes in enabling energy efficient solutions,...

Scroll to top