The PCF8574N is an I2C I/O expander manufactured by Texas Instruments. It provides 8 additional General Purpose Input/Output (GPIO) pins for microcontrollers, enabling easy expansion of input/output capabilities. This component is particularly useful in applications where the number of GPIO pins on a microcontroller is insufficient. The PCF8574N communicates with the host microcontroller via the I2C protocol, requiring only two pins (SCL and SDA) for data transfer.
The following are the key technical details of the PCF8574N:
Parameter | Value |
---|---|
Operating Voltage (Vcc) | 2.5V to 6V |
I2C Bus Speed | Up to 100 kHz (Standard Mode) |
GPIO Pins | 8 (P0 to P7) |
Maximum Sink Current (per pin) | 25 mA |
Maximum Source Current (per pin) | -300 µA |
Operating Temperature Range | -40°C to 85°C |
Package Type | DIP-16 |
The PCF8574N comes in a 16-pin DIP package. The pinout and descriptions are as follows:
Pin Number | Pin Name | Description |
---|---|---|
1 | P0 | GPIO Pin 0 |
2 | P1 | GPIO Pin 1 |
3 | P2 | GPIO Pin 2 |
4 | P3 | GPIO Pin 3 |
5 | P4 | GPIO Pin 4 |
6 | P5 | GPIO Pin 5 |
7 | P6 | GPIO Pin 6 |
8 | GND | Ground |
9 | P7 | GPIO Pin 7 |
10 | INT | Interrupt Output (active LOW) |
11 | SCL | I2C Clock Line |
12 | SDA | I2C Data Line |
13 | A0 | I2C Address Selection Bit 0 |
14 | A1 | I2C Address Selection Bit 1 |
15 | A2 | I2C Address Selection Bit 2 |
16 | Vcc | Power Supply (2.5V to 6V) |
The I2C address of the PCF8574N is determined by the A0, A1, and A2 pins. These pins can be connected to either GND (logic 0) or Vcc (logic 1). The base address is 0x20
, and the final address is calculated as:
I2C Address = 0x20 + (A2 * 4) + (A1 * 2) + (A0 * 1)
For example:
Below is an example of how to use the PCF8574N with an Arduino UNO to control LEDs connected to the GPIO pins.
#include <Wire.h> // Include the Wire library for I2C communication
#define PCF8574_ADDRESS 0x20 // Base I2C address of the PCF8574N
void setup() {
Wire.begin(); // Initialize I2C communication
Serial.begin(9600); // Start serial communication for debugging
// Set all GPIO pins to output and turn them off
Wire.beginTransmission(PCF8574_ADDRESS);
Wire.write(0x00); // Write 0x00 to set all pins LOW
Wire.endTransmission();
}
void loop() {
// Turn on all LEDs
Wire.beginTransmission(PCF8574_ADDRESS);
Wire.write(0xFF); // Write 0xFF to set all pins HIGH
Wire.endTransmission();
delay(1000); // Wait for 1 second
// Turn off all LEDs
Wire.beginTransmission(PCF8574_ADDRESS);
Wire.write(0x00); // Write 0x00 to set all pins LOW
Wire.endTransmission();
delay(1000); // Wait for 1 second
}
I2C Communication Not Working
GPIO Pins Not Responding
Interrupt Pin Not Functioning
Q: Can the PCF8574N be used with 3.3V microcontrollers?
A: Yes, the PCF8574N supports operating voltages from 2.5V to 6V, making it compatible with both 3.3V and 5V systems.
Q: How many PCF8574N devices can be connected to the same I2C bus?
A: Up to 8 devices can be connected by configuring unique I2C addresses using the A0, A1, and A2 pins.
Q: What happens if multiple GPIO pins are set to HIGH while sourcing current?
A: The PCF8574N has a limited source current capability (-300 µA per pin). Exceeding this limit may result in unreliable operation. Use external drivers if higher current is needed.