Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[KC868-A16] Problem with PCF8574 I/O
#1
Hello, i'm tryng to read inputs from the PCF8574 channels. This is my code:

Code:
//Apple Homekit for KC868-E16S/KC868-E16T
//first time to use: use serial port send "W" to config wifi ssid and password
//if you want to eraser all data, re-config, use serial port send "E"
//default qrcode is 46637726

#include "HomeSpan.h"
#include "PCF8574.h"

PCF8574 pcfInLeft(0x22);

void pcfInit(){
 
  pcfInLeft.pinMode(P0, INPUT);
  pcfInLeft.pinMode(P1, INPUT);
  pcfInLeft.pinMode(P2, INPUT);
  pcfInLeft.pinMode(P3, INPUT);
  pcfInLeft.pinMode(P4, INPUT);
  pcfInLeft.pinMode(P5, INPUT);
  pcfInLeft.pinMode(P6, INPUT);
  pcfInLeft.pinMode(P7, INPUT);
 
  if (pcfInLeft.begin()) {
    Serial.println("pcf OK");
  }
  else{
    Serial.println("pcf ERROR");
  }

}

void setup() {
 
  Serial.begin(115200);

  delay(1000);

  pcfInit();     

} // end of setup()

//////////////////////////////////////

void loop(){

  uint8_t in0 = pcfInLeft.digitalRead(P0);
  Serial.println("in0");
  Serial.println(in0);
  uint8_t in1 = pcfInLeft.digitalRead(P1);
  Serial.println("in1");
  Serial.println(in1);
  uint8_t in2 = pcfInLeft.digitalRead(P2);
  Serial.println("in2");
  Serial.println(in2);
  uint8_t in3 = pcfInLeft.digitalRead(P3);
  Serial.println("in3");
  Serial.println(in3);
  uint8_t in4 = pcfInLeft.digitalRead(P4);
  Serial.println("in4");
  Serial.println(in4);
  uint8_t in5 = pcfInLeft.digitalRead(P5);
  Serial.println("in5");
  Serial.println(in5);
  uint8_t in6 = pcfInLeft.digitalRead(P6);
  Serial.println("in6");
  Serial.println(in6);
  uint8_t in7 = pcfInLeft.digitalRead(P7);
  Serial.println("in7");
  Serial.println(in7);

  delay(1000);
 
} // end of loop()

But the method  pcfInLeft.begin() always returns false and the inputs are always read as off. What's wrong?

Thanks in advance

I forgot to mention that the KCS software knows when the inputs go on, so it's not a wiring-related problem
Reply


Messages In This Thread
[KC868-A16] Problem with PCF8574 I/O - by alessiovietri - 07-04-2023, 12:59 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)