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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,346
» Latest member: bookwriterscanada
» Forum threads: 3,640
» Forum posts: 18,799

Full Statistics

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

Latest Threads
KC868-A16 - IP & PORT ?? ...
Forum: KC868-A16
Last Post: Guele1
11 hours ago
» Replies: 6
» Views: 692
N20 Problem with Home Ass...
Forum: N20
Last Post: admin
Today, 06:55 AM
» Replies: 6
» Views: 43
N30 Energy entry not work...
Forum: N30
Last Post: admin
Today, 06:50 AM
» Replies: 14
» Views: 157
Problems and general Feed...
Forum: N30
Last Post: admin
Today, 06:49 AM
» Replies: 2
» Views: 22
kWh resolution
Forum: N30
Last Post: admin
Today, 06:49 AM
» Replies: 2
» Views: 9
KCS_N60_N30_N20_N10_V3.18...
Forum: N60
Last Post: admin
Today, 06:45 AM
» Replies: 0
» Views: 7
N60 N30 N20 N10 ARM CPU f...
Forum: N60
Last Post: admin
Today, 06:20 AM
» Replies: 0
» Views: 9
N60/N30/N20/N10 PC softwa...
Forum: N60
Last Post: admin
Today, 04:49 AM
» Replies: 2
» Views: 405
Goes Offline
Forum: KC868-E16S/E16P
Last Post: admin
Today, 12:02 AM
» Replies: 3
» Views: 20
WHATS FIRMWARE
Forum: "KCS" v3 firmware
Last Post: admin
Yesterday, 11:46 PM
» Replies: 7
» Views: 636

  [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: 523)
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: 513)
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: 493)
Print this item

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

Code:
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(digitalPinToInterrupt(16));   
}

void loop() {
  if (mySwitch.available()) {
   
    Serial.print("Received ");
    Serial.print( mySwitch.getReceivedValue() );
    Serial.print(" / ");
    Serial.print( mySwitch.getReceivedBitlength() );
    Serial.print("bit ");
    Serial.print("Protocol: ");
    Serial.println( mySwitch.getReceivedProtocol() );

    mySwitch.resetAvailable();
  }
}
[Arduino source code for KC868-A16S]-03 433_DECODE



Attached Files
.zip   A16S_433-decode.zip (Size: 584 bytes / Downloads: 512)
Print this item

  [Arduino source code for KC868-A16S]-02 PCF8574-OUTPUT
Posted by: KinCony Support - 04-14-2023, 02:45 AM - Forum: KC868-A16S - Replies (3)

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

// Set i2c address
PCF8574 pcf8574_1(0x24,4,5);
PCF8574 pcf8574_2(0x25,4,5);

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

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

  pcf8574_2.pinMode(P0, OUTPUT);
  pcf8574_2.pinMode(P1, OUTPUT);
  pcf8574_2.pinMode(P2, OUTPUT);
  pcf8574_2.pinMode(P3, OUTPUT);
  pcf8574_2.pinMode(P4, OUTPUT);
  pcf8574_2.pinMode(P5, OUTPUT);
  pcf8574_2.pinMode(P6, OUTPUT);
  pcf8574_2.pinMode(P7, OUTPUT);


  Serial.print("Init pcf8574_1...");
  if (pcf8574_1.begin()){
    Serial.println("PCF8574_1_OK");
  }else{
    Serial.println("PCF8574_1_KO");
  }

  Serial.print("Init pcf8574_2...");
  if (pcf8574_2.begin()){
    Serial.println("PCF8574_2_OK");
  }else{
    Serial.println("PCF8574_2_KO");
  }


}

void loop()
{
  for(int i=0;i<=7;i++)
  {
    pcf8574_1.digitalWrite(i, LOW);
    delay(500);
  }
  for(int j=0;j<=7;j++)
  {
    pcf8574_2.digitalWrite(j,LOW);
    delay(500);
  }
for(int i=0;i<=7;i++)
  {
    pcf8574_1.digitalWrite(i, HIGH);
    delay(500);
  }
  for(int j=0;j<=7;j++)
  {
    pcf8574_2.digitalWrite(j,HIGH);
    delay(500);
  }
 
}
[Arduino source code for KC868-A16S]-02 PCF8574-OUTPUT



Attached Files
.zip   A16S_RELAY_OUT.zip (Size: 717 bytes / Downloads: 531)
Print this item

  [Arduino source code for KC868-A16S]-01 PCF8574-INPUT
Posted by: KinCony Support - 04-14-2023, 02:45 AM - Forum: KC868-A16S - No Replies

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

// Set i2c address

PCF8574 pcf8574_1(0x24,4,5);
PCF8574 pcf8574_2(0x25,4,5);

PCF8574 pcf8574_IN1(0x22,4,5);
PCF8574 pcf8574_IN2(0x23,4,5);

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

  // Set pinMode to OUTPUT
  for(int i=0;i<=7;i++)
  {
    pcf8574_IN1.pinMode(i, INPUT);
  }
  for(int i=0;i<=7;i++)
  {
    pcf8574_IN2.pinMode(i, INPUT);
  }

  for(int i=0;i<=7;i++)
  {
    pcf8574_1.pinMode(i, OUTPUT);
  }

  for(int i=0;i<=7;i++)
  {
    pcf8574_2.pinMode(i,OUTPUT);
  }

    pcf8574_1.begin();
    pcf8574_2.begin();
    pcf8574_IN1.begin();
    pcf8574_IN2.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_IN2.pinMode(P0, INPUT);
  pcf8574_IN2.pinMode(P1, INPUT);
  pcf8574_IN2.pinMode(P2, INPUT);
  pcf8574_IN2.pinMode(P3, INPUT);
  pcf8574_IN2.pinMode(P4, INPUT);
  pcf8574_IN2.pinMode(P5, INPUT);
  pcf8574_IN2.pinMode(P6, INPUT);
  pcf8574_IN2.pinMode(P7, INPUT);

pcf8574_IN1.begin();
pcf8574_IN2.begin();
  /*Serial.print("Init pcf8574_IN1...");
  if (pcf8574_IN1.begin()){
    Serial.println("pcf8574_IN1_OK");
  }else{
    Serial.println("pcf8574_IN1_KO");
  }

  Serial.print("Init pcf8574_IN2...");
  if (pcf8574_IN2.begin()){
    Serial.println("pcf8574_IN2_OK");
  }else{
    Serial.println("pcf8574_IN2_KO");
  }*/


}

void loop()
{
    for(int i=0;i<=7;i++)
    {
      if(pcf8574_IN1.digitalRead(i)==LOW)
      {
        Serial.printf("KEY  %d PRESSED\n",i+1);
        pcf8574_1.digitalWrite(i,LOW);
      }else pcf8574_1.digitalWrite(i,HIGH);
      delay(10);
    }


for(int i=0;i<=7;i++)
    {
      if(pcf8574_IN2.digitalRead(i)==LOW)
      {
        Serial.printf("KEY %d PRESSED\n",i+9);
        pcf8574_2.digitalWrite(i,LOW);
      }else pcf8574_2.digitalWrite(i,HIGH);
      delay(10);
    }
 
}
[Arduino source code for KC868-A16S]-01 PCF8574-INPUT



Attached Files
.zip   A16S__INPUT.zip (Size: 824 bytes / Downloads: 519)
Print this item

  KC868-A8M configure yaml for ESPhome
Posted by: admin - 04-14-2023, 02:10 AM - Forum: KC868-A8M - Replies (11)

esphome:
  name: a8m
  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: 5
  scl: 4
  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
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true
     
     
     
  - platform: gpio
    name: "curtain1-down"
    id: relay6
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true
     

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

     
  - platform: gpio
    name: "curtain2-down"
    id: relay8
    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: '000101000101010100000011'
      protocol: 2
    on_press:
      then:
        - switch.toggle: light1
    filters:
      - delayed_off: 200ms

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

  - platform: remote_receiver
    name: "remoter6"
    rc_switch_raw:
      code: '001111010111001010110101'
      protocol: 2
    on_press:
      then:
        - switch.toggle: relay6
    filters:
      - delayed_off: 200ms
     
  - platform: remote_receiver
    name: "remoter7"
    rc_switch_raw:
      code: '001111010111001010110001'
      protocol: 2
    on_press:
      then:
        - switch.toggle: relay7
    filters:
      - delayed_off: 200ms
     
  - platform: remote_receiver
    name: "remoter8"
    rc_switch_raw:
      code: '001111010111001010110011'
      protocol: 2
    on_press:
      then:
        - switch.toggle: relay8
    filters:
      - delayed_off: 200ms
     

# Enable logging
logger:

# Enable Home Assistant API
api:


.txt   KC868-A8M-ha-config.txt (Size: 5.68 KB / Downloads: 531)

Print this item

  KC868-A8M ESP32 I/O pin define
Posted by: admin - 04-14-2023, 02:09 AM - Forum: KC868-A8M - Replies (2)

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

IIC SDA:5
IIC SCL:4

Relay_IIC_address 0x24

Input_IIC_address 0x22

DS18B20/DHT11/DHT21/LED strip -2: 14

RF433MHz wireless receiver: 16


Ethernet (LAN8720) I/O define:

#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


GSM/RS485:
RXD:GPIO15
TXD:GPIO13

CAN bus:
TXD:GPIO32
RXD:GPIO33

Print this item