meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sensor:pcf857x [2026/05/14 15:24] vamsansensor:pcf857x [2026/05/14 16:58] (current) vamsan
Line 1: Line 1:
 ====== lamaPLC: PCF857x I/O Expander chip/modul with I²C communication ====== ====== lamaPLC: PCF857x I/O Expander chip/modul with I²C communication ======
 +{{ :sensor:pcf8575_1.png?120|CF857x I/O Expander chip/modul with I²C communication}}
 The PCF857x series consists of I²C-based general-purpose I/O (GPIO) expanders manufactured by NXP and Texas Instruments. They allow microcontrollers (such as Arduino, ESP32, or Raspberry Pi) to control multiple digital pins with only two wires: Serial Data (SDA) and Serial Clock (SCL). The PCF857x series consists of I²C-based general-purpose I/O (GPIO) expanders manufactured by NXP and Texas Instruments. They allow microcontrollers (such as Arduino, ESP32, or Raspberry Pi) to control multiple digital pins with only two wires: Serial Data (SDA) and Serial Clock (SCL).
  
-|<100%>|+|<100% 20% 40% 40%>|
 ^Feature^PCF8574 / PCF8574A^PCF8575| ^Feature^PCF8574 / PCF8574A^PCF8575|
 ^GPIO Count|8-bit (8 pins)|16-bit (16 pins)| ^GPIO Count|8-bit (8 pins)|16-bit (16 pins)|
-^I²C Base Address|0x20 (PCF8574) / 0x38 (PCF8574A)|0x20| +^I²C Base Address|**0x20** (PCF8574) / **0x38** (PCF8574A)|**0x20**
-^Max Devices on 1 Bus|8 units|units|+^Max Devices on 1 Bus|8 units|16 units|
 ^Operating Voltage|2.5V to 6V|2.5V to 5.5V| ^Operating Voltage|2.5V to 6V|2.5V to 5.5V|
 ^Interrupt Output|Yes (Open-drain INT)|Yes (Open-drain INT)| ^Interrupt Output|Yes (Open-drain INT)|Yes (Open-drain INT)|
 +
 +The current limits of the PCF857x are heavily lopsided because of its quasi-bidirectional architecture. It handles current entirely differently depending on whether you are sinking current (outputting 0/LOW) or sourcing it (outputting 1/HIGH).
 +
 +The [[arduino:display_lcd#i_c_lcd_adapter|I²C LCD adapter]] utilizes the PCF8574.  
 +
 +**Main Control & Power Header**
 +
 +  * **VCC:** Power input. Connects to **3.3V or 5V** to match your microcontroller's logic levels.
 +  * **GND:** Common ground reference.
 +  * **SDA:** Serial Data line for I²C communication.
 +  * **SCL:** Serial Clock line for I²C communication.
 +  * **INT:** Interrupt output (Active Low). Pulls low to alert the microcontroller when an input pin changes state, eliminating the need for software polling.
 +
 +**8/16-Bit I/O Extension Pins**
 +
 +  * **Port 0** (P00 to P07): The first group of 8 quasi-bidirectional GPIO pins.
 +  * **Port 1** (PCF8575 only, P10 to P17): The second group of 8 quasi-bidirectional GPIO pins.
 +
 +**Sinking Current (Output LOW / Connecting to Ground)**
 +
 +  * **Maximum per individual pin:** 25 mA (typical) / 20 mA for extended use.
 +  * **Maximum combined total (all 16 pins combined):** 100 mA.
 +  * **The Math:** If you activate all 16 pins simultaneously at LOW logic, you can only allocate a maximum of 6.25 mA per pin (100 mA ÷ 16) to avoid overloading the chip.
 +
 +**Sourcing Current (Output HIGH / Connecting to VCC)**
 +
 +This is the weak mode meant mostly for sensing state changes.
 +  * **Maximum per individual pin:** Only 100 µA (0.1 mA).
 +  * **The Limit:** This current is too weak to directly light up an LED or actuate a standard relay trigger.
 +
 +**How to Correctly Wire Components**
 +
 +  * **Correct (Sinking):** Connect your load's positive wire to VCC, and the negative side (through a current-limiting resistor) directly to the PCF8575 I/O pin. Setting the pin LOW completes the path to ground and activates the load.
 +  * **Incorrect (Sourcing):** Connecting your load's positive wire to the PCF8575 I/O pin and the negative side to Ground will fail, as the pin cannot supply sufficient current.
 +
 +{{ :sensor:pcf857x_wiring_1.png |PCF8575 I/O How to Correctly Wire Components}}
 +
 +==== Wiring with relay modules ====
 +Connecting optocoupled relay modules to the PCF8575 is a common practice, but it requires strict electrical care. Because of the chip's asymmetrical quasi-bidirectional ports, a mistake in how you trigger the relay will prevent it from working entirely.
 +
 +**The Triggering Rule: Active LOW Only**
 +
 +  * **Why Active HIGH fails:** Standard optocoupled multi-channel relay modules require 2-5 mA of logic current on their IN pins to light the internal infrared LED and engage the circuit. Because the PCF8575 can source only 0.1 mA when outputting HIGH, it cannot trigger an Active HIGH configuration.
 +  * **Why Active LOW works:** When configured as Active LOW, the PCF8575 acts as a ground connection (0V), cleanly sinking the current from the relay module. The PCF8575 can safely sink up to 20 mA per pin, easily meeting the relay's current requirements.
 +
 +For example, the HL-54 (4-channel 3.3V optocoupled relay module) can be directly connected to the PCF8575. Because the HL-54 is hardwired as an Active LOW module, it is perfectly suited to the PCF8575's current limits.
 +
 +===== I²C topics on lamaPLC =====
 +{{topic>i2c}}
 +
 +\\
 +\\
 +{{tag>communication i2c PCF857x PCF8574 PCF8574A PCF8575 I/O_Expander I/O_Extension I2C NXP Texas_Instruments}}
 +\\
 +This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}