Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Arduino IDE demo source code for KC868-A64]--#05-PCF8575_Input_code
#1
Bug 
[Arduino IDE demo source code for KC868-A64]--#05-PCF8575_Input_code
   

Code:
/*www.kinocny.com */
/*KC868-A64 CODE OF PCF8575 READ INPUT*/

#include "Arduino.h"
#include "PCF8575.h"

// Set i2c address
PCF8575 pcf8575_IN1(0x24,15,4);
PCF8575 pcf8575_IN2(0x25,15,4);
PCF8575 pcf8575_IN3(0x21,15,4);
PCF8575 pcf8575_IN4(0x22,15,4);

void setup()
{
    Serial.begin(115200);
  pcf8575_IN1.begin();
  pcf8575_IN2.begin();
  pcf8575_IN3.begin();
  pcf8575_IN4.begin();
for(int i=0;i<16;i++)
{
  pcf8575_IN1.pinMode(i,INPUT);
  pcf8575_IN2.pinMode(i,INPUT);
  pcf8575_IN3.pinMode(i,INPUT);
  pcf8575_IN4.pinMode(i,INPUT);
}

  Serial.println("KC868-A64 64 channel input state 0:ON  1:OFF");
}

void loop()
{
  uint16_t var_1 = 0;
  uint16_t var_2 = 0;
  uint16_t var_3 = 0;
  uint16_t var_4 = 0;
  var_1 = pcf8575_IN1.digitalReadAll();
  var_2 = pcf8575_IN2.digitalReadAll();
  var_3 = pcf8575_IN3.digitalReadAll();
  var_4 = pcf8575_IN4.digitalReadAll();
/* Detect IN1-IN16  If triggered print "KEY i PRESSED"  */
  for(int i=0;i<16;i++)
  {
    if((var_1>>i&1)==0)
    {
     Serial.print("KEY ");
     Serial.print(i+1);
     Serial.println(" PRESSED");
    }
  }
/* Detect IN17-IN32  If triggered print "KEY i PRESSED"  */
  for(int i=0;i<16;i++)
  {

    if((var_2>>i&1)==0)
    {
     Serial.print("KEY ");
     Serial.print(i+17);
     Serial.println(" PRESSED");
   }
  }
/* Detect IN33-IN48  If triggered print "KEY i PRESSED"  */
for(int i=0;i<16;i++)
  {
    if((var_3>>i&1)==0)
    {
     Serial.print("KEY ");
     Serial.print(i+33);
     Serial.println(" PRESSED");
   }
  }
/* Detect IN49-IN64  If triggered print "KEY i PRESSED"  */
   for(int i=0;i<16;i++)
  {

    if((var_4>>i&1)==0)
    {
     Serial.print("KEY ");
     Serial.print(i+49);
     Serial.println(" PRESSED");
    }
  }
delay(100);
}

   
you should install the library PCF8575 library
   
Before Upload the code ,you should find the PCF8575.h  in PCF8575 Library file,and enable the the code in below picture
   


Attached Files
.zip   KC868-A64-PCF8575-DI.zip (Size: 1.13 KB / Downloads: 326)
Reply
#2
Hello,
I have loaded the library PCF8575 by Renzo Mischianti like in the sample but the compilation abort :
C:\Users\regis\AppData\Local\Temp\f5fbfc26-b151-4eb0-8b55-51a854384440_KC868-A64-PCF8575-DI (2).zip.440\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI.ino: In function 'void loop()':
C:\Users\regis\AppData\Local\Temp\f5fbfc26-b151-4eb0-8b55-51a854384440_KC868-A64-PCF8575-DI (2).zip.440\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI.ino:37:38: error: cannot convert 'PCF8575:Big GrinigitalInput' to 'uint16_t' {aka 'short unsigned int'} in assignment
var_1 = pcf8575_IN1.digitalReadAll();
^
C:\Users\regis\AppData\Local\Temp\f5fbfc26-b151-4eb0-8b55-51a854384440_KC868-A64-PCF8575-DI (2).zip.440\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI.ino:38:38: error: cannot convert 'PCF8575:Big GrinigitalInput' to 'uint16_t' {aka 'short unsigned int'} in assignment
var_2 = pcf8575_IN2.digitalReadAll();
^
C:\Users\regis\AppData\Local\Temp\f5fbfc26-b151-4eb0-8b55-51a854384440_KC868-A64-PCF8575-DI (2).zip.440\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI.ino:39:38: error: cannot convert 'PCF8575:Big GrinigitalInput' to 'uint16_t' {aka 'short unsigned int'} in assignment
var_3 = pcf8575_IN3.digitalReadAll();
^
C:\Users\regis\AppData\Local\Temp\f5fbfc26-b151-4eb0-8b55-51a854384440_KC868-A64-PCF8575-DI (2).zip.440\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI\KC868-A64-PCF8575-DI.ino:40:38: error: cannot convert 'PCF8575:Big GrinigitalInput' to 'uint16_t' {aka 'short unsigned int'} in assignment
var_4 = pcf8575_IN4.digitalReadAll();
^

exit status 1

Compilation error: cannot convert 'PCF8575:Big GrinigitalInput' to 'uint16_t' {aka 'short unsigned int'} in assignment

Can you help ?
Reply
#3
Hi, 

Can you help me, i can't go on because  am stopped

I tried the demo code for A64 you recommande, but it doesn't work. After transfering code, the A64 doesn't work (impossible to connect on his IP adress, light of ethernet connection off).

So, I  try to use a very simple code, as below, but it doesn't work too, the A64 stopped,; I need to download firmaware again. I used as you recommande board NODEMCA-32S. 
Code 

#include "Arduino.h"
void setup() {
  // put your setup code here, to run once:
}
void loop() {
  // put your main code here, to run repeatedly:
}

Le croquis utilise 230493 octets (17%) de l'espace de stockage de programmes. Le maximum est de 1310720 octets.
Les variables globales utilisent 20968 octets (6%) de mémoire dynamique, ce qui laisse 306712 octets pour les variables locales. Le maximum est de 327680 octets.
esptool.py v4.5.1
Serial port COM3
Connecting....
Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d4:d4:da:e1:1e:38
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00048fff...
Compressed 17568 bytes to 12204...
Writing at 0x00001000... (100 %)
Wrote 17568 bytes (12204 compressed) at 0x00001000 in 0.5 seconds (effective 278.3 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 282.9 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.2 seconds (effective 414.9 kbit/s)...
Hash of data verified.
Compressed 230864 bytes to 127838...
Writing at 0x00010000... (12 %)
Writing at 0x0001e038... (25 %)
Writing at 0x000237a7... (37 %)
Writing at 0x00028af6... (50 %)
Writing at 0x0002dfc9... (62 %)
Writing at 0x000364d8... (75 %)
Writing at 0x0003e6aa... (87 %)
Writing at 0x00043ca0... (100 %)
Wrote 230864 bytes (127838 compressed) at 0x00010000 in 2.5 seconds (effective 744.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Reply
#4
if you download KCS firmware, whether work well?
Reply
#5
No, I used KCS firmware version KCS_KC868_A64_V2.0.8 and the latest KCS_KC868_A64_V2.1.1 but it doesn't work, same problem, after download very simple Arduino code (see above) the left of the ethernet connector stop blinking and light off, all the board is stopped.
With TUYA , these firmware work well, but I need using ARDUINO coding because TUYA is too limited for what I need to use.
Do you think the bugg will be quickly fixed ?
Best regards
Reply
#6
how you download firmware of KCS? can you take a screen photo of setting, upload at here.
Reply
#7
(11-01-2023, 10:34 PM)admin Wrote: how you download firmware of KCS? can you take a screen photo of setting, upload at here.

Attached the screen shots + the screen shot with TUYA that correctly work . 

I tried also to download with the adress 0x010000 (seen on one of yours documents), but also doesn't work


Attached Files Image(s)
               
Reply
#8
download KCS firmware, address is 0x0
if can't download. lower your COM port Baud rate.
Reply
#9
Sorry I don't understand, can you give me the link for the "KCS firmware" you mean ?
Reply
#10
https://www.kincony.com/forum/showthread.php?tid=3330
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)