Explore, Create, Learn and Teach

Hobbybotics PCF8574A I2C I/O Expander

Introduction

Specifications

Documentation

Build It

Use It

Related Links

Disclaimer

Introduction

The Hobbybotics I2C I/O Expander is based on the Philips PCF8574A.  The PCF8574A provides eight bits of I/O with the use of only two pins on the Hobbyduino.  Analog pins 4 and 5 double as the SDA and SCL, respectively.  The nominal communication rate on the I2C bus is 100 kbits/sec.  The sample code presented below adds an additional eight outputs to the Hobbyduino while only using two pins.

Take a look at the “Build It” section below for a more detailed explanation of the circuit.

Specifications

  • Philips PCF8574A
  • Supply voltage 2.5V – 6V
  • Latched outputs
  • I2C to parallel port expander
  • 3 hardware address pins allows expansion up to 8 devices (PCF8574A) or 16 devices if PCF8574 is added
  • Size: 1.5W” x 1.875L”

Documentation

  • Schematic – PDF
  • PCB – PDF
  • Schematic – SCH
  • PCB – PCB
  • Mechanical Drawing – DXF
  • Bill of Materials – TXT

The schematic and PCB was developed with the freely available ExpressPCB software.

Build It

The I2C bus is a two wire connection that can link multiple devices together and allow them to exchange data in a master-slave configuration.  All devices on the I2Cbus are connected in parallel to the same bus lines.  These bus lines are known as serial clock (SCL) and serial data (SDA).  The master device on the bus controls the serial clock.  Bi-directional communication is sent on the serial data line between the master and slave devices.  The SCL and SDA lines must be pulled up to VDD with pullup resistors in the range of 1k to 10k.

To accomplish a read or write to a slave device, the master device sends out a slave address coupled with a one-bit read/write flag.  I2C addresses are seven bits long which allow up to 127 devices to be attached to the same bus.  Each device has an internal address that is made up of the four most significant bits and an external address composed of the three least significant bits.  This seven bit address is shifted left one bit and the least significant bit is used to flag a read or write.  Thus, in simple terms, a complete slave address is one byte (seven address bits and one read/write bit).  The external address for each device is set by pulling each pin of the three least significant bits (A2, A1, and A0) to VDD or GND (1 or 0).  This yields an address range of 38 to 3F hexadecimal (56 to 63 decimal).  If using this device with an Arduino, do not set the eighth bit (read/write flag) as the wire library handles this for you.

A2 – External address bit.  Set to 0 or 1.
A1 – External address bit.  Set to 0 or 1.
A0 – External address bit.  Set to 0 or 1.
R/W – Read/Write bit.  Set to 0 for write and 1 for read.

Reference the B.O.M above for a list of the parts necessary to complete the Hobbybotics PCF8574A I2C I/O Expander.

Only basic soldering skills are needed to put this board together. I recommend you start with the smaller components first such as the resistors. The PCF8574A should be the last component installed.

Reference the below schematic and layout file for component locations.

Use It

I recommend you look over your solder connections before you apply power to the board. This will give you an opportunity to detect and correct any bad solder joints or solder bridges that could possibly let the smoke out. Once that is complete there are a few tidbits we need to take care of before we can make stuff. We’ll need to get some software (free of course) and configure some settings.

1. Go here and download the latest version of the Arduino Ide.
2. Plug the FTDI Serial-to-USB adapter into an available USB port on your computer. The drivers will automatically be downloaded and installed.
3. Go to Device Manager on your computer and expand the Ports (COM & LPT) field. Right-click on the USB serial port and select -> properties -> port-settings tab -> advanced. Set the baud-rate to the appropriate setting for your controller.
4. Extract the compressed file to a location on your computer and launch the “arduino.exe” file.
5. In the Arduino Ide, select Tools -> Board -> Arduino Duemilanove or Nano w/ ATmega328.
6. Ensure the correct serial port is selected in the Arduino Ide.

You are now ready to upload and test a sketch using the Hobbyduino Mini or an Arduino of your choosing.

1. Launch the Arduino Ide and either copy and paste the above code or download the file from here.
2. Connect analog pin 4 to SDA and analog pin 5 to SCL of the I2C expander.  Connect an LED/Resistor to P0, P1, and P2 of the I2C expander with the anodes of each connected to +5V and the cathodes connected to the output pins.
3. Connect VDD and GND pins on the I2C board to the +5V and GND pins on the Hobbyduino.
4. Click the upload button and the sketch will be uploaded to the board. You’ll need to do a little troubleshooting if the sketch fails to upload. I recommend checking for the correct serial port and board within the Arduino Ide.
5. If all is successful, the LEDs will blink on/off for 1 second in an alternating pattern.  The LED connected to P0 will be off when the LEDs attached to P1 and P2 are on.

This completes the basic functionality test for the Hobbybotics PCF8574A I2C I/O Expander. Checkout the video to see it in action.

Related Links

Hobbybotics PCF8574A I2C Expander Gallery

Disclaimer

This example shows hardware and software used to implement the design. It is recommended the viewer use sound judgment in determining and/or implementing this example for any particular application. This example may include information from 3rd parties and/or information which may require further licensing or otherwise. Additional hardware or software may be required. Hobbybotics or any affiliates does not support or warrant this information for any purpose other than a design example and takes no responsibility for any mishaps (none being implied).

Follow

Get every new post delivered to your Inbox.

Join 41 other followers

%d bloggers like this: