06-30-2023, 02:38 PM
(06-30-2023, 12:16 PM)admin Wrote: A16 need to chanage code.
https://github.com/HomeSpan/HomeSpan/discussions/394
I tried with this 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 "DEV_LED.h"
PCF8574 pcfIN_1(0x14,15,14);
PCF8574 pcfIN_2(0x31,15,14);
PCF8574 pcfOUT_1(0x16,15,14);
PCF8574 pcfOUT_2(0x32,15,14);
void pcf_init(){
pcfIN_1.pinMode(0, INPUT);
pcfIN_1.pinMode(1, INPUT);
pcfIN_1.pinMode(2, INPUT);
pcfIN_1.pinMode(3, INPUT);
pcfIN_1.pinMode(4, INPUT);
pcfIN_1.pinMode(5, INPUT);
pcfIN_1.pinMode(6, INPUT);
pcfIN_1.pinMode(7, INPUT);
pcfIN_2.pinMode(0, INPUT);
pcfIN_2.pinMode(1, INPUT);
pcfIN_2.pinMode(2, INPUT);
pcfIN_2.pinMode(3, INPUT);
pcfIN_2.pinMode(4, INPUT);
pcfIN_2.pinMode(5, INPUT);
pcfIN_2.pinMode(6, INPUT);
pcfIN_2.pinMode(7, INPUT);
pcfOUT_1.pinMode(0, OUTPUT);
pcfOUT_1.pinMode(1, OUTPUT);
pcfOUT_1.pinMode(2, OUTPUT);
pcfOUT_1.pinMode(3, OUTPUT);
pcfOUT_1.pinMode(4, OUTPUT);
pcfOUT_1.pinMode(5, OUTPUT);
pcfOUT_1.pinMode(6, OUTPUT);
pcfOUT_1.pinMode(7, OUTPUT);
pcfOUT_2.pinMode(0, OUTPUT);
pcfOUT_2.pinMode(1, OUTPUT);
pcfOUT_2.pinMode(2, OUTPUT);
pcfOUT_2.pinMode(3, OUTPUT);
pcfOUT_2.pinMode(4, OUTPUT);
pcfOUT_2.pinMode(5, OUTPUT);
pcfOUT_2.pinMode(6, OUTPUT);
pcfOUT_2.pinMode(7, OUTPUT);
if (pcfIN_1.begin()) {
Serial.println("pcfIN_1_OK");
}
else{
Serial.println("pcfIN_1_ERROR");
}
if (pcfIN_2.begin()) {
Serial.println("pcfIN_2_OK");
}
else{
Serial.println("pcfIN_2_ERROR");
}
if (pcfOUT_1.begin()) {
Serial.println("pcfOUT_1_OK");
}
else{
Serial.println("pcfOUT_1_ERROR");
}
if (pcfOUT_2.begin()) {
Serial.println("pcfOUT_2_OK");
}
else{
Serial.println("pcfOUT_2_ERROR");
}
}
void setup() {
Serial.begin(115200);
delay(200);
pcf_init();
homeSpan.begin(Category::Bridges,"HomeSpan Bridge");
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED1");
new DEV_DimmableLED(RELAY1,INPUT1);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED2");
new DEV_DimmableLED(RELAY2,INPUT2);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED3");
new DEV_DimmableLED(RELAY3,INPUT3);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED4");
new DEV_DimmableLED(RELAY4,INPUT4);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED5");
new DEV_DimmableLED(RELAY5,INPUT5);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED6");
new DEV_DimmableLED(RELAY6,INPUT6);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED7");
new DEV_DimmableLED(RELAY7,INPUT7);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED8");
new DEV_DimmableLED(RELAY8,INPUT8);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED9");
new DEV_DimmableLED(RELAY9,INPUT9);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED10");
new DEV_DimmableLED(RELAY10,INPUT10);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED11");
new DEV_DimmableLED(RELAY11,INPUT11);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED12");
new DEV_DimmableLED(RELAY12,INPUT12);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED13");
new DEV_DimmableLED(RELAY13,INPUT13);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED14");
new DEV_DimmableLED(RELAY14,INPUT14);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED15");
new DEV_DimmableLED(RELAY15,INPUT15);
///////////////////
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("LED16");
new DEV_DimmableLED(RELAY16,INPUT16);
} // end of setup()
//////////////////////////////////////
void loop(){
homeSpan.poll();
} // end of loop()
But it doesn't work (i managed to connect the board to homekit, but the status leds don't turn on). What am i doing wrong? i also tried wit addresses 0x21, 0x22, 0x24 and 0x25 for inputs and outputs