/************************************************/
/***** I2C library for PCF8574 (XREEF) *****/
/***** I2C chip = PCA8574A – addr 0x38 *****/
/***** with A0=x, A1=x, A2=x (x= GND) *****/
/************************************************/
/***** ESP32-CAM I2C bus uses pins: *****/
/***** GPIO15 = SCL (ESP32_CAM) *****/
/***** GPIO14 = SDA (ESP32_CAM) *****/
/************************************************/
Problem I2C @ ESP32-CAM (AI Thinker Board)
cpp
#include <Wire.h>
#define SCL 15 // IO15 GPIO15 HSPI_WSO HS2_CMD SD-Conn
#define SDA 14 // IO14 GPIO14 HSPI_CLK HS2_CLK SD-Conn
#include "PCF8574.h" // PCF8574 library @ 2.3.7
#define PCF_INTERRUPT 0 // IO0 GPIO0 CAM_PIN_XCLK or CSI_MCLK (Interrupt pin for Encoder & Switch)
// Pre-formatted Header for the Interrupt (See initialization of updateEncoder Interrupt Below),
// necessary because of the Interrupt initialization in the next line
void IRAM_ATTR updateEncoder(); // ! *** IRAM_ATTR because this is the ISR !!!
// Initialize PCF-library Interrupt
PCF8574 pcf8574(0x38, PCF_INTERRUPT, updateEncoder); // for Default I2C Pins
Result:
- Init pcf8574…begin(sda, scl) -> 21 22
- Using interrupt pin (not all pins support interrupts)
- STATUS –> 4
- NOT OK <== Wrong SDA and SCL port
After Change
#include <Wire.h>
#define SCL 15 // IO15 GPIO15 HSPI_WSO HS2_CMD SD-Conn
#define SDA 14 // IO14 GPIO14 HSPI_CLK HS2_CLK SD-Conn
#include "PCF8574.h" // PCF8574 library @ 2.3.7
#define PCF_INTERRUPT 0 // IO0 GPIO0 CAM_PIN_XCLK or CSI_MCLK (Interrupt pin for Encoder & Switch)
// Pre-formatted Header for the Interrupt (See initialization of updateEncoder Interrupt Below),
// necessary because of the Interrupt initialization in the next line
void IRAM_ATTR updateEncoder(); // ! *** IRAM_ATTR because this is the ISR !!!
// Initialize PCF-library SDA & SCL
PCF8574 pcf8574(0x38, SDA, SCL);
Question: How to also setup the PCF_INTERRUPT?
Result:
- Init pcf8574…begin(sda, scl) -> 14 15 <== This is OK now
- But also need the Interrupt setup. How to do this?
- STATUS –> 4
- NOT OK <== Why is it still showing NOT OK?