Hey Paul,
Thank you for the reply!
You have probably fried the chip, or at least that pin, because you have not understood how this chip works.
Thankfully I have a few on hand to continue testing with! Just before typing this and to elimate this doubt, I opened the package for the third one and soldered in the header pins. Same issue persisted.
To use a pin as an input on the pcf chip, you must write a 1 to it, making it output a (weak) HIGH. A circuit connected to it can then pull it low or not (e.g. a switch/button).
I understand, but I didn't see this covered in any of the example sketches? I also tried this, but it didn't yield the expected results. The exact coding is below. I even included a heartbeat to make sure I wasn't missing anything. Even with this new third 8575 and this slightly modified example sketch, a 1kohm resistor tied to 3.3v directly (I literally only have the cables running between the Wemos D1 and the 8575, to eliminate all other possible interference) will not pull up the pin.
(Note, I've soldered the address pads to ground (and can read inputs), so its not the possibility of another address. )
#include "Arduino.h"
#include "PCF8575.h"
// Set i2c address
PCF8575 pcf8575(0x20);
unsigned long timeElapsed;
void setup()
{
Serial.begin(115200);
pcf8575.pinMode(P1, INPUT);
pcf8575.begin();
Serial.println("Start");
}
void loop()
{
pcf8575.digitalWrite(P1, HIGH);
uint8_t val = pcf8575.digitalRead(P1);
if (val==HIGH) Serial.println("KEY PRESSED");
delay(100);
Serial.print(".");
}
This chip will happily run at 3.3V, so a level shifter is not needed. The chip will only output 3.3V, of course. Do you need it to output 5V for some reason?
It works out best for my application, since there's a few other things that need 5v.
One last thing, the datasheet you referenced is a Ti datasheet, this is a NXP chip. Im not sure how much that matters? Honestly, I'm considering that these are just counterfeit chips, writing it off as a hardware failure and sourcing different ones.