Site icon Renzo Mischianti

Can’t get PCF8574 lib working on Wio Terminal

Hello again @xreef, thank you for providing this library. I'm just trying to get the PCF8574 library working with Seeed Wio Terminal, but it doesn't work ( doesn't return from pcf8574.begin() ). I have tried other I2C devices on the Wio Terminal and everything works. https://github.com/RoSchmi/PlatformIO/tree/master/Proj/Wio_Terminal_M5Stack_ENV_Hat_Test So I think that I have used the correct pins. I have also set up your example code on an Arduino Nano and it works. So I think that I have used the correct address for my PCF8574. Before trying to set up oscilloscope and logic analyzer I wand to ask if you already know a reason why it doesn't work. Here is the example code I'm using:

#include "Arduino.h"
#include "PCF8574.h"

// Set i2c address
//PCF8574 pcf8574(0x39); // For PCF8574A
PCF8574 pcf8574(0x20); // For PCF8574

void setup()
{
Serial.begin(9600);
while(!Serial);
delay(1000);
Serial.println("Starting...");

// Set pinMode to OUTPUT
pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P1, INPUT);

Serial.print("Init pcf8574...");
if (pcf8574.begin()){
Serial.println("OK");
}else{
Serial.println("KO");
}
}

void loop()
{
pcf8574.digitalWrite(P0, HIGH);
delay(1000);
pcf8574.digitalWrite(P0, LOW);
delay(1000);
}
Thanks in advance RoSchmi
Exit mobile version