Sebastian584
I added the following code in the “Arduino extension” section of the IDE:
//////////////////////////////// sketch section ////////////////////////////////

#include <Adafruit_PCF8574.h>

Adafruit_PCF8574 pcf_DI;
Adafruit_PCF8574 pcf_DO;

void sketch_setup()
{
    pcf_DI.begin(0x21, &Wire); // I2C address for digital inputs
    pcf_DO.begin(0x20, &Wire); // I2C address for digital outputs

    pcf_DI.pinMode(0, INPUT);
    pcf_DI.pinMode(1, INPUT);
    pcf_DI.pinMode(2, INPUT);
    pcf_DI.pinMode(3, INPUT);
    pcf_DI.pinMode(4, INPUT);
    pcf_DI.pinMode(5, INPUT);

    pcf_DO.pinMode(0, OUTPUT);
    pcf_DO.pinMode(1, OUTPUT);
    pcf_DO.pinMode(2, OUTPUT);
    pcf_DO.pinMode(3, OUTPUT);
    pcf_DO.pinMode(4, OUTPUT);
    pcf_DO.pinMode(5, OUTPUT);
}

void sketch_loop()
{
    ED1 = pcf_DI.digitalRead(0);
    ED2 = pcf_DI.digitalRead(1);
    ED3 = pcf_DI.digitalRead(2);
    ED4 = pcf_DI.digitalRead(3);
    ED5 = pcf_DI.digitalRead(4);  
    ED6 = pcf_DI.digitalRead(5);  

    pcf_DO.digitalWrite(0, SD1);
    pcf_DO.digitalWrite(1, SD2);
    pcf_DO.digitalWrite(2, SD3);
    pcf_DO.digitalWrite(3, SD4);
    pcf_DO.digitalWrite(4, SD5);
    pcf_DO.digitalWrite(5, SD6);
}
 
The IDE shows that the following libraries were used:

Used library     Version Path
src                      C:\Users\carlo\OpenPLC_Editor\editor\arduino\src
WiFi             3.3.0   C:\Users\carlo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\libraries\WiFi
Networking       3.3.0   C:\Users\carlo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\libraries\Network
Adafruit PCF8574 1.1.2   C:\Users\carlo\OneDrive\Documentos\Arduino\libraries\Adafruit_PCF8574
Adafruit BusIO   1.17.4  C:\Users\carlo\OneDrive\Documentos\Arduino\libraries\Adafruit_BusIO
Wire             3.3.0   C:\Users\carlo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\libraries\Wire
SPI              3.3.0   C:\Users\carlo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\libraries\SPI
 
Any ideas why OpenPLC fails to compile when using the PCF8574 with the ESP32?
Reply 0 0
thiagoralves
No idea, especially without knowing what was the compilation error and the compilation logs...
Reply 0 0
Reply