Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to connect SMOKE DETECTOR SENSOR with KC868-A64?
#11
In Definition:
PCF8575 pcf8575_in(0x24,15,4);
PCF8575 pcf8575_out(0x24,15,4);
In Setup:
for(int i=0;i<16;i++)
{
pcf8575_in.pinMode(i,INPUT);
}
pcf8575_in.begin();

for(int i=0;i<16;i++)
{
pcf8575_out.pinMode(i,OUTPUT);
}
pcf8575_out.begin();

I set i2c address for digital input like this: PCF8575 pcf8575_in(0x24,15,4);
and i2c address for relay output like this: PCF8575 pcf8575_out(0x24,15,4);
When I'm making all relay output pins to LOW with this:
for(int i=0;i<16;i++){
pcf8575_out.digitalWrite(i, LOW);
}
Its automatically making digital input pins to LOW as well in the loop:
for(int i=0;i<16;i++)
{
int piDigital = pcf8575_in.digitalRead(i); // read P(i)
if(piDigital==0)
{
Serial.print("KEY ");
Serial.print(i+1);
Serial.println(" PRESSED");
}
}

When I'm making all relay output pins to LOW, why is it making the digital input pins to LOW ?
Reply
#12
I set i2c address for digital input like this: PCF8575 pcf8575_in(0x24,15,4);
and i2c address for relay output like this: PCF8575 pcf8575_out(0x24,15,4);

WHY use same i2c address for INPUT and OUTPUT???
Reply
#13
As per the pin definition you shared: https://www.kincony.com/forum/showthread.php?tid=1903
Its showing same address (check: https://snipboard.io/VxU7rB.jpg) for digital input and relay output. What changes is needed in the definition?
Reply
#14
i have defined same i2c address, but do you see they use by different two i2c bus?
do you have define two i2c bus?
Reply
#15
I don't know how to define different i2c bus, I can't find in the library documentation: https://github.com/xreef/PCF8575_library
I'm defining i2c bus for (relay1-16) like this PCF8575 pcf8575_out(0x24,15,4);
and I'm defining i2c bus for (DI1-16) like this PCF8575 pcf8575_in(0x24,15,4);

Is the 15,4 value need to be changed, what change is needed in the definition. Please help.

Don't you think i2c bus could be same for the relay and digital input pins as I did that definition of INPUT and OUTPUT in setup function:
for(int i=0;i<16;i++)
{
pcf8575_in.pinMode(i,INPUT);
}
pcf8575_in.begin();

for(int i=0;i<16;i++)
{
pcf8575_out.pinMode(i,OUTPUT);
}
pcf8575_out.begin();
Reply
#16
you can see the PCF8574 library guide, how to define two different i2c bus.
Reply
#17
But As per the documentation https://www.kincony.com/forum/showthread.php?tid=1903 , (relay1-16) and (DI1-16) are having same i2c address: 0x24
So Where am I wrong?
Reply
#18
IIC Bus-1:A

SDA-A:GPIO5
SCL-A:GPIO16

PCF8575:U143 (relay1-16): 100 100 = 0x24
PCF8575:U145 (relay17-32): 100 101 = 0x25
PCF8575:U147 (relay33-48): 100 001 = 0x21
PCF8575:U149 (relay49-64): 100 010 = 0x22

IIC Bus-2:B
SDA-B:GPIO15
SCL-B:GPIO4

PCF8575:U14 (DI1-16): 100 100 = 0x24
PCF8575:U31 (DI17-32): 100 101 = 0x25
PCF8575:U56 (DI33-48): 100 001 = 0x21
PCF8575:U57 (DI49-64): 100 010 = 0x22

do you see clearly? they use two different i2c bus! bus-1 and bus-2 you need to define two i2c bus pin define. if you don't know how to do , you can search by Google, how to define i2c bus in arduino IDE.
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)