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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,316
» Latest member: seosearchgroup
» Forum threads: 3,630
» Forum posts: 18,744

Full Statistics

Online Users
There are currently 35 online users.
» 0 Member(s) | 18 Guest(s)
AhrefsBot, Amazonbot, Applebot, Bytespider, Google, PetalBot, Yeti, bot

Latest Threads
KC868-M16v2 configure yam...
Forum: KC868-M16 / M1 / MB / M30
Last Post: cmeyer5
1 hour ago
» Replies: 126
» Views: 25,272
sample code to receive ht...
Forum: F16
Last Post: admin
5 hours ago
» Replies: 1
» Views: 1
Replacing ESP32 with Kinc...
Forum: KC868-A16
Last Post: admin
12-24-2025, 11:43 PM
» Replies: 1
» Views: 18
N30 Energy entry not work...
Forum: N30
Last Post: admin
12-24-2025, 11:43 PM
» Replies: 11
» Views: 97
KC868-Server ESP32 Ethern...
Forum: KC868-Server Raspberry Pi4 local server
Last Post: admin
12-24-2025, 11:41 PM
» Replies: 7
» Views: 77
Single Moment switch
Forum: DIY Project
Last Post: admin
12-24-2025, 11:37 PM
» Replies: 1
» Views: 22
Help with Product Slectio...
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
12-24-2025, 12:06 AM
» Replies: 5
» Views: 65
Loxone RS485
Forum: KinCony integrate with Loxone home automation
Last Post: admin
12-24-2025, 12:03 AM
» Replies: 9
» Views: 1,129
adaptor V2 and KC868 h32b...
Forum: KC868-ATC / Tuya adapter V2
Last Post: admin
12-23-2025, 01:19 AM
» Replies: 1
» Views: 26
KC868-A6 - how to connect...
Forum: KC868-A6
Last Post: admin
12-23-2025, 01:18 AM
» Replies: 1
» Views: 26

  [Arduino source code for KC868-A256]-05 RS485
Posted by: KinCony Support - 03-22-2023, 01:05 AM - Forum: KC868-A256 - No Replies

Code:
/*/*WWW.KINCONY.COM*/
/*KC868-A256 code of RS485 */
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,13,14);//A256
   Serial2.println("RS485 SEND is OK!!");
   Serial2.println("******************");
 
}

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   rs485.zip (Size: 550 bytes / Downloads: 656)
Print this item

  [Arduino source code for KC868-A256]-04 OUTPUT_256
Posted by: KinCony Support - 03-22-2023, 01:05 AM - Forum: KC868-A256 - No Replies

Code:
/*
KC868-256  press button S2,all leds will on one by one;
            release the button,all leds will off one by one;
*/

int latchPin = 4;
int clockPin = 16;
int dataPin = 5;
int button =0;

void setup()
{
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);
  pinMode(button, INPUT);
 
}

void loop()
{
if(digitalRead(button)==LOW){
     
     digitalWrite(dataPin,HIGH);
     delay(10);
     digitalWrite(clockPin,LOW);
     delay(10);
     digitalWrite(clockPin,HIGH);
     delay(10);
     digitalWrite(latchPin, LOW);
     delay(10);
     digitalWrite(latchPin, HIGH);
     delay(100);
}
else {
     digitalWrite(dataPin,LOW);
     delay(10);
     digitalWrite(clockPin,LOW);
     delay(10);
     digitalWrite(clockPin,HIGH);
     delay(10);
     digitalWrite(latchPin, LOW);
     delay(10);
     digitalWrite(latchPin, HIGH);
     delay(100);
  }

}



Attached Files
.zip   A256-output_256.zip (Size: 635 bytes / Downloads: 606)
Print this item

  [Arduino source code for KC868-A256]-03 ETHERNET
Posted by: KinCony Support - 03-22-2023, 01:03 AM - Forum: KC868-A256 - No Replies

Code:
/*KC868-A256 NETWORK TEST 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.");}
  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   LAN8720_UDP.zip (Size: 929 bytes / Downloads: 589)
Print this item

  [Arduino source code for KC868-A256]-02 INPUT_256
Posted by: KinCony Support - 03-22-2023, 01:02 AM - Forum: KC868-A256 - No Replies

Code:
/*
* KC868-256 INPUT CODE
  74HC165 Shift register input example
*/
const byte latchPin = 33;       
const byte clockPin = 32;       
const byte dataPin = 15;       


const int numBits = 8;   

void setup() {
  Serial.begin(115200);
  pinMode(dataPin, INPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
}

void loop() {

  digitalWrite(latchPin, LOW);
  digitalWrite(latchPin, HIGH);
  for(int j =0;j<=255;j+=8)
  {
    for (int i = numBits; i >0; i--) {
    int bit = digitalRead(dataPin);
    if (bit == LOW) {
      Serial.printf("Input %d is DOWN\n",i+j);
    }
    digitalWrite(clockPin, HIGH);
    digitalWrite(clockPin, LOW);
  }
  }
}



Attached Files
.zip   KC868-256_input_256.zip (Size: 796 bytes / Downloads: 603)
Print this item

  [Arduino source code for KC868-A256]-01 ADC_INOUT
Posted by: KinCony Support - 03-22-2023, 01:01 AM - Forum: KC868-A256 - No Replies

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

#define ANALOG_A1   36        // IO36 
#define ANALOG_A2   39        // IO39   
#define ANALOG_A3   34        // IO34   
#define ANALOG_A4   35        // 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);}

}



Attached Files
.zip   KC868-256_ADC_INOUT.zip (Size: 681 bytes / Downloads: 536)
Print this item

  [Arduino source code for KC868-AM]-05 WIFISCAN_RSSI
Posted by: KinCony Support - 03-22-2023, 12:54 AM - Forum: KC868-AM - No Replies

Code:
/*  KC868-AM wifi scan and print the RSSI*/


#include "WiFi.h"

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

    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);
}

void loop()
{
    Serial.println("scan start");

    // WiFi.scanNetworks will return the number of networks found
    int n = WiFi.scanNetworks();
    Serial.println("scan done");
    if (n == 0) {
        Serial.println("no networks found");
    } else {
        Serial.print(n);
        Serial.println(" networks found");
       
       for (int i = 0; i < n; ++i) {
          /*Print SSID and RSSI for each network found
            Serial.print(i + 1);
            Serial.print(": ");
            Serial.print(WiFi.SSID(i));
            Serial.print(" (");
            Serial.print(WiFi.RSSI(i));
            Serial.print(")");
            Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
            delay(10);*/
            if(WiFi.SSID(i)=="KinCony"){
            Serial.print(WiFi.SSID(i));
            Serial.print(" (");
            Serial.print(WiFi.RSSI(i));
            Serial.println("db)");
            delay(100);
        }
        }
    }
    Serial.println("");

    // Wait a bit before scanning again
    delay(1000);
}



Attached Files
.zip   AM_WiFiScan_RSSI.zip (Size: 852 bytes / Downloads: 495)
Print this item

  [Arduino source code for KC868-AM]-04 RELAY
Posted by: KinCony Support - 03-22-2023, 12:53 AM - Forum: KC868-AM - No Replies

Code:
/*KC868-AM  relay  output*/
#define RELAY 15
void setup() {
  pinMode(RELAY, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    digitalWrite(RELAY, HIGH);
    delay(1000);
    digitalWrite(RELAY, LOW);
    delay(1000);
}



Attached Files
.zip   AM_Relay.zip (Size: 485 bytes / Downloads: 479)
Print this item

  [Arduino source code for KC868-AM]-03 ETHERNET
Posted by: KinCony Support - 03-22-2023, 12:53 AM - Forum: KC868-AM - 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
  }
}



Attached Files
.zip   AM_ETHERNET.zip (Size: 1.07 KB / Downloads: 524)
Print this item

  [Arduino source code for KC868-AM]-02 DS18b20
Posted by: KinCony Support - 03-22-2023, 12:51 AM - Forum: KC868-AM - Replies (4)

Code:
#include <DS18B20.h>

DS18B20 ds1(5); 
DS18B20 ds2(14); 
DS18B20 ds3(13);
DS18B20 ds4(33);
void setup() {
  Serial.begin(115200);
}
void loop() {
Serial.printf("T1:%.2fC||T2:%.2fC||T3:%.2fC||T4:%.2fC\n",ds1.getTempC(),ds2.getTempC(),ds3.getTempC(),ds4.getTempC());
      delay(500);
}



Attached Files
.zip   AM_DS18b20.zip (Size: 491 bytes / Downloads: 503)
Print this item

  [Arduino source code for KC868-AM]-01 RS485
Posted by: KinCony Support - 03-22-2023, 12:50 AM - Forum: KC868-AM - No Replies

Code:
//AM
#define AM_RS485RX  35
#define AM_RS485TX  32
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,AM_RS485RX,AM_RS485TX);

   Serial2.println("AM RS485 SEND is OK!!");
   Serial2.println("******************");
 
}

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   AM_RS485.zip (Size: 562 bytes / Downloads: 492)
Print this item