Reading PCF8575C Expander Inputs

Hello, dear Arduino community. I have bought the pcf8575c to expand arduino uno pins. The pins works great, when i use them in output mode. But when i'am trying to read inputs, i always get '0' value. Can you please help me ? I tried so many libraries from github, but without results.

In attacment:
A photo of expander
Values, reading by pcf8575c from Sr-501 motion sensor
Values, reading by arduino UNO from Sr-501 motion sensor
A code of simple project, where i am trying to read inputs from SR501 motion sensor. (The library in project is PCF8575 by phisman from github)

#include <Wire.h>
#include <PCF8575.h>
PCF8575 expander;
void setup()
{
  //Wire.begin();
  Serial.begin(9600);
  expander.begin(0x20);
  expander.pinMode(P0,INPUT);
}
 
void loop()
{
  Serial.println(expander.digitalRead(P0));
  delay(200);

}

Missing:

  • Diagram of how you have connected everything together.
  • Explanation of what you read when you manually connect the relevant expander pin to Vcc and then ground.

from the datasheet:

It also possesses an interrupt line (INT) which can be connected to the interrupt logic of the microcontroller. By sending an interrupt signal on this line, the remote I/O can inform the microcontroller if there is incoming data on its ports without having to communicate via the I2C-bus.

see this: Using-The-PCF8575-i2c-io-Expander-To-Read-Inputs

It is important to remember that the pins are only quasi-bidirectional I/O, not actually bidirectional I/O.

To use any pin as an input you first have to write a logic HIGH to it, and then read the pin. The pin will only read something different from a logic HIGH if you connect it to ground through a switch, or other logic level signal.

So it matters how you have connected your switches, it needs to be from input to ground.

I have never used a libiary to control something as simple as this chip so I can't comment on how to get your libiary to do this.