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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,310
» Latest member: biofrankpharma
» Forum threads: 3,629
» Forum posts: 18,736

Full Statistics

Online Users
There are currently 28 online users.
» 0 Member(s) | 12 Guest(s)
AhrefsBot, Amazonbot, Bing, PetalBot, Semrush, bot

Latest Threads
KC868-M16v2 configure yam...
Forum: KC868-M16 / M1 / MB / M30
Last Post: admin
5 hours ago
» Replies: 120
» Views: 25,175
Replacing ESP32 with Kinc...
Forum: KC868-A16
Last Post: admin
Yesterday, 11:43 PM
» Replies: 1
» Views: 13
N30 Energy entry not work...
Forum: N30
Last Post: admin
Yesterday, 11:43 PM
» Replies: 11
» Views: 76
KC868-Server ESP32 Ethern...
Forum: KC868-Server Raspberry Pi4 local server
Last Post: admin
Yesterday, 11:41 PM
» Replies: 7
» Views: 68
Single Moment switch
Forum: DIY Project
Last Post: admin
Yesterday, 11:37 PM
» Replies: 1
» Views: 16
Help with Product Slectio...
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
Yesterday, 12:06 AM
» Replies: 5
» Views: 58
Loxone RS485
Forum: KinCony integrate with Loxone home automation
Last Post: admin
Yesterday, 12:03 AM
» Replies: 9
» Views: 1,119
adaptor V2 and KC868 h32b...
Forum: KC868-ATC / Tuya adapter V2
Last Post: admin
12-23-2025, 01:19 AM
» Replies: 1
» Views: 19
KC868-A6 - how to connect...
Forum: KC868-A6
Last Post: admin
12-23-2025, 01:18 AM
» Replies: 1
» Views: 16
easy way to export/import...
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
12-23-2025, 01:09 AM
» Replies: 7
» Views: 5,642

  Lesson28 - How to send command control RS485 curtain motor
Posted by: admin - 06-01-2022, 02:39 AM - Forum: Home automation training courses - No Replies


This is a demo of curtain motor. this motor support TUYA wifi and RS485 modbus protocol.

Open command

start Motor address function Data address CRC16
Send 55 fe fe 03 01 AD 8A
receive 55 fe fe 03 01 AD 8A

Close command

start Motor address function Data address CRC16
Send 55 fe fe 03 02 ED 8B
receive 55 fe fe 03 02 ED 8B

Set any positon command

start Motor address function Data address value CRC16
Send 55 fe fe 03 04 1E C8 E5
receive 55 Fe fe 03 04 FF* 08 AD


Read current positon command

start Motor address function Data address Data length CRC16
Send 55 fe fe 01 02 01 2B 4D
receive 55 fe fe 01 01 FF* AA 3D

Track range: 0x00—0x64    -  0%--100%

Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#10-KC868-A8S_GSM_code
Posted by: KinCony Support - 06-01-2022, 01:33 AM - Forum: KC868-A8S - No Replies

[Arduino IDE demo source code for KC868-A8S]--#10-KC868-A8S_GSM_code

Code:
/*KC868-A8S GSM_CODE*/
/*The gsm module is SIM7600*/
/*Send the AT command*/

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

void loop() {
  while (Serial.available()) {
      delay(1);
      Serial1.write(Serial.read());
  }
  while (Serial1.available()) {
       Serial.write(Serial1.read());
  }
}

.zip   sim7600-AT-debug.zip (Size: 542 bytes / Downloads: 631)



Attached Files Thumbnail(s)
   

.zip   sscom32E.zip (Size: 344.42 KB / Downloads: 588)
Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#09-KC868-A8S_RS485_code
Posted by: KinCony Support - 06-01-2022, 01:23 AM - Forum: KC868-A8S - No Replies

[Arduino IDE demo source code for KC868-A8S]--#09-KC868-A8S_RS485_code

Code:
/*WWW.KINCONY.COM*/
/*KC868-A8s code of RS485 */
void setup() {

Serial2.begin(9600,SERIAL_8N1,32,33);  //  IO32   485RX   IO33 485TX

}

void loop() {
Serial2.println("KinCony ACBDEFG"); // Enter your print string
delay(1500);
}



Attached Files
.zip   rs485.zip (Size: 489 bytes / Downloads: 611)
Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#08-KC868-A8S_WS2812-RGB_LED_code
Posted by: KinCony Support - 06-01-2022, 01:21 AM - Forum: KC868-A8S - No Replies

[Arduino IDE demo source code for KC868-A8S]--#08-KC868-A8S_WS2812-RGB_LED_code

Code:
/*KC868-A8S  WS2812 RGB LED CODE*/

#include <Adafruit_NeoPixel.h>

Adafruit_NeoPixel rgb_display = Adafruit_NeoPixel(130,12,NEO_GRB + NEO_KHZ800);
//The WS2812 rgb LED is connect to IO12    RGB_LED number is 1

void setup(){
  rgb_display.begin();
}

void loop(){
  /*
    void setPixelColor(uint16_t n, uint32_t c);
    uint16_t n   start from 0
*/
  rgb_display.setPixelColor((1)-1,(0xff00ff));// Set RGB_LED to Blue color
  rgb_display.setBrightness(100);
  rgb_display.show();
  delay(2000);
  rgb_display.setPixelColor((1)-1,(0xff0000));// Set RGB_LED to Blue color
  rgb_display.setBrightness(100);
  rgb_display.show();
  delay(2000);
  rgb_display.setPixelColor((1)-1,(0x00ff00));// Set RGB_LED to Blue color
  rgb_display.setBrightness(100);
  rgb_display.show();
  delay(2000);
 

}



Attached Files
.zip   WS2812-RGB_LED.zip (Size: 871 bytes / Downloads: 565)
Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#07-KC868-A8S_PCF8574-Digital output_co
Posted by: KinCony Support - 06-01-2022, 01:20 AM - Forum: KC868-A8S - Replies (2)

[Arduino IDE demo source code for KC868-A8S]--#07-KC868-A8S_PCF8574-Digital output_code

Code:
/*KC868-A8S  PCF8574 Digital output code*/

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

// Set i2c address
PCF8574 pcf8574(0x24,4,5);

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

    // Set pinMode to OUTPUT
  pcf8574.pinMode(P0, OUTPUT);
  pcf8574.pinMode(P1, OUTPUT);
  pcf8574.pinMode(P2, OUTPUT);
  pcf8574.pinMode(P3, OUTPUT);
  pcf8574.pinMode(P4, OUTPUT);
  pcf8574.pinMode(P5, OUTPUT);
  pcf8574.pinMode(P6, OUTPUT);
  pcf8574.pinMode(P7, OUTPUT);
   pcf8574.begin();
   
}

void loop()
{
   pcf8574.digitalWrite(P0, HIGH);  delay(300); 
   pcf8574.digitalWrite(P1, HIGH);  delay(300); 
   pcf8574.digitalWrite(P2, HIGH);  delay(300); 
   pcf8574.digitalWrite(P3, HIGH);  delay(300);
   pcf8574.digitalWrite(P4, HIGH);  delay(300); 
   pcf8574.digitalWrite(P5, HIGH);  delay(300);
   pcf8574.digitalWrite(P6, HIGH);  delay(300); 
   pcf8574.digitalWrite(P7, HIGH);  delay(300);
   pcf8574.digitalWrite(P0, LOW);   delay(300);
   pcf8574.digitalWrite(P1, LOW);   delay(300);
   pcf8574.digitalWrite(P2, LOW);   delay(300);
   pcf8574.digitalWrite(P3, LOW);   delay(300);
   pcf8574.digitalWrite(P4, LOW);   delay(300);
   pcf8574.digitalWrite(P5, LOW);   delay(300);
   pcf8574.digitalWrite(P6, LOW);   delay(300);
   pcf8574.digitalWrite(P7, LOW);   delay(300);

}



Attached Files
.zip   PCF8574-DO.zip (Size: 792 bytes / Downloads: 644)
Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#06-KC868-A8S_PCF8574-Digital input_cod
Posted by: KinCony Support - 06-01-2022, 01:19 AM - Forum: KC868-A8S - No Replies

[Arduino IDE demo source code for KC868-A8S]--#06-KC868-A8S_PCF8574-Digital input_code

Code:
/*KC868-A8S PCF8574 Digital input code*/
/*digital input will trigger digital output */
#include "Arduino.h"
#include "PCF8574.h"

// Set i2c address
PCF8574 pcf8574_IN1(0x22,4,5);
PCF8574 pcf8574_RE(0x24,4,5);
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_RE.begin();
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();

}

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);
}



Attached Files
.zip   PCF8574-DI.zip (Size: 940 bytes / Downloads: 582)
Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#05-KC868-A8S_LAN8720_UDP_code
Posted by: KinCony Support - 06-01-2022, 01:18 AM - Forum: KC868-A8S - No Replies

[Arduino IDE demo source code for KC868-A8S]--#05-KC868-A8S_LAN8720_UDP_code

Code:
/*KC868-A8S LAN8720_UDP communication 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 the default IP address to 192.168.1.200  */
/*you can change the default IP address*/
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: 1.09 KB / Downloads: 579)
Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#04-KC868-A8S_DS18B20_code
Posted by: KinCony Support - 06-01-2022, 01:17 AM - Forum: KC868-A8S - No Replies

[Arduino IDE demo source code for KC868-A8S]--#04-KC868-A8S_DS18B20_code

Code:
/*KC868-A8S DS18B20 Temperature sensor code*/

#include <DS18B20.h>
DS18B20 ds1(14);  //channel-1-DS18b20  IO14


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

void loop()
{
  Serial.print("Temperature1:");
  Serial.print(ds1.getTempC());
  Serial.print(" C /");
  delay(500);   
}



Attached Files
.zip   ds18b20.zip (Size: 498 bytes / Downloads: 599)
Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#03-KC868-A8S_BEEP_code
Posted by: KinCony Support - 06-01-2022, 01:14 AM - Forum: KC868-A8S - No Replies

[Arduino IDE demo source code for KC868-A8S]--#03-KC868-A8S_BEEP_code

Code:
/*KC868-A8S Beep code*/

const int BEEP_Pin = 2; 

void setup() {

  // initialize the BEEP_Pin as an output:
   pinMode(BEEP_Pin, OUTPUT);
}

void loop() {
   
    digitalWrite(BEEP_Pin, LOW);
    delay(2000);
    digitalWrite(BEEP_Pin, HIGH);
    delay(2000);
}



Attached Files
.zip   Beep.zip (Size: 632 bytes / Downloads: 580)
Print this item

Lightbulb [Arduino IDE demo source code for KC868-A8S]--#02-KC868-A8S_ADC_INOUT_code
Posted by: KinCony Support - 06-01-2022, 01:12 AM - Forum: KC868-A8S - No Replies

[Arduino IDE demo source code for KC868-A8S]--#02-KC868-A8S_ADC_INOUT_code

Code:
/*KC868-A8S Analog input code*/
/*When the analog input interface has some Voltage ,it will print to the Serial port */
/*A1 A2   Input---0-5V*/
/*A3 A4   Input---0-20MA*/
#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("Current Reading A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));delay(500);}
  if(analogRead(ANALOG_A2)!=0)
    {  Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));delay(500);}
  if(analogRead(ANALOG_A3)!=0)
    {  Serial.printf("Current Reading A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));delay(500);}
  if(analogRead(ANALOG_A4)!=0)
    {  Serial.printf("Current Reading A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));delay(500);}

}



Attached Files
.zip   ADC_INOUT.zip (Size: 710 bytes / Downloads: 573)
Print this item