Connecting I2C PCF8575C Expander

I have recently bought I2C PCF8575C expander board from SparkFun https://www.sparkfun.com/commerce/product_info.php?products_id=8130 and now trying to connect it without any luck.

I’ve tried different ways of connecting it, but unfortunately, non of my attempts made it work reliable :frowning:

This is how I’m trying to connect it:

And this is my sketch:

#include <Wire.h>

const int inputPins[] = { 2, 3, 4, 5 };
const int inputPinsLen = sizeof( inputPins )/sizeof( inputPins[0] );

void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);
  for( int i = 0; i < inputPinsLen; ++i )
    pinMode(inputPins[i], INPUT);      
  Wire.begin();
}

byte getMyStatus(){
  byte s = 0;
  for( int i = 0; i < inputPinsLen; ++i )
    s = ( s << 1 ) + digitalRead( inputPins[i] );

  Serial.print( "Status: " ); Serial.println( s, BIN );
  return s;
}

uint8_t step = 0;

void loop()                     // run over and over again
{
  byte s = 0;
  byte w = 0;
  if( step++%2 == 0 )
     w = 0xFF;
  
  expanderWrite( w, B0100000 );
  delay(10);

  Serial.print( "Wrote 0x" );
  Serial.println( w, HEX );
  getMyStatus();
  delay(1000);       
}

void expanderWrite(uint8_t _data, uint8_t expander ) {
  Wire.beginTransmission(expander);
  Wire.send(_data);
  Wire.send(_data);
  Wire.endTransmission();
}

Thanks to anyone who can shed some light on this issue.

I used a PCF8574 in my transistor tester circuit, full schematics and code at:-

http://www.thebox.myzen.co.uk/Hardware/Transistor_Tester.html

From your circuit 1K pull up resistors on the I2C lines look a bit small, I would use 4K7. Also be aware there are two types of this chip both with different base addresses. Also your circuit looks not to have connected up the external address lines (it is hard to see from the schematic what signals are what) or if you have, then they are going to +5v this will change the address from what you have in your code to an address with the three least significant bits as 1s.

Hi Mike,

Today, you've made my day!

I don't know why, but I was assuming that SparkFun board comes preconfigured with address set to 0 (all 3 addr pins tied to a ground) and did not checked it.

And of course that was my problem. After connecting address pins to ground, I'm able to see consistent result and my sketch work fine.

Thank you a lot!