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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 5,368
» Latest member: Alan.llm
» Forum threads: 2,574
» Forum posts: 13,304

Full Statistics

Online Users
There are currently 52 online users.
» 0 Member(s) | 38 Guest(s)
Applebot, Bing, Bytespider, Google, Google-Apps-Script, PetalBot, Yandex, bot

Latest Threads
change wake up name
Forum: KinCony AS
Last Post: gal
5 hours ago
» Replies: 12
» Views: 73
A32 Pro ESPHome yaml incl...
Forum: KC868-A32/A32 Pro
Last Post: xarouli5
6 hours ago
» Replies: 17
» Views: 181
Need help with configurat...
Forum: KC868-HxB series Smart Controller
Last Post: admin
8 hours ago
» Replies: 32
» Views: 392
ESP32 S3 set up issue
Forum: Extender module
Last Post: admin
Yesterday, 11:43 PM
» Replies: 10
» Views: 61
KC868-A8 Schematic
Forum: KC868-A8
Last Post: admin
Yesterday, 11:40 PM
» Replies: 7
» Views: 46
"KCS" v2.2.8 firmware BIN...
Forum: "KCS" firmware system
Last Post: admin
Yesterday, 11:38 PM
» Replies: 2
» Views: 164
Dimensions/drawings of bo...
Forum: Schematic and diagram
Last Post: admin
Yesterday, 11:37 PM
» Replies: 1
» Views: 21
how to use AS ESP32-S3 vo...
Forum: KinCony AS
Last Post: admin
12-16-2024, 10:55 PM
» Replies: 12
» Views: 447
Problem with IFTTT automa...
Forum: "KCS" firmware system
Last Post: admin
12-16-2024, 10:53 PM
» Replies: 5
» Views: 34
M16 SHT31 sensor disconne...
Forum: KC868-M16 / M1 / MB / M30
Last Post: bsarra
12-16-2024, 08:36 PM
» Replies: 4
» Views: 39

Star [Arduino IDE demo source code for KC868-A8]--#06-PCF8574-DI
Posted by: KinCony Support - 01-05-2022, 07:05 AM - Forum: KC868-A8 - No Replies

Code 5: //The demo code is PCF8574-DI    You can copy the code to your Arduino IDE

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

// Set i2c address
PCF8574 pcf8574(0x22,4,5);// 0x22 is address, IO4 is SDA   IO5 is SCL
unsigned long timeElapsed;
void setup()
{
    Serial.begin(115200);
    delay(1000);

//    pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P0, INPUT);
pcf8574.pinMode(P1, INPUT);
pcf8574.pinMode(P2, INPUT);
pcf8574.pinMode(P3, INPUT);
pcf8574.pinMode(P4, INPUT);
pcf8574.pinMode(P5, INPUT);
pcf8574.pinMode(P6, INPUT);
pcf8574.pinMode(P7, INPUT);

    Serial.print("Init pcf8574...");
    if (pcf8574.begin()){
        Serial.println("OK");
    }else{
        Serial.println("KO");
    }
}

void loop()
{
uint8_t val1 = pcf8574.digitalRead(P0);
uint8_t val2 = pcf8574.digitalRead(P1);
uint8_t val3 = pcf8574.digitalRead(P2);
uint8_t val4 = pcf8574.digitalRead(P3);
uint8_t val5 = pcf8574.digitalRead(P4);
uint8_t val6 = pcf8574.digitalRead(P5);
uint8_t val7 = pcf8574.digitalRead(P6);
uint8_t val8 = pcf8574.digitalRead(P7);
if (val1==LOW) Serial.println("KEY1 PRESSED");
if (val2==LOW) Serial.println("KEY2 PRESSED");
if (val3==LOW) Serial.println("KEY3 PRESSED");
if (val4==LOW) Serial.println("KEY4 PRESSED");
if (val5==LOW) Serial.println("KEY5 PRESSED");
if (val6==LOW) Serial.println("KEY6 PRESSED");
if (val7==LOW) Serial.println("KEY7 PRESSED");
if (val8==LOW) Serial.println("KEY8 PRESSED");
    delay(300);
}
   
   

Print this item

Star [Arduino IDE demo source code for KC868-A8]--#05-LAN8720-UDP
Posted by: KinCony Support - 01-05-2022, 07:01 AM - Forum: KC868-A8 - No Replies

Code 4: //The demo code is LAN8720-UDP    You can copy the code to your Arduino IDE

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, 2, 200);
IPAddress gateway(192, 168, 2, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192, 168, 2, 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
  }
}
   

Print this item

Star [Arduino IDE demo source code for KC868-A8]--#04-DS18B20
Posted by: KinCony Support - 01-05-2022, 06:49 AM - Forum: KC868-A8 - No Replies

Code 3: //The demo code is DS18B20    You can copy the code to your Arduino IDE

Code:
#include <DS18B20.h>

#define LOW_ALARM 10
#define HIGH_ALARM 15

//IO14 or IO13 or IO32 or IO33   Choose one of the IO port
  DS18B20 ds(14);   //DS18B20  -01 
//DS18B20 ds(13);   //DS18B20  -02
//DS18B20 ds(32);   //DS18B20  -03
//DS18B20 ds(33);   //DS18B20  -04
uint8_t address[] = {40, 168, 111, 11, 44, 32, 1, 185};
uint8_t selected;

void setup() {
  Serial.begin(9600);
  selected = ds.select(address);

  if (selected) {
    ds.setAlarms(LOW_ALARM, HIGH_ALARM);
  } else {
    Serial.println("Device not found!");
  }
}

void loop() {
  if (selected) {
    if (ds.hasAlarm()) {
      Serial.print("Warning! Temperature is ");
      Serial.print(ds.getTempC());
      Serial.println(" C");
    }
  } else {
    Serial.println("Device not found!");
  }
}
       

Print this item

Star [Arduino IDE demo source code for KC868-A8]--#03-ADC INPUT
Posted by: KinCony Support - 01-05-2022, 06:35 AM - Forum: KC868-A8 - No Replies

Code 2: //The demo code is ADC INPUT    You can copy the code to your Arduino IDE

Code:
#include "Arduino.h"
#include "PCF8574.h"          //install library "PCF8574 library"

#define ANALOG_A1   34        // IO34   Board: V1.4 
#define ANALOG_A2   35        // IO35   Board: V1.4

byte out_arr[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
// Set i2c address
//TwoWire my_def
PCF8574 pcf8574_input(0x22);

PCF8574 pcf8574_output(0x24);

byte value = 0;

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

  pinMode(ANALOG_A1,INPUT);
  pinMode(ANALOG_A2,INPUT);


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

    Serial.print("Init pcf8574 output...");
    if (pcf8574_output.begin()){
        Serial.println("OK");
    }else{
        Serial.println("failed");
    }

  pcf8574_input.pinMode(P0, INPUT);
  pcf8574_input.pinMode(P1, INPUT);
  pcf8574_input.pinMode(P2, INPUT);
  pcf8574_input.pinMode(P3, INPUT);
  pcf8574_input.pinMode(P4, INPUT);
  pcf8574_input.pinMode(P5, INPUT);
  pcf8574_input.pinMode(P6, INPUT);
  pcf8574_input.pinMode(P7, INPUT);
Serial.print("Init pcf8574 input...");
if (pcf8574_input.begin()){
    Serial.println("OK");
  }else{
    Serial.println("failed");
  }
 
}

void loop()
{
  delay(500);
  Serial.printf("Current Reading A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));
  Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));

 
}
   

Print this item

Star [Arduino IDE demo source code for KC868-A8]--#02-RF_receive
Posted by: KinCony Support - 01-05-2022, 06:28 AM - Forum: KC868-A8 - No Replies

Code 1: //The demo code is RF-receive    You can copy the code to your Arduino IDE

Code:
#include <RCSwitch.h>  //Install library "rcswitch"

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(digitalPinToInterrupt(15));  //receive PIN IO15
}

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 Thumbnail(s)
   
Print this item

Star [Arduino IDE demo source code for KC868-A8]--#01-config Arduino IDE for ESP32 module
Posted by: KinCony Support - 01-05-2022, 05:26 AM - Forum: KC868-A8 - No Replies

  Before using KC868-A8, you need to set the parameters of the preference

Copy the following URL: https://dl.espressif.com/dl/package_esp32_index.json


   
Select the Board "NodeMCU -32S"
   

   
#define ANALOG_A1  34  updated in PCB V1.4
#define ANALOG_A2  35  updated in PCB V1.4

IIC SDA:4
IIC SCL:5

Relay_IIC_address 0x24

Relay1 = pcf8574.pinMode(P0, OUTPUT);
Relay2 = pcf8574.pinMode(P1, OUTPUT);
Relay3 = pcf8574.pinMode(P2, OUTPUT);
Relay4 = pcf8574.pinMode(P3, OUTPUT);
Relay5 = pcf8574.pinMode(P4, OUTPUT);
Relay6 = pcf8574.pinMode(P5, OUTPUT);
Relay7 = pcf8574.pinMode(P6, OUTPUT);
Relay8 = pcf8574.pinMode(P7, OUTPUT);

Input_IIC_address 0x22

Input1 = pcf8574.pinMode(P0, INPUT);
Input2 = pcf8574.pinMode(P1, INPUT);
Input3 = pcf8574.pinMode(P2, INPUT);
Input4 = pcf8574.pinMode(P3, INPUT);
Input5 = pcf8574.pinMode(P4, INPUT);
Input6 = pcf8574.pinMode(P5, INPUT);
Input7 = pcf8574.pinMode(P6, INPUT);
Input8 = pcf8574.pinMode(P7, INPUT);


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

DS18B20/DHT11/DHT21/LED strip -3: 32   updated in PCB V1.4
DS18B20/DHT11/DHT21/LED strip -4: 33   updated in PCB V1.4



RF433MHz wireless receiver: 15

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

Print this item

  [arduino source code for KC868-Uair-9] Send RF 433MHz wireless signal
Posted by: admin - 01-05-2022, 12:47 AM - Forum: KC868-Uair - No Replies

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableTransmit(digitalPinToInterrupt(2));
}

void loop() {
  mySwitch.switchOn("11111", "00010");
  delay(1000);
  mySwitch.switchOff("11111", "00010");
  delay(1000);

  mySwitch.send(5393, 24);
  delay(1000); 
  mySwitch.send(5396, 24);
  delay(1000); 

  mySwitch.send("000000000001010100010001");
  delay(1000); 
  mySwitch.send("000000000001010100010100");
  delay(1000);

  mySwitch.sendTriState("00000FFF0F0F");
  delay(1000); 
  mySwitch.sendTriState("00000FFF0FF0");
  delay(1000);
}

download arduino IDE source code file: 

.zip   433-sender-code.zip (Size: 407 bytes / Downloads: 272)

Note: install "rcswitch" library online firstly.
[Image: attachment.php?aid=462]

Print this item

  [arduino source code for KC868-Uair-8] RF 433MHz wireless remoter decode
Posted by: admin - 01-04-2022, 01:16 AM - Forum: KC868-Uair - No Replies

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

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

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


download arduino IDE source code file: 

.zip   RF-receiver.zip (Size: 393 bytes / Downloads: 300)
Note: install "rcswitch" library online firstly.
   

Print this item

  [arduino source code for KC868-Uair-7] send IR code signal
Posted by: admin - 01-03-2022, 05:41 AM - Forum: KC868-Uair - No Replies

#include "PinDefinitionsAndMore.h"
#include <IRremote.h>

void setup() {

  Serial.begin(9600);
  IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK);

}

  uint16_t sAddress = 0x78;
  uint8_t sCommand = 0xCD;
  uint8_t sRepeats = 0;

void loop() {
  IrSender.sendNEC(sAddress, sCommand, sRepeats);
  delay(1000);
}


download arduino IDE source code file: 

.zip   Uair_IR_send.zip (Size: 388 bytes / Downloads: 292)

Note: install "IRremote" library online firstly.

[Image: attachment.php?aid=456]

set IR sender and receiver GPIO pins define as below image:
[Image: attachment.php?aid=459]

Print this item

  [arduino source code for KC868-Uair-6] IR remoter button decode
Posted by: admin - 01-02-2022, 04:15 AM - Forum: KC868-Uair - No Replies

#include "PinDefinitionsAndMore.h"
#include <IRremote.h>

void setup() {
  Serial.begin(9600);
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN);
}

void loop() {
    if (IrReceiver.decode()) {
        
        IrReceiver.printIRResultShort(&Serial);
        if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
          
            IrReceiver.printIRResultRawFormatted(&Serial, true);
        }
        Serial.println();
    IrReceiver.resume();
    }
}


download arduino IDE source code file: 

.zip   Uair_IR_receive.zip (Size: 569 bytes / Downloads: 291)
Note: install "IRremote" library online firstly.
   

set IR sender and receiver GPIO pins define as below image:
   

Print this item