I2C Issues - CrowPanel x" -HMI ESP32 Display

I need to use one or more PCF8575s with my HMI displays (7, 5, and 2.8 inches) but I cannot get my PCF8575 IO Expander Module I2C to 16IO to work for the life of me. I read all 8575 related posts here but none of the methods has worked for me. First, what library do you recommend, second, is there sample code I can look at for that library? I am using Arduino IDE. Thanks!

Tagged:

Comments

  • Hi Bernhard,
    Our technical support team is currently looking into your issue in your email. Please be patient, and we will get back to you as soon as possible.
    Best regards,

  • Hi Bernhard,
    About the issue, please refer to the following information:
    _To use the PCF8575 I2C 16-bit IO expander module on your ESP32-S3 development board, the following libraries are recommended:


    📚 Recommended Libraries

    1. Rob Tillaart's PCF8575 Library
      This library provides simple control over the 16 pins of the PCF8575 chip, allowing you to expand up to 128 IO ports via the I2C bus.
      👉 GitHub: PCF8575 by Rob Tillaart
    2. Adafruit’s PCF8574 Library
      Although named for the PCF8574, this library also supports the PCF8575 and includes example code for easy integration with Arduino-compatible microcontrollers.
      👉 GitHub: Adafruit-PCF8574
    3. xreef’s PCF8575 Library
      This one supports both Arduino and ESP8266. It enables digital reads and writes using only two I2C wires, ideal for devices like ESP-01.
      👉 GitHub: PCF8575 by xreef

    Example Code (Using Rob Tillaart’s Library)

    #include "Wire.h"
    #include "PCF8575.h"
    
    // Create a PCF8575 instance, default I2C address is usually 0x20
    PCF8575 pcf8575(0x20);
    
    void setup() {
      Serial.begin(115200);
      Wire.begin(); // Initialize I2C
    
      // Initialize PCF8575
      if (!pcf8575.begin()) {
        Serial.println("Failed to initialize PCF8575, check connections!");
        while (1);
      }
    
      // Set all pins as OUTPUT
      for (int i = 0; i < 16; i++) {
        pcf8575.pinMode(i, OUTPUT);
      }
    }
    
    void loop() {
      // Sequentially turn on each pin
      for (int i = 0; i < 16; i++) {
        pcf8575.digitalWrite(i, HIGH);
        delay(500);
        pcf8575.digitalWrite(i, LOW);
      }
    }
    

    Important Notes

    • I2C Address:
      The default I2C address of the PCF8575 is 0x20, but it can be changed by setting A0, A1, and A2 pins high or low. Make sure the address in your code matches your device.

    • Pull-up Resistors:
      The I2C bus requires pull-up resistors (typically 4.7kΩ). If they’re not built into your board or module, you’ll need to add them manually.

    • Input Mode:
      If you configure the PCF8575 pins as inputs, it's recommended to use INPUT_PULLUP to keep the state stable and avoid floating inputs._

Sign In or Register to comment.