Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,326
» Latest member: sarabhealthcare
» Forum threads: 3,635
» Forum posts: 18,771

Full Statistics

Online Users
There are currently 15 online users.
» 0 Member(s) | 6 Guest(s)
AhrefsBot, Amazonbot, Crawl, bot

Latest Threads
adaptor V2 and KC868 h32b...
Forum: KC868-ATC / Tuya adapter V2
Last Post: admin
4 hours ago
» Replies: 3
» Views: 43
Problems and general Feed...
Forum: N30
Last Post: admin
Yesterday, 11:58 PM
» Replies: 1
» Views: 7
N20 Problem with Home Ass...
Forum: N20
Last Post: admin
Yesterday, 11:57 PM
» Replies: 4
» Views: 19
Voltage for KC868-16
Forum: KC868-A16
Last Post: admin
Yesterday, 11:54 PM
» Replies: 1
» Views: 2
sample code to receive ht...
Forum: F16
Last Post: admin
Yesterday, 10:54 AM
» Replies: 8
» Views: 32
16-Channel Lighting Contr...
Forum: News
Last Post: admin
Yesterday, 10:52 AM
» Replies: 1
» Views: 10
OUTPUT DO1
Forum: KC868-AIO
Last Post: admin
Yesterday, 01:58 AM
» Replies: 3
» Views: 20
N30 Energy entry not work...
Forum: N30
Last Post: Vega
12-27-2025, 01:15 PM
» Replies: 13
» Views: 129
KC868-M16v2 configure yam...
Forum: KC868-M16 / M1 / MB / M30
Last Post: admin
12-27-2025, 08:45 AM
» Replies: 127
» Views: 25,362
Replacing ESP32 with Kinc...
Forum: KC868-A16
Last Post: admin
12-24-2025, 11:43 PM
» Replies: 1
» Views: 29

  KC868-A16 - Different digital Output modes
Posted by: oxedgar - 04-14-2023, 04:42 AM - Forum: DIY Project - Replies (8)

Hello, I try to get KCS-Firmware to work has i want...
I have one output to need to work in two modes ...
the first is  normal On-OFF toggle with one input triggered (this work fine)
The the second mode is to delayed this same output if i trigger another input (this do not work)

The result is to provide one wall button to ON Off Light and for the same light one motion PIR not temporised to work with specific delay set in this smart controller!
Can i make this with KCS firmware?

Print this item

  [Arduino source code for KC868-A8M]-06 RS485
Posted by: KinCony Support - 04-14-2023, 03:19 AM - Forum: KC868-A8M - Replies (6)

[Arduino source code for KC868-A8M]-06 RS485

Code:
#define A8M_RS485_RX 15
#define A8M_RS485_TX 13
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,A8M_RS485_RX,A8M_RS485_TX);//A8M
  Serial2.println("A8M RS485 SEND is OK!!"); 
}

void loop() {
  /*print the received data of RS485 port*/
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());//Read rs485 receive data  and print it
   }
  delay(200);
}



Attached Files
.zip   KC868-A8M_RS485.zip (Size: 596 bytes / Downloads: 548)
Print this item

  [Arduino source code for KC868-A8M]-05 OUTPUT
Posted by: KinCony Support - 04-14-2023, 03:16 AM - Forum: KC868-A8M - No Replies

Code:
#include "Arduino.h"
#include "PCF8574.h"

#define SDA 5
#define SCL 4

PCF8574 pcf8574_RE1(0x24,SDA,SCL);//DO
void setup()
{
    Serial.begin(115200);
for(int i=0;i<=7;i++)
{
   pcf8574_RE1.pinMode(i, OUTPUT);
}
   pcf8574_RE1.begin();

for(int i=0;i<=7;i++)
{
  pcf8574_RE1.digitalWrite(i, LOW);delay(200);
}
for(int i=0;i<=7;i++)
{
  pcf8574_RE1.digitalWrite(i, HIGH);delay(200);
}   
}

void loop()
{
  /******Output is all off by default, and can be turned
on or off manually when pressed by the keypad**************/
for(int i=0;i<=7;i++)
{
  pcf8574_RE1.digitalWrite(i, HIGH);delay(100);
}

}
[Arduino source code for KC868-A8M]-05 OUTPUT



Attached Files
.zip   KC868-A8M_OUTPUT.zip (Size: 664 bytes / Downloads: 489)
Print this item

  [Arduino source code for KC868-A8M]-04 LAN8720_UDP
Posted by: KinCony Support - 04-14-2023, 03:16 AM - Forum: KC868-A8M - No Replies

[Arduino source code for KC868-A8M]-04 LAN8720_UDP

Code:
#include <ETH.h>
#include <WiFiUdp.h>

#define ETH_ADDR        0
#define ETH_POWER_PIN  -1
#define ETH_MDC_PIN    23
#define ETH_MDIO_PIN   18   
#define ETH_TYPE       ETH_PHY_LAN8720
#define ETH_CLK_MODE   ETH_CLOCK_GPIO17_OUT

WiFiUDP Udp;                      //Create UDP object
unsigned int localUdpPort = 4196; //local port

// Set it based on the IP address of the router
IPAddress local_ip(192, 168, 1, 200);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192, 168, 1, 1);

void setup()
{
  Serial.begin(115200);
  Serial.println();
   
  ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE); //start with ETH

  // write confir for static IP, gateway,subnet,dns1,dns2
  if (ETH.config(local_ip, gateway, subnet, dns, dns) == false) {
    Serial.println("LAN8720 Configuration failed.");
  }else{Serial.println("LAN8720 Configuration success.");}
 
/* while(!((uint32_t)ETH.localIP())) //wait for IP
  {

  }*/
  Serial.println("Connected");
  Serial.print("IP Address:");
  Serial.println(ETH.localIP());

  Udp.begin(localUdpPort); //begin UDP listener
}

void loop()
{
  int packetSize = Udp.parsePacket(); //get package size
  if (packetSize)                     //if have received data
  {
    char buf[packetSize];
    Udp.read(buf, packetSize); //read current data

    Serial.println();
    Serial.print("Received: ");
    Serial.println(buf);
    Serial.print("From IP: ");
    Serial.println(Udp.remoteIP());
    Serial.print("From Port: ");
    Serial.println(Udp.remotePort());

    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); //ready to send data
    Udp.print("Received: ");   
    Udp.write((const uint8_t*)buf, packetSize); //copy data to sender buffer
    Udp.endPacket();            //send data
  }
}



Attached Files
.zip   KC868-A8M_LAN8720_UDP.zip (Size: 1.13 KB / Downloads: 500)
Print this item

  [Arduino source code for KC868-A8M]-03 INPUT
Posted by: KinCony Support - 04-14-2023, 03:15 AM - Forum: KC868-A8M - No Replies

Code:
/*KC868-A8M input trigger output*/
#include "Arduino.h"
#include "PCF8574.h"

#define SDA 5
#define SCL 4
// Set i2c address
PCF8574 pcf8574_IN1(0x22,SDA,SCL);
PCF8574 pcf8574_RE(0x24,SDA,SCL);
unsigned long timeElapsed;
void setup()
{
    Serial.begin(115200);
    delay(1000);
    pcf8574_RE.pinMode(P0, OUTPUT);
    pcf8574_RE.pinMode(P1, OUTPUT);
    pcf8574_RE.pinMode(P2, OUTPUT);
    pcf8574_RE.pinMode(P3, OUTPUT);
    pcf8574_RE.pinMode(P4, OUTPUT);
    pcf8574_RE.pinMode(P5, OUTPUT);
    pcf8574_RE.pinMode(P6, OUTPUT);
    pcf8574_RE.pinMode(P7, OUTPUT);
   
    pcf8574_IN1.pinMode(P0, INPUT);
    pcf8574_IN1.pinMode(P1, INPUT);
    pcf8574_IN1.pinMode(P2, INPUT);
    pcf8574_IN1.pinMode(P3, INPUT);
    pcf8574_IN1.pinMode(P4, INPUT);
    pcf8574_IN1.pinMode(P5, INPUT);
    pcf8574_IN1.pinMode(P6, INPUT);
    pcf8574_IN1.pinMode(P7, INPUT);
    pcf8574_IN1.begin();
    pcf8574_RE.begin();
}

void loop()
{
uint8_t val1 = pcf8574_IN1.digitalRead(P0);
uint8_t val2 = pcf8574_IN1.digitalRead(P1);
uint8_t val3 = pcf8574_IN1.digitalRead(P2);
uint8_t val4 = pcf8574_IN1.digitalRead(P3);
uint8_t val5 = pcf8574_IN1.digitalRead(P4);
uint8_t val6 = pcf8574_IN1.digitalRead(P5);
uint8_t val7 = pcf8574_IN1.digitalRead(P6);
uint8_t val8 = pcf8574_IN1.digitalRead(P7);
if (val1==LOW) {
  pcf8574_RE.digitalWrite(P0,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P0,HIGH);
if (val2==LOW) {
  pcf8574_RE.digitalWrite(P1,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P1,HIGH);
if (val3==LOW)  {
  pcf8574_RE.digitalWrite(P2,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P2,HIGH);
if (val4==LOW)  {
  pcf8574_RE.digitalWrite(P3,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P3,HIGH);
if (val5==LOW)  {
  pcf8574_RE.digitalWrite(P4,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P4,HIGH);
if (val6==LOW)  {
  pcf8574_RE.digitalWrite(P5,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P5,HIGH);
if (val7==LOW)  {
  pcf8574_RE.digitalWrite(P6,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P6,HIGH);
if (val8==LOW)  {
  pcf8574_RE.digitalWrite(P7,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P7,HIGH);

    delay(300);
}
[Arduino source code for KC868-A8M]-03 INPUT



Attached Files
.zip   KC868-A8M_INPUT.zip (Size: 822 bytes / Downloads: 510)
Print this item

  [Arduino source code for KC868-A8M]-02 DS18B20
Posted by: KinCony Support - 04-14-2023, 03:15 AM - Forum: KC868-A8M - Replies (2)

Code:
#include <DS18B20.h>

DS18B20 ds(14);   //IO13

void setup() {
  Serial.begin(115200);
}

void loop() {
 
    Serial.printf("Temperature: %.2f C\n",ds.getTempC());
    delay(1000);
}
[Arduino source code for KC868-A8M]-02 DS18B20



Attached Files
.zip   KC868-A8M_DS18B20.zip (Size: 514 bytes / Downloads: 522)
Print this item

  [Arduino source code for KC868-A8M]-01 ADC
Posted by: KinCony Support - 04-14-2023, 03:15 AM - Forum: KC868-A8M - No Replies

Code:
/*Code for KC868-A8S*/
#include "Arduino.h"

#define ANALOG_A1   34        // IO36 
#define ANALOG_A2   35        // IO39   
#define ANALOG_A3   39        // IO34   
#define ANALOG_A4   36        // IO35   
void setup()
{
    Serial.begin(115200);
    delay(1000);

  pinMode(ANALOG_A1,INPUT);
  pinMode(ANALOG_A2,INPUT);
  pinMode(ANALOG_A3,INPUT);
  pinMode(ANALOG_A4,INPUT);
}

void loop()
{
  if(analogRead(ANALOG_A1)!=0)
    {  Serial.printf("A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));delay(500);}
  if(analogRead(ANALOG_A2)!=0)
    {  Serial.printf("A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));delay(500);}
  if(analogRead(ANALOG_A3)!=0)
    {  Serial.printf("A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));delay(500);}
  if(analogRead(ANALOG_A4)!=0)
    {  Serial.printf("A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));delay(500);}

}
[Arduino source code for KC868-A8M]-01 ADC



Attached Files
.zip   KC868-A8M_ADC.zip (Size: 643 bytes / Downloads: 481)
Print this item

  [Arduino source code for KC868-A16S]-06 DS18B20
Posted by: KinCony Support - 04-14-2023, 02:47 AM - Forum: KC868-A16S - No Replies

Code:
#include <DS18B20.h>

#define A16S_RS485_RX  32
#define A16S_RS485_TX  33
#define DL 0
DS18B20 ds(14);

void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,A16S_RS485_RX,A16S_RS485_TX); //A16S
  Serial2.println("A16S RS485 SEND OK");
  pinMode(DL,INPUT);
  Serial2.print(ds.getTempC());
  Serial2.println(" C");
}
void loop() {
  if(digitalRead(DL)==LOW)
  {
    delay(20);
     if(digitalRead(DL)==LOW)
  {
    Serial2.println("Download key ok");
    Serial2.print(ds.getTempC());
    Serial2.println(" C");
   
  }
  }
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());//print rs485 receive
   }
   delay(200);
}
[Arduino source code for KC868-A16S]-06 DS18B20



Attached Files
.zip   A16S_DS18B20.zip (Size: 852 bytes / Downloads: 497)
Print this item

  [Arduino source code for KC868-A16S]-05 LAN8720_UDP
Posted by: KinCony Support - 04-14-2023, 02:46 AM - Forum: KC868-A16S - No Replies

Code:
#include <ETH.h>
#include <WiFiUdp.h>

#define ETH_ADDR        0
#define ETH_POWER_PIN  -1
#define ETH_MDC_PIN    23
#define ETH_MDIO_PIN   18   
#define ETH_TYPE       ETH_PHY_LAN8720
#define ETH_CLK_MODE   ETH_CLOCK_GPIO17_OUT

WiFiUDP Udp;                      //Create UDP object
unsigned int localUdpPort = 4196; //local port

// Set it based on the IP address of the router
IPAddress local_ip(192, 168, 1, 200);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192, 168, 1, 1);

void setup()
{
  Serial.begin(115200);
  Serial.println();
   
  ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE); //start with ETH

  // write confir for static IP, gateway,subnet,dns1,dns2
  if (ETH.config(local_ip, gateway, subnet, dns, dns) == false) {
    Serial.println("LAN8720 Configuration failed.");
  }else{Serial.println("LAN8720 Configuration success.");}
 
/* while(!((uint32_t)ETH.localIP())) //wait for IP
  {

  }*/
  Serial.println("Connected");
  Serial.print("IP Address:");
  Serial.println(ETH.localIP());

  Udp.begin(localUdpPort); //begin UDP listener
}

void loop()
{
  int packetSize = Udp.parsePacket(); //get package size
  if (packetSize)                     //if have received data
  {
    char buf[packetSize];
    Udp.read(buf, packetSize); //read current data

    Serial.println();
    Serial.print("Received: ");
    Serial.println(buf);
    Serial.print("From IP: ");
    Serial.println(Udp.remoteIP());
    Serial.print("From Port: ");
    Serial.println(Udp.remotePort());

    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); //ready to send data
    Udp.print("Received: ");   
    Udp.write((const uint8_t*)buf, packetSize); //copy data to sender buffer
    Udp.endPacket();            //send data
  }
}
[Arduino source code for KC868-A16S]-05 LAN8720_UDP



Attached Files
.zip   A16S_LAN8720_UDP.zip (Size: 1.1 KB / Downloads: 512)
Print this item

  [Arduino source code for KC868-A16S]-04 ADC_code
Posted by: KinCony Support - 04-14-2023, 02:46 AM - Forum: KC868-A16S - No Replies

Code:
#include "Arduino.h"

#define ANALOG_A1   36       
#define ANALOG_A2   34           
#define ANALOG_A3   35       
#define ANALOG_A4   39       

void setup()
{
    Serial.begin(115200);
    delay(1000);

  pinMode(ANALOG_A1,INPUT);
  pinMode(ANALOG_A2,INPUT);
  pinMode(ANALOG_A3,INPUT);
  pinMode(ANALOG_A4,INPUT);
}

void loop()
{
  if(digitalRead(ANALOG_A1)!=0){
    Serial.printf("A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));
  }
  if(digitalRead(ANALOG_A2)!=0){
    Serial.printf("A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));
  }

  if(digitalRead(ANALOG_A3)!=0){
    Serial.printf("A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));
  }

  if(digitalRead(ANALOG_A4)!=0){
    Serial.printf("A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));
  }
  delay(100);

}
[Arduino source code for KC868-A16S]-04 ADC_code



Attached Files
.zip   A16S_ADC.zip (Size: 580 bytes / Downloads: 492)
Print this item