Smart Home Automation Forum
PCF8574 - begin() throws error - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=1)
+--- Forum: KC868-A series and Uair Smart Controller (https://www.kincony.com/forum/forumdisplay.php?fid=6)
+--- Thread: PCF8574 - begin() throws error (/showthread.php?tid=1968)



PCF8574 - begin() throws error - staehla - 06-06-2022

Hi all,

i am pretty new to ESP32 and programming with Arduion IDE. I have purchased a KC868-A8-V1.4 board and now i wanted to do the Realy programming according to the instruction from your site KC868-A8 programming
Correct type of board is selected NodeMCU-32S and the pins in pins_arduino.h are changed to 4 + 5, PCF8574 library V2.3.1 from Renzo Mischianti is installed.
The problem i am facing is that the PCF8574 throws all the time "error" instead of "OK" and therefore the relays are not working.

In order to test whether the board has a hardware problem, I have also tried once the TASMATO accoring to the video Tasmato KC868-A8, this has worked without any problems. So the hardware is ok.

Do you know what i am doing wrong that the PCF8574 throws the error?

Any help would be appreaciated

Used code:
PHP Code:
/*
Kincony KC868-A8
Relays example
*/
 
#include "Arduino.h"
#include "PCF8574.h"
 
#define I2C_RELAYS_ADR 0x24
PCF8574 pcf(I2C_RELAYS_ADR);

void setup() {
  Serial.begin(115200);
  Serial.println(F("Start Kincony KC868-A8 Relays example…"));
  pcf.pinMode(P0OUTPUT);
  pcf.pinMode(P1OUTPUT);
  pcf.pinMode(P2OUTPUT);
  pcf.pinMode(P3OUTPUT);
  pcf.pinMode(P4OUTPUT);
  pcf.pinMode(P5OUTPUT);
  pcf.pinMode(P6OUTPUT);
  pcf.pinMode(P7OUTPUT);
  Serial.print("Init PCF8574… ");
  if (pcf.begin()){
    Serial.println(F("Ok"));
  }else {
    Serial.println(F("Error"));}
}

void loop() {
  pcf.digitalWrite(P0HIGH);
  Serial.print(F("Relay #")); Serial.print(P0); Serial.println(F(" ON"));
  delay(10000);
  pcf.digitalWrite(P0LOW);
  Serial.print(F("Relay #")); Serial.print(P0); Serial.println(F(" OFF"));
  delay(10000);




RE: PCF8574 - begin() throws error - admin - 06-07-2022

because you have not define the IIC bus for SDA , SCL pins in config file.


RE: PCF8574 - begin() throws error - staehla - 06-07-2022

(06-07-2022, 01:37 AM)admin Wrote: because you have not define the IIC bus for SDA , SCL pins in config file.

Hi admin,

Thank you for your answer but I have done this already.
I have now figure it out what the problem was, it does not work with esp32 version higher than 2.0.0. With version 2.0.0 and lower it works.


RE: PCF8574 - begin() throws error - admin - 06-07-2022

maybe is pcf8574 library's compatibility problem.