Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
USE PCF8574 FOR ESP32 INPUT PORTS
#1
USE PCF8574 IIC EXTEND GPIO FOR ESP32 INPUT PORTS
Hello, 

I am very new working with Kincony 868 A8

I have downloaded the instructions from lesson 20 for installing input ports and copied them in e new sketch.
 
After uploading I see that all 8 Inports give "pressed key", continiously. Making contact between ground and 1 port (1 to 8) give no change. 
The serial monitor stays announcing all ports "pressed key".
 
Type : Kincony 868 A8 V1.5
Thanks
What is wrong?
Reply
#2
you can use this arduino demo code for PCF8574 INPUT function test: https://www.kincony.com/forum/showthread.php?tid=1609
here are all source code for KC868-A8: https://www.kincony.com/forum/forumdisplay.php?fid=23 see this zone is correct.
Reply
#3
Hello, it was that what I have done first time. I installed and loaded up 8574-DI but the result is that all 8 buttons stays continiously on "pressed button"
Reply
#4
do you have defined IIC pins in arduino config file. you'd better upload screen error image.
Reply
#5
Hello, there is no error message. The screen shows every 0,3 sec for all 8 relais :"Key 1...8 pressed". You can only stop the text by switching out the power.

Hello, I have tried again. The serial monitor writes :
Init pcf8574...OK
KEY1 PRESSED
KEY2 PRESSED.....
KEY8 PRESSED
KEY2 PRESSED
KEY2 PRESSED..... continiously


IC adress in sketch :
PCF8574 pcf8574(0x22,4,5)
I made a copy of the download 8574-DI...
Reply
#6
post your code, i will test on your code by KC868-A8.
Reply
#7
/*
KeyPressed on PIN1
by Mischianti Renzo <http://www.mischianti.org>

https://www.mischianti.org/2019/01/02/pc...asy-usage/
*/

#include "Arduino.h"
#include "PCF8574.h"

// Set i2c address
PCF8574 pcf8574(0x22,4,5);
unsigned long timeElapsed;
void setup()
{
Serial.begin(115200);
delay(1000);

// pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P0, INPUT);
pcf8574.pinMode(P1, INPUT);
pcf8574.pinMode(P2, INPUT);
pcf8574.pinMode(P3, INPUT);
pcf8574.pinMode(P4, INPUT);
pcf8574.pinMode(P5, INPUT);
pcf8574.pinMode(P6, INPUT);
pcf8574.pinMode(P7, INPUT);

Serial.print("Init pcf8574...");
if (pcf8574.begin()){
Serial.println("OK");
}else{
Serial.println("KO");
}
}

void loop()
{
uint8_t val1 = pcf8574.digitalRead(P0);
uint8_t val2 = pcf8574.digitalRead(P1);
uint8_t val3 = pcf8574.digitalRead(P2);
uint8_t val4 = pcf8574.digitalRead(P3);
uint8_t val5 = pcf8574.digitalRead(P4);
uint8_t val6 = pcf8574.digitalRead(P5);
uint8_t val7 = pcf8574.digitalRead(P6);
uint8_t val8 = pcf8574.digitalRead(P7);
if (val1==LOW) Serial.println("KEY1 PRESSED");
if (val2==LOW) Serial.println("KEY2 PRESSED");
if (val3==LOW) Serial.println("KEY3 PRESSED");
if (val4==LOW) Serial.println("KEY4 PRESSED");
if (val5==LOW) Serial.println("KEY5 PRESSED");
if (val6==LOW) Serial.println("KEY6 PRESSED");
if (val7==LOW) Serial.println("KEY7 PRESSED");
if (val8==LOW) Serial.println("KEY8 PRESSED");
delay(300);
}


Attached Files Image(s)
       
Reply
#8
Hello,

As nobody finds the reason and as you can see that the result is as 2 is closed without a connection between ground and input 2 there must be a electrical short circuit in the Kincony A8!

It is the second failure of a Kincony A8 on two peaces.

Kind regards
Reply
#9
this code is work fine, but you have changed, so your board not work well.

.zip   8574-DI.zip (Size: 650 bytes / Downloads: 146)
NOT use " PCF8574 pcf8574(0x22,4,5); "    our code is "PCF8574 pcf8574(0x22);"
I have told you need set pin define in your arduino config file:
we use NodeMcu-32S board, so do as these photos will be work fine:
   
   
   
Reply
#10
Hello,

thanks for your help, but the same result as before. Key 2 is always closed.

An other question : instead of KC868 A8 do there exist also one with 10 or 12 relais? Or can you connect 2 more relays on the KC868 A8?

Kind regards.
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)