I2C RTC and BV4206

I have built a small circuit to add a RTC and 15 extra i/o ports.

It all works fine but I cannot get the read digital pin section working, I have removed the RTC stuff from the sketch.

This is my current code and I think that the issue is with the digitalReadI2C(int pin) function.

#include "Wire.h"
#define I2C_ADDRESS_BV4206 0x10  // This is the I2C address
#define pinIn 0x01       
#define pinOut 0x00       

void digitalPinmodeI2C(int pin, int value){
  Wire.beginTransmission(I2C_ADDRESS_BV4206);  
  Wire.send(0x01);               //set pin mode command
  Wire.send(pin);                 //the digital output id
  Wire.send(value);  
  Wire.endTransmission();     
}

void digitalWriteI2C(int pin, int value){
    Wire.beginTransmission(I2C_ADDRESS_BV4206);   
    Wire.send(0x02);          //set output command
    Wire.send(pin);           //send pin number
    Wire.send(value);  
    Wire.endTransmission();     
}

boolean digitalReadI2C(int pin){
    Wire.beginTransmission(I2C_ADDRESS_BV4206);
    Wire.send(0x03);         //set read command
    Wire.send(pin);          //send pin number
    if (Wire.receive()==0x01){return true;} else {return false;}
    Wire.endTransmission();  
}

void setup() {
  Wire.begin();
  Serial.begin(9600);
    
  /** For BV4206 GPIO Devices **/
  //change address from default (0x21) to 0x10
  Wire.beginTransmission(0x21);  // join I2C, talk to BV4206 by id
  Wire.send(0x99);   //change address command
  Wire.send(I2C_ADDRESS_BV4206 << 1);  //new address (7 bit)
  Wire.send(0x55);  //check code - do not change
  Wire.send(0xaa);  //double check code - do not change
  Wire.send(0x21 << 1);  //current address (7 bit)
  Wire.endTransmission();      // leave I2C bus
  
  //set pin IO modes
  digitalPinmodeI2C(0,pinOut);
  digitalPinmodeI2C(1,pinIn);
  digitalPinmodeI2C(2,pinIn);
}

void loop() {
  
  //set output 0 of BV4206 to high
  Serial.println("BV4206 value set HIGH");
  digitalWriteI2C(0,1);
  
  delay(200);
    
  //set output 0 low
  Serial.println("BV4206 value set LOW");
  digitalWriteI2C(0,0);
 
  delay(200);
 
  //read input 1 of BV4206
  Serial.print("BV4206 reading values at 1 =");
  if (digitalReadI2C(1)==true){Serial.println("HI"); } else {Serial.println("LOW"); }
 
  //read input 2 of BV4206
  Serial.print("BV4206 reading values at 2 =");
  if (digitalReadI2C(2)==true){Serial.println("HI"); } else {Serial.println("LOW"); }

  Serial.println(""); 
}

Think the read code should be :

boolean digitalReadI2C(int pin)
{
  Wire.beginTransmission(I2C_ADDRESS_BV4206);
  Wire.send(0x03);         //set read command
  Wire.send(pin);          //send pin number
  Wire.endTransmission();  

  Wire.requestFrom(I2C_ADDRESS_BV4206, 1);
  return Wire.receive() ;  //  0 = false; anything else = true
}