Initializing PCF8574 (init_pcf8574)¶
What it does: Initializes the PCF8574 I2C expander at the selected address and SDA/SCL pins.

Inputs¶
pin_SDA: I2C bus SDA pin.pin_SCL: I2C bus SCL pin.- Field
adress: expander address (A0-A2).
Output¶
- none (command block).
When to use it¶
- Before first read/write to PCF8574.
- When you use multiple expanders on one I2C bus.
Tips and pitfalls¶
- Initialize once at program start.
- The address must match the physical setting of pins A0-A2.
Generated Python example¶
from machine import Pin, SoftI2C
import pcf8574
i2c_22_21 = SoftI2C(scl=Pin(22), sda=Pin(21), freq=100000)
pcf8574_0 = pcf8574.PCF8574(i2c_22_21, 0x20)