Using a pfc8574 I2C

Hello,

I tried to use a PFC8574 I2C by doing as described on this page, but it does not seem to work.

I have tried changing the address but without any luck.

I also added debug code so that it write back to the serial line what it is doing.

Any suggestions?

Here is my code:

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

const int iCtrlLed = 8;

// Set i2c address
//uint8_t sdaPin = 4;
//uint8_t sclPin = 5;
PCF8574 pcf8574(0x20);
 
void setup()
{
  Serial.begin(9600);
 
  // Set pinMode to OUTPUT
  for (int i = 0; i < 8; i++) {
    pcf8574.pinMode(i, OUTPUT);
  }
  pcf8574.begin();

  pinMode(iCtrlLed, OUTPUT);
  digitalWrite(iCtrlLed, LOW);
}

void loop()
{
  static int  pin = 0;
  char        buffer[20];

  sprintf(buffer, "Pin: %d\n", pin);
  Serial.print(buffer);
  digitalWrite(iCtrlLed, HIGH);
  pcf8574.digitalWrite(pin, HIGH);
  delay(1000);

  digitalWrite(iCtrlLed, LOW);
  pcf8574.digitalWrite(pin, LOW);
  delay(1000);

  pin++;
  if (pin > 7) {
    pin = 0;
  }
}

Additional information:

Board info:
BN: Arduino/Genuino Uno
VID: 0x2341
PID: 0x0043
SN: 55834323333351104112

Using a PFE8574 based module bought from aliexpress. Got 4 of them and have tried them all - same result. All LEDs are on all the time. The chip is labeled "PFE8574T" and the A0, A1 and A2 pins are set to LOW.

I tried to run the i2c_scanner sketch and it reported "No I2C devices found".

Solved it. Turned out to be a wire with bad connection.