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 13 online users.
» 0 Member(s) | 4 Guest(s)
AhrefsBot, Amazonbot, Applebot, bot

Latest Threads
KC868-M16v2 configure yam...
Forum: KC868-M16 / M1 / MB / M30
Last Post: admin
Yesterday, 12:24 PM
» Replies: 120
» Views: 25,189
Replacing ESP32 with Kinc...
Forum: KC868-A16
Last Post: admin
12-24-2025, 11:43 PM
» Replies: 1
» Views: 14
N30 Energy entry not work...
Forum: N30
Last Post: admin
12-24-2025, 11:43 PM
» Replies: 11
» Views: 81
KC868-Server ESP32 Ethern...
Forum: KC868-Server Raspberry Pi4 local server
Last Post: admin
12-24-2025, 11:41 PM
» Replies: 7
» Views: 69
Single Moment switch
Forum: DIY Project
Last Post: admin
12-24-2025, 11:37 PM
» Replies: 1
» Views: 17
Help with Product Slectio...
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
12-24-2025, 12:06 AM
» Replies: 5
» Views: 61
Loxone RS485
Forum: KinCony integrate with Loxone home automation
Last Post: admin
12-24-2025, 12:03 AM
» Replies: 9
» Views: 1,121
adaptor V2 and KC868 h32b...
Forum: KC868-ATC / Tuya adapter V2
Last Post: admin
12-23-2025, 01:19 AM
» Replies: 1
» Views: 24
KC868-A6 - how to connect...
Forum: KC868-A6
Last Post: admin
12-23-2025, 01:18 AM
» Replies: 1
» Views: 18
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,646

Question ESPHome DAC output DC 0-10V
Posted by: Loki - 05-06-2023, 11:39 PM - Forum: KC868-A4S - Replies (9)

Hi,

I don't understand how to correctly integrate the AO 01-08 (0-10V) as DAC output in the ESPHome yaml.

Could you please show me an example programme?

Many thanks in advance

Print this item

  [Arduino source code for KC868-A32M]-07_PCF8574_DO
Posted by: KinCony Support - 05-06-2023, 01:16 AM - Forum: KC868-A32M - No Replies

[Arduino source code for KC868-A32M]-07_PCF8574_DO

Code:
/*kc868-a32m pcf8575 out*/
#include "Arduino.h"
#include "PCF8574.h"

#define a 100
// Set i2c address
PCF8574 pcf8574_R1(0x23,4,5);
PCF8574 pcf8574_R2(0x24,4,5);
PCF8574 pcf8574_R3(0x25,4,5);
PCF8574 pcf8574_R4(0x26,4,5);

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

for(int i=0;i<=7;i++){
  pcf8574_R1.pinMode(i,OUTPUT);
  pcf8574_R2.pinMode(i,OUTPUT);
  pcf8574_R3.pinMode(i,OUTPUT);
  pcf8574_R4.pinMode(i,OUTPUT);
 
}
    pcf8574_R1.begin();
    pcf8574_R2.begin();
    pcf8574_R3.begin();
    pcf8574_R4.begin();

    for(int j=0;j<=31;j++){
     if(j<=7){
              pcf8574_R1.digitalWrite(j,LOW);
              delay(a);
             }
     if(7<j<=15){
              pcf8574_R2.digitalWrite(j-8,LOW);
              delay(a);
             } 
     if(15<j<=23){
              pcf8574_R3.digitalWrite(j-16,LOW);
              delay(a);
             }
     if(23<j<=31){
              pcf8574_R4.digitalWrite(j-24,LOW);
              delay(a);
             }       
    }

    for(int j=0;j<=31;j++){
     if(j<=7){
              pcf8574_R1.digitalWrite(j,HIGH);
              delay(a);
             }
     if(7<j<=15){
              pcf8574_R2.digitalWrite(j-8,HIGH);
              delay(a);
             } 
     if(15<j<=23){
              pcf8574_R3.digitalWrite(j-16,HIGH);
              delay(a);
             }
     if(23<j<=31){
              pcf8574_R4.digitalWrite(j-24,HIGH);
              delay(a);
             }       
    }
}

void loop()
{


}



Attached Files
.zip   KC868-A32M-PCF8574_DO.zip (Size: 779 bytes / Downloads: 505)
Print this item

  [Arduino source code for KC868-A32M]-06_ADC
Posted by: KinCony Support - 05-06-2023, 01:14 AM - Forum: KC868-A32M - No Replies

[Arduino source code for KC868-A32M]-06_ADC

Code:
/*KC868-A32M- ADC*/

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

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


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

  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));
  }
   if(analogRead(ANALOG_A2)!=0){
    Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));
   }
   if(analogRead(ANALOG_A3)!=0){
    Serial.printf("Current Reading A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));
   }
   if(analogRead(ANALOG_A4)!=0){
    Serial.printf("Current Reading A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));
   }
   delay(100);
 
}



Attached Files
.zip   KC868-A32M-ADC.zip (Size: 650 bytes / Downloads: 459)
Print this item

  [Arduino source code for KC868-A32M]-05_433_RECEIVE
Posted by: KinCony Support - 05-06-2023, 01:13 AM - Forum: KC868-A32M - No Replies

[Arduino source code for KC868-A32M]-05_433_RECEIVE

Code:
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(115200);
  mySwitch.enableReceive(digitalPinToInterrupt(14));  //IO19
  Serial.print("begin test");
}

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



Attached Files
.zip   KC868-A32M-433_RECEIVE.zip (Size: 641 bytes / Downloads: 482)
Print this item

  [Arduino source code for KC868-A32M]-04_RS485
Posted by: KinCony Support - 05-06-2023, 01:13 AM - Forum: KC868-A32M - No Replies

[Arduino source code for KC868-A32M]-04_RS485

Code:
/*KC868-A32M RS485*/
#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("A32M RS485 SEND is OK!!"); 
}

void loop() {
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());
   }
  delay(200);
}



Attached Files
.zip   KC868-A32M_RS485.zip (Size: 569 bytes / Downloads: 505)
Print this item

  [Arduino source code for KC868-A32M]-03_LAN8720_UDP
Posted by: KinCony Support - 05-06-2023, 01:12 AM - Forum: KC868-A32M - No Replies

[Arduino source code for KC868-A32M]-03_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
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-A32M_LAN8720_UDP.zip (Size: 1.11 KB / Downloads: 484)
Print this item

  [Arduino source code for KC868-A32M]-02_IR_receive_code
Posted by: KinCony Support - 05-06-2023, 01:11 AM - Forum: KC868-A32M - No Replies

[Arduino source code for KC868-A32M]-02_IR_receive_code

Code:
#include <IRremote.h>
IRrecv irrecv_16(16);// set ir_receive pin IO16
void setup() {

  Serial.begin(115200);
  irrecv_16.enableIRIn();
}

void loop() {
    if (irrecv_16.decode()) {
      if(irrecv_16.decodedIRData.decodedRawData!=(0)){
        Serial.print("irCode address: ");           
        Serial.println(irrecv_16.decodedIRData.address,HEX);
        Serial.print("irCode command: ");           
        Serial.println(irrecv_16.decodedIRData.command,HEX);
        Serial.print("irCode decodedRawData: ");           
        Serial.println(irrecv_16.decodedIRData.decodedRawData,HEX);
      }
      IrReceiver.resume();
    }
}
   



Attached Files
.zip   KC868-A32M_IR_receive_code.zip (Size: 673 bytes / Downloads: 491)
Print this item

  [Arduino source code for KC868-A32M]-01_DS3231_RTC
Posted by: KinCony Support - 05-06-2023, 01:09 AM - Forum: KC868-A32M - No Replies

[Arduino source code for KC868-A32M]-01_DS3231_RTC

Code:
// KC868-A32M  RTC CODE DS3231

#include <Wire.h>
#include "RTClib.h"

#define SDA 4
#define SCL 5
RTC_DS3231 myRTC;

void setup () {
    Serial.begin(115200);
    Wire.begin(SDA,SCL);
    delay(500);
    myRTC.begin();
    myRTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
}

void loop () {
     
    DateTime now = myRTC.now();
    Serial.printf("%02d/%02d/%02d  %02d:%02d:%02d\n",
                                          now.year(),
                                          now.month(),
                                          now.day(),
                                          now.hour(),
                                          now.minute(),
                                          now.second());
   delay(1000);
   

   
}



Attached Files
.zip   KC868-A32M_DS3231_RTC.zip (Size: 689 bytes / Downloads: 499)
Print this item

  [Arduino source code for KC868-M16]-03 -ETHERNET_code
Posted by: KinCony Support - 05-06-2023, 01:02 AM - Forum: KC868-M16 / M1 / MB / M30 - No Replies

[Arduino source code for KC868-M16]-03 -ETHERNET_code

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

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-M16-LAN8720.zip (Size: 1 KB / Downloads: 570)
Print this item

  [Arduino source code for KC868-M16]-02 -ADC_code
Posted by: KinCony Support - 05-06-2023, 01:01 AM - Forum: KC868-M16 / M1 / MB / M30 - No Replies

[Arduino source code for KC868-M16]-02 -ADC_code

Code:
/*KC868-M16 Read A1 A2 A4 input*/

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

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


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

  pinMode(ANALOG_A1,INPUT);
  pinMode(ANALOG_A2,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));
  }
   if(analogRead(ANALOG_A2)!=0){
    Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));
   }
   if(analogRead(ANALOG_A4)!=0){
    Serial.printf("Current Reading A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));
   }
   delay(100);
 
}



Attached Files
.zip   KC868-M16-ADC.zip (Size: 631 bytes / Downloads: 513)
Print this item