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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,270
» Latest member: chicagoandy
» Forum threads: 3,616
» Forum posts: 18,647

Full Statistics

Online Users
There are currently 132 online users.
» 0 Member(s) | 108 Guest(s)
AhrefsBot, Amazonbot, Applebot, Bytespider, Crawl, PetalBot, Semrush, Sogou web, bot

Latest Threads
KC868-A32 : PSU 24VDC
Forum: KC868-A32/A32 Pro
Last Post: nicolouts
5 hours ago
» Replies: 0
» Views: 3
MODBUS TCP ETHERNET - SLA...
Forum: KC868-A16
Last Post: admin
11 hours ago
» Replies: 8
» Views: 1,003
N20 ESPHome YAML Updated ...
Forum: N20
Last Post: admin
11 hours ago
» Replies: 1
» Views: 14
Where to start
Forum: KC868-A6
Last Post: admin
Today, 01:05 AM
» Replies: 11
» Views: 8,422
N20 ESPHome & HA - Line t...
Forum: N20
Last Post: admin
Today, 01:04 AM
» Replies: 4
» Views: 43
flash kc868-a4
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
Today, 01:03 AM
» Replies: 11
» Views: 259
KC868-H16B Mqtt stops wor...
Forum: KC868-HxB series Smart Controller
Last Post: admin
Today, 01:02 AM
» Replies: 1
» Views: 5
Some bugs in Home Assista...
Forum: N60
Last Post: VeikkoPeikko
Yesterday, 06:37 AM
» Replies: 2
» Views: 41
KC868 server16 and GSM mo...
Forum: KinCony AS
Last Post: admin
12-15-2025, 11:39 PM
» Replies: 12
» Views: 1,690
IFTTT T64M
Forum: "KCS" v3 firmware
Last Post: admin
12-15-2025, 11:37 PM
» Replies: 3
» Views: 39

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: 559)
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: 640)
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: 572)
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: 575)
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: 592)
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: 573)
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: 564)
Print this item

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

[Arduino IDE demo source code for KC868-A8S]--#01-KC868-A8S_433_receive_code

Code:
/* RF-receive code for KC868-A8S*/
/*If receive the RF single,the LED will be turn the color to "0xff00ff"*/
/*install library RCSwitch and Adafruit_NeoPixel*/

#include <RCSwitch.h>  //Install library "rcswitch"
#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
RCSwitch mySwitch = RCSwitch();
void setup() {
  Serial.begin(9600);
  rgb_display.begin();
  mySwitch.enableReceive(digitalPinToInterrupt(16));  //receive PIN IO16
}

void loop() {

if (mySwitch.available()) {
    Serial.print("Received ");
    Serial.println( mySwitch.getReceivedValue() );
    rgb_display.setPixelColor((1)-1,(0xff00ff));
    rgb_display.setBrightness(100);
    rgb_display.show();
  }
    mySwitch.resetAvailable();   
}
   



Attached Files
.zip   433-decode.zip (Size: 777 bytes / Downloads: 593)
Print this item

  KC868-A8 and PCF8574 Interrupt pin
Posted by: andhol - 05-31-2022, 07:53 PM - Forum: KC868-A8 - Replies (14)

Hi!
I am planning to use all 8 digital inputs of the KC868-A8, and it would be nice to be able to use the interrupt pin of the PCF8574 to detect changes. I'm just not sure if the pin is connected or not. When looking at the schematic, it looks like it is connected to GPIO16, but there is also a red X symbol next to it that might suggest otherwise.. Any hints? 

/A

Print this item

  KC868-A8S hotel room demo configure for ESPhome
Posted by: admin - 05-31-2022, 12:45 AM - Forum: KC868-A8S - Replies (16)

esphome:
  name: a8s
  platform: ESP32
  board: esp32dev
 
 
remote_receiver:
  pin: 16
  dump:
    - rc_switch
  tolerance: 50%
  filter: 250us
  idle: 2ms
  buffer_size: 2kb



# Example configuration entry for ESP32
i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a


# Example configuration entry
ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0

  # Optional manual IP
  manual_ip:
    static_ip: 192.168.1.199
    gateway: 192.168.1.1
    subnet: 255.255.255.0 


# Example configuration entry
pcf8574:
  - id: 'pcf8574_hub_out_1'  # for output channel 1-8
    address: 0x24

  - id: 'pcf8574_hub_in_1'  # for input channel 1-8
    address: 0x22

# Individual outputs
switch:
  - platform: gpio
    name: "light1"
    id: light1
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "light2"
    id: light2
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: OUTPUT
      inverted: true
     
  - platform: gpio
    name: "light3"
    id: light3
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: OUTPUT
      inverted: true
     
  - platform: gpio
    name: "light4"
    id: light4
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: OUTPUT
      inverted: true
     
  - platform: gpio
    name: "curtain1-up"
    id: relay5
    interlock: [relay6]
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true
     
     
     
  - platform: gpio
    name: "curtain1-down"
    id: relay6
    interlock: [relay5]
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true
     

  - platform: gpio
    name: "curtain2-up"
    id: relay7
    interlock: [relay8]
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: true

     
  - platform: gpio
    name: "curtain2-down"
    id: relay8
    interlock: [relay7]
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true

     
binary_sensor:
  - platform: gpio
    name: "input1"
    on_press:
      then:
        - switch.toggle: light1
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 0
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input2"
    on_press:
      then:
        - switch.toggle: light2
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 1
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input3"
    on_press:
      then:
        - switch.toggle: light3
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 2
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input4"
    on_press:
      then:
        - switch.toggle: light4
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 3
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input5"
    on_press:
      then:
        - switch.toggle: relay5
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 4
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input6"
    on_press:
      then:
        - switch.toggle: relay6
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 5
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input7"
    on_press:
      then:
        - switch.toggle: relay7
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 6
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input8"
    on_press:
      then:
        - switch.toggle: relay8
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 7
      mode: INPUT
      inverted: true

  - platform: remote_receiver
    name: "remoter1"
    rc_switch_raw:
      code: '001111010111001010111000'
      protocol: 1
    on_press:
      then:
        - switch.toggle: light1
    filters:
      - delayed_off: 200ms

  - platform: remote_receiver
    name: "remoter2"
    rc_switch_raw:
      code: '001111010111001010111100'
      protocol: 1
    on_press:
      then:
        - switch.toggle: light2
    filters:
      - delayed_off: 200ms
     
  - platform: remote_receiver
    name: "remoter3"
    rc_switch_raw:
      code: '001111010111001010110100'
      protocol: 1
    on_press:
      then:
        - switch.toggle: light3
    filters:
      - delayed_off: 200ms
     
  - platform: remote_receiver
    name: "remoter4"
    rc_switch_raw:
      code: '001111010111001010111001'
      protocol: 1
    on_press:
      then:
        - switch.toggle: light4
    filters:
      - delayed_off: 200ms 
   
  - platform: remote_receiver
    name: "remoter5"
    rc_switch_raw:
      code: '001111010111001010110010'
      protocol: 1
    on_press:
      then:
        - switch.toggle: relay5
    filters:
      - delayed_off: 200ms

  - platform: remote_receiver
    name: "remoter6"
    rc_switch_raw:
      code: '001111010111001010110101'
      protocol: 1
    on_press:
      then:
        - switch.toggle: relay6
    filters:
      - delayed_off: 200ms
     
  - platform: remote_receiver
    name: "remoter7"
    rc_switch_raw:
      code: '001111010111001010110001'
      protocol: 1
    on_press:
      then:
        - switch.toggle: relay7
    filters:
      - delayed_off: 200ms
     
  - platform: remote_receiver
    name: "remoter8"
    rc_switch_raw:
      code: '001111010111001010110011'
      protocol: 1
    on_press:
      then:
        - switch.toggle: relay8
    filters:
      - delayed_off: 200ms
     
  - platform: gpio
    name: "PIR1"
    pin: 14
    device_class: motion
    on_release:
      - script.execute: motion_timer

script:
  - id: motion_timer
    mode: restart
    then:
      - delay: 10s
      - switch.turn_off: light1
      - switch.turn_off: light2
      - switch.turn_off: light3
      - switch.turn_off: light4


# Enable logging
logger:

# Enable Home Assistant API
api:



Attached Files
.txt   KC868-A8S-ha-config.txt (Size: 6.11 KB / Downloads: 829)
Print this item