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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,457
» Latest member: np.nagypeter@gmail.com
» Forum threads: 3,704
» Forum posts: 19,063

Full Statistics

Online Users
There are currently 39 online users.
» 1 Member(s) | 18 Guest(s)
AhrefsBot, Amazonbot, Bytespider, Google, PetalBot, Semrush, bot, np.nagypeter@gmail.com

Latest Threads
E16T is not detected when...
Forum: KC868-E16T
Last Post: Sansol94
2 hours ago
» Replies: 7
» Views: 264
KC868-A16 ethernet work w...
Forum: KC868-A16
Last Post: admin
3 hours ago
» Replies: 18
» Views: 16,203
smoke sensor user manual
Forum: Extender module
Last Post: admin
4 hours ago
» Replies: 0
» Views: 2
gas sensor user manual
Forum: Extender module
Last Post: admin
4 hours ago
» Replies: 0
» Views: 3
N20 CT Shorting terminal ...
Forum: N20
Last Post: WestCoastXS
Yesterday, 10:48 PM
» Replies: 4
» Views: 54
KC868-E16T added Tuya mod...
Forum: KC868-E16T
Last Post: admin
Yesterday, 11:37 AM
» Replies: 8
» Views: 1,702
Problem with KCS flash af...
Forum: "KCS" v2 firmware system
Last Post: tidek1507
Yesterday, 12:39 AM
» Replies: 4
» Views: 38
Bulk IFTTT mapping
Forum: "KCS" v3 firmware
Last Post: admin
Yesterday, 12:18 AM
» Replies: 1
» Views: 20
flash kc868-a4
Forum: KC868-A series and Uair Smart Controller
Last Post: Michel.nadin
01-17-2026, 03:24 PM
» Replies: 21
» Views: 701
E16P Case / Cover
Forum: KC868-E16S/E16P
Last Post: admin
01-17-2026, 01:38 AM
» Replies: 1
» Views: 17

  Lesson18 - add ZigBee PIR motion sensor to auto control light in home assistant
Posted by: admin - 04-25-2022, 01:41 AM - Forum: Home automation training courses - No Replies


1. SONOFF SNZB-03 configure for home assistant by Zigbee2mqtt

sensor:
  - platform: mqtt
    name: pir-state
    state_topic: "zigbee2mqtt/0x00124b00251e530f"
    value_template: "{{ value_json.occupancy }}"   

Note: ID need replace with your device. such as '0x00124b00251e530f'

2. create a new automation:

create automation-1 (turn on light)
-------------------------------------------
Trigger type: State
Entity: pir-state
To: True


Actions:
Action type: Call service
Service: Switch:Switch: Turn on
+ Choose entity

create automation-2 (turn off light)
------------------------------------------
Trigger type: State
Entity: pir-state
To: False


Actions:
Action type: Call service
Service: Switch:Switch: Turn off
+ Choose entity

Print this item

  [Arduino IDE demo source code for KC868-SERVER]--#04-Key press code
Posted by: KinCony Support - 04-22-2022, 01:06 AM - Forum: KC868-Server Raspberry Pi4 local server - No Replies

Code:
void setup() {
  Serial.begin(9600);
  pinMode(0,INPUT);// Key S5  is connected to IO0   set IO0 to input mode
}
void loop() {
  if(digitalRead(0)==LOW){
    Serial.println("Key S5 Pressed!");
    delay(100);
  }
  if(digitalRead(0)==HIGH){
   Serial.println("Key S5 Not Pressed!");
   delay(1000);
   }
}
   
   

Print this item

  [Arduino IDE demo source code for KC868-SERVER]--#03-IR_send code
Posted by: KinCony Support - 04-21-2022, 08:35 AM - Forum: KC868-Server Raspberry Pi4 local server - No Replies

Code:
#include <IRremote.h>
IRsend irsend_23(23);      // set ir_send pin IO23
uint8_t sRepeats = 0;

void setup() {

  Serial.begin(9600);
  pinMode(0,INPUT);
  IrSender.begin(23, ENABLE_LED_FEEDBACK);
  IrSender.enableIROut(38);
}

void loop() {
  /*the raw_code of your remote button,you can get it by our
    example [Arduino IDE demo source code for KC868-SERVER]--#02-IR_RECEIVE code*/
        Serial.println("Turn on LED");
        irsend_23.sendNECRaw(0xF807FF00, sRepeats);   //  0xF807FF00  is the raw_code  of led on
        delay(1000);
        Serial.println("Turn off LED");
        irsend_23.sendNECRaw(0xF906FF00, sRepeats);  //   0xF906FF00 is the raw_code  of led Off
        delay(1000);
}
   
This code will turn on LED and delay 1s turn off LED
   
The raw_data of LED on is 0xF807FF00  ,you can decode the data by our example code
"[Arduino IDE demo source code for KC868-SERVER]--#02-IR_RECEIVE code"
   

Print this item

  [Arduino IDE demo source code for KC868-SERVER]--#02-IR_RECEIVE code
Posted by: KinCony Support - 04-21-2022, 06:16 AM - Forum: KC868-Server Raspberry Pi4 local server - No Replies

Code:
#include <IRremote.h>
IRrecv irrecv_22(22);// set ir_receive pin IO22
void setup() {

  Serial.begin(9600);
  irrecv_22.enableIRIn();
}

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

Print this item

  [Arduino IDE demo source code for KC868-SERVER]--#01-433Mhz-RF-RECEIVE code
Posted by: KinCony Support - 04-21-2022, 05:36 AM - Forum: KC868-Server Raspberry Pi4 local server - No Replies

Code:
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(digitalPinToInterrupt(13));  //The receive PIN is IO 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();
  }
}
       

Print this item

Wink [Case Study-01]: KC868-A4 Green house temperature monitoring
Posted by: admin - 04-21-2022, 01:35 AM - Forum: DIY Project - Replies (1)

[Image: kc868-a4-email.jpg]
In this series, we will analyze examples of the application of Kincony controllers in solving cases from practical applications. Practical cases are usually not complex, but they solve important things in the production process. In some cases, mistakes can cause large losses in production. Such systems need to be approached seriously.
author: wrote by Nebojsa from Croatia
 
Case study:  Greenhouse temperature management
The user owns a greenhouse for growing vegetables. Summer temperature inside the greenhouse should not exceed 35oC. At a temperature of > 40oC the plants begin to be irreversibly destroyed.
When the temperature reaches 30oC, the automation system should immediately send an e-mail warning to the responsible person and start the industrial fans to injecting cooler air. If the temperature continues to rise and reaches (set + 4oC) 34oC, the system should start opening the sides via automatic actuators.
When the temperature drops below 30oC, it is necessary to stop the ventilation and close the sides.
Reading the current temperature inside the greenhouse, and changing the system parameters can be done through the website on the local network.
 
We will use these components:
[Image: kc868-a4.jpg]
KC868-A4 controller
[Image: ds18b20-1.png][Image: ds18b20-2.jpg]
Temperature sensor DS18B20
[Image: contact.jpg][Image: 2NO.jpg][Image: 2NC.jpg]
Contactors, 1 x 2NO; 1 x 1NO – 1 NC
Program structure:
[Image: Program-structure-1.png]
[Image: Program-structure-2.png]This block enable data entry over LAN Web. Start any web browser and in address field enter IP what see after start program over Arduino IDE (for example: 192.168.8.153 as can see on screen)
Programing details
In my series of case studies will not so much fokusing on programming details. Some interesting parts of programs will be comented in source code.
I think you have read the published articles about the KC868-A4 controller, but to note in the Tools menu you should choose Board: NodeMCU 32S.
Include the necessary libraries via Manage Libraries ...
Included libraries:
#include <WiFi.h>               // Enables network connection.
#include <AsyncTCP.h>           // This is a fully asynchronous TCP library
#include <ESPAsyncWebServer.h>  // Async HTTP and WebSocket Server
#include <OneWire.h>            // Access 1-wire devices as temp. sensors
#include <DallasTemperature.h>  // Library for Dallas Temperature ICs
#include "ESP32_MailClient.h"   // Mail Client Arduino Library for ESP32
#include "time.h"               // Date and Time functions, NTP sync.
 
 
Slanje maila preko KC868-A4
We recommend that you create a new mail, and do not use your existing mail account. This mail will be used to send emails. On this occasion, I opened a new gmail.com account via the link.
In the Select app field, choose mail and password.
The SMTP server settings for the sender email.

  • SMTP Server: gmail.com
  • SMTP username: Complete Gmail address
  • SMTP password: Your Gmail password
  • SMTP port (TLS): 587
  • SMTP port (SSL): 465
  • SMTP TLS/SSL required: yes
 
// To send Email using Gmail use port 465 (SSL) and SMTP Server smtp.gmail.com
const String emailSenderAccount  = "your mail@gmail.com";
const String emailSenderPassword = "your password";
const String smtpServer          = "smtp.gmail.com";
const int    smtpServerPort      = 465;
 
The mailing address for reception, can be our existing mail or any other.
 
KC868-A4 Mailing source program download here.
 
Run the temperature mailing notification
Start Tools -> Serial monitor
First start WiFi connecting over assign SSID and password of the router WiFi.
Remember this IP address, will need later.
[Image: arduino-serial.jpg]
The program provided the date and time via an internet NTP server. It is important for real time the temperature monitoring. After this program read temperature from DS18B20 sensor.
As the case study defined, the temperature less than 30oC mean normal situation, no any action and there is no need to turn on the cooling, the fan stay Off and wall is closed.
[Image: temperature-output-1.jpg]
After the temperature exceeds the set limit (30oC), ventilation is switched on (Fan -> ON), system send Alert mail to defined address, but the wall actuators stay closed.
If the temperature continues to rise and reaches 4oC more than the set limit, the actuator is started to open the sides of the greenhouse. State: Fan -> On; Wall -> Open.
[Image: temperature-output-2.jpg]
If the temperature starts to drop, the fan will continue to run until it falls below the set limit. The sides will also be open during this time. When the temperature falls below the set limit, the system sends an e-mail to the user to inform him that the temperature has returned to normal, the fan is stopped and the side walls of the greenhouse are closed.
[Image: temperature-output-3.jpg]
Received mail when temperature goes over the defined limit:
[Image: temperature-output-4.jpg]
[Image: alarm-mail.jpg]
Received mail when temperature again become the normal:
[Image: alarm-mail-2.jpg]
[Image: alarm-mail-3.jpg]
Temperature readings and settings can be performed via a web browser. We need to start our web browser (any), enter the IP address obtained at the beginning, we will get the web page as shown below.
[Image: alarm-mail-4.jpg]
The HTML code generated by the specified screen was created in our program. We will not go into deeper explanations, we would just look the HTML code.
[Image: http-code.jpg]
Hardware system configuration
[Image: hardware-system.png]
Conclusion:
This case study like all others can be performed in many ways. One solution is presented here. The Kincony controller KC868-A4 was used, the Arduino IDE was used for programming. For settings see the link about KC868-A4. The plan is to process several different projects related to practical applications.
If you have any questions, suggestions or comments, write to info@edata.hr

Print this item

  [Arduino demo source code for KC868-A4]-14 MQTT demo
Posted by: admin - 04-19-2022, 12:47 AM - Forum: KC868-A4 - Replies (18)

Code:
// MQTT demo source code for KC868-A4
// Remote control relay ON/OFF by any MQTT broker
// Digital input use by switch button for ON/OFF and demo show state feedback
// You can use by MQTTBOX for test or KinCony KBOX android phone app

#define Relay1  2
#define Relay2  15
#define Relay3  5
#define Relay4  4

#define Key1  36
#define Key2  39
#define Key3  27
#define Key4  14


int KEY_NUM1 = 0;    //key_1 value
int KEY_NUM2 = 0;    //key_2 value
int KEY_NUM3 = 0;    //key_3 value
int KEY_NUM4 = 0;    //key_4 value

#include <string.h>
#include <WiFi.h>
#include <PubSubClient.h>


// WiFi
const char *ssid = "KinCony"; // Enter your WiFi name
const char *password = "a12345678";  // Enter WiFi password

// MQTT Broker
const char *mqtt_broker = "iot.kincony.com";  // or your MQTT broker IP/Domain
const char *topic_command = "relay4/123456/set";  // if use by KBOX android phone app, use relay4/xxxxxx/set      for command
const char *topic_state = "relay4/123456/state";  // if use by KBOX android phone app, use relay4/xxxxxx/state    for feedback state
const char *mqtt_username = "mqtt";
const char *mqtt_password = "123";
const int mqtt_port = 1883;

WiFiClient espClient;
PubSubClient client(espClient);

void setup() {

  pinMode(Relay1,OUTPUT);   //Relay1 IO2
  pinMode(Relay2,OUTPUT);   //Relay2 IO15
  pinMode(Relay3,OUTPUT);   //Relay3 IO2
  pinMode(Relay4,OUTPUT);   //Relay4 IO2

  pinMode(Key1,INPUT);  //Digital input1 IO36
  pinMode(Key2,INPUT);  //Digital input2 IO39
  pinMode(Key3,INPUT);  //Digital input3 IO27
  pinMode(Key4,INPUT);  //Digital input4 IO14

  pinMode(2, OUTPUT);   //relay1
  pinMode(15, OUTPUT);  //relay2
  pinMode(4, OUTPUT);   //relay3
  pinMode(5, OUTPUT);   //relay4

  digitalWrite(2, LOW);   // turn the LED OFF (HIGH is the voltage level)
  digitalWrite(15,LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);

 
// Set software serial baud to 115200;
Serial.begin(115200);
// connecting to a WiFi network
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
     delay(500);
     Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
//connecting to a mqtt broker
client.setServer(mqtt_broker, mqtt_port);
client.setCallback(callback);
while (!client.connected()) {
     String client_id = "esp32-client-";
     client_id += String(WiFi.macAddress());
     Serial.printf("The client %s connects to the public mqtt broker\n", client_id.c_str());
     if (client.connect(client_id.c_str(), mqtt_username, mqtt_password)) {
         Serial.println("Public emqx mqtt broker connected");
     } else {
         Serial.print("failed with state ");
         Serial.print(client.state());
         delay(2000);
     }
}
// publish and subscribe
client.publish(topic_state, "Hi I am KC868-A4");
client.subscribe(topic_command);
}

void callback(char *topic_command, byte *payload, unsigned int length) {
Serial.print("Message arrived in topic: ");
Serial.println(topic_command);
Serial.print("Message:");
for (int i = 0; i < length; i++) {
     Serial.print((char) payload[i]);
}
Serial.println();
Serial.println("-----------------------");

if (!strncmp((char *)payload, "{\"relay1\":{\"on\":1}}", length)) digitalWrite(Relay1, HIGH);
else if (!strncmp((char *)payload, "{\"relay1\":{\"on\":0}}", length)) digitalWrite(Relay1, LOW);

if (!strncmp((char *)payload, "{\"relay2\":{\"on\":1}}", length)) digitalWrite(Relay2, HIGH);
else if (!strncmp((char *)payload, "{\"relay2\":{\"on\":0}}", length)) digitalWrite(Relay2, LOW);

if (!strncmp((char *)payload, "{\"relay3\":{\"on\":1}}", length)) digitalWrite(Relay3, HIGH);
else if (!strncmp((char *)payload, "{\"relay3\":{\"on\":0}}", length)) digitalWrite(Relay3, LOW);

if (!strncmp((char *)payload, "{\"relay4\":{\"on\":1}}", length)) digitalWrite(Relay4, HIGH);
else if (!strncmp((char *)payload, "{\"relay4\":{\"on\":0}}", length)) digitalWrite(Relay4, LOW);



if (!strncmp((char *)payload, "{\"relay4\":{\"read\":1}}", length)) {   //for app read all state, replace with your read relay and input code
      client.publish(topic_state, "{\"relay1\":{\"on\":0},\"relay2\":{\"on\":0},\"relay3\":{\"on\":0},\"relay4\":{\"on\":0},\"input1\":{\"on\":0},\"input2\":{\"on\":0},\"input3\":{\"on\":0},\"input4\":{\"on\":0}}");
    }


}

void loop() {
  ScanKey1();            //scan key1
  ScanKey2();            //scan key2
  ScanKey3();            //scan key3
  ScanKey4();            //scan key4
client.loop();
}

void ScanKey1()           
{
  String temp="{\"relay1\":{\"on\":";

  KEY_NUM1 = 0;                     
  if(digitalRead(Key1) == LOW)         //key1 pressed
  {
    delay(20);                        //anti-interference
    if(digitalRead(Key1) == LOW)       //key1 pressed again
    {
      KEY_NUM1 = 1;                  
      while(digitalRead(Key1) == LOW); //wait remove hand
    }
  }
  if(KEY_NUM1 == 1)              //if key1 pressed
  {  
    digitalWrite(Relay1,!digitalRead(Relay1));    // toggle relay1 state
    if(digitalRead(Relay1) == LOW) temp=temp+"0}}";
    if(digitalRead(Relay1) == HIGH) temp=temp+"1}}";

    client.publish(topic_state, temp.c_str());
  } 
}

void ScanKey2()           
{
  String temp="{\"relay2\":{\"on\":";
  KEY_NUM2 = 0;                     
  if(digitalRead(Key2) == LOW)         //key2 pressed
  {
    delay(20);                        //anti-interference
    if(digitalRead(Key2) == LOW)       //key2 pressed again
    {
      KEY_NUM2 = 1;                  
      while(digitalRead(Key2) == LOW); //wait remove hand
    }
  }
  if(KEY_NUM2 == 1)              //if key2 pressed
  {  
    digitalWrite(Relay2,!digitalRead(Relay2));    // toggle relay2 state
    if(digitalRead(Relay2) == LOW) temp=temp+"0}}";
    if(digitalRead(Relay2) == HIGH) temp=temp+"1}}";
    client.publish(topic_state, temp.c_str());
  }
}

void ScanKey3()           
{
  String temp="{\"relay3\":{\"on\":";
  KEY_NUM3 = 0;                     
  if(digitalRead(Key3) == LOW)         //key3 pressed
  {
    delay(20);                        //anti-interference
    if(digitalRead(Key3) == LOW)       //key3 pressed again
    {
      KEY_NUM3 = 1;                  
      while(digitalRead(Key3) == LOW); //wait remove hand
    }
  }
  if(KEY_NUM3 == 1)              //if key3 pressed
  {  
    digitalWrite(Relay3,!digitalRead(Relay3));    // toggle relay3 state
    if(digitalRead(Relay3) == LOW) temp=temp+"0}}";
    if(digitalRead(Relay3) == HIGH) temp=temp+"1}}";
    client.publish(topic_state, temp.c_str());
  }
}

void ScanKey4()           
{
  String temp="{\"relay4\":{\"on\":";
  KEY_NUM4 = 0;                     
  if(digitalRead(Key4) == LOW)         //key4 pressed
  {
    delay(20);                        //anti-interference
    if(digitalRead(Key4) == LOW)       //key4 pressed again
    {
      KEY_NUM4 = 1;                  
      while(digitalRead(Key4) == LOW); //wait remove hand
    }
  }
  if(KEY_NUM4 == 1)              //if key4 pressed
  {  
    digitalWrite(Relay4,!digitalRead(Relay4));    // toggle relay4 state
    if(digitalRead(Relay4) == LOW) temp=temp+"0}}";
    if(digitalRead(Relay4) == HIGH) temp=temp+"1}}";
    client.publish(topic_state, temp.c_str());
  }
}
   

.zip   a4-mqtt.zip (Size: 2.05 KB / Downloads: 785)

Print this item

  Lesson17 - integrate USB local camera to home assistant
Posted by: admin - 04-18-2022, 12:52 AM - Forum: Home automation training courses - No Replies


1. connect with your USB camera.
2. Enable home assistant "Advanced Mode".
3. "Add-ons, Backups & Supervisor" -- "system" -- "Host" -- "Hardware" ,  search videox
4. Configuration edit yaml
camera:
  - platform: ffmpeg
    name: cam
    input: /dev/input/video0
5. Home assistant restart
6. Add camera to dashboard by "picture entity" card

Print this item

  KC816-A16 ESPHome modbus.
Posted by: aamelkin - 04-16-2022, 06:37 AM - Forum: KC868-A16 - Replies (8)

Hi all, i'm tring to connect r4dcb08 module (https://aliexpress.ru/item/1005002616932...1413511247) to the A16 board using ESPHome
Could you please share me some working config (demo config) for A16 board with some modbus device ? (Existing demo codes havn't modbus examles)
Thanks.

Print this item

  Read 4 channel analog inputs by TCP or RS485 protocol
Posted by: admin - 04-15-2022, 03:25 AM - Forum: KC868-Server Raspberry Pi4 local server - Replies (2)

1: Read 4 channel analog inputs by TCP command:
Send: RELAY-GET_AI-255
Feedback: RELAY-AI-ALL,A0,A1,A2,A3,OK

A0,A1 analog input range: DC0-5V
A2,A3 analog input range: 4-20mA

example:
A0 and A1 connect with 3.3V , will feedback:
RELAY-AI-ALL,330,330,0,0,OK

A2 and A3 connect with 10mA sensor , will feedback:
RELAY-AI-ALL,0,0,455,455,OK


--------------------------------------------------------------
2: enable/disable analog inputs by TCP command:
Send: RELAY-AI_REPORT-255,1    //Enable analog input AUTO feedback
Feedback: RELAY-AI_REPORT-255,1,OK

Send: RELAY-AI_REPORT-255,0   //Disable analog input AUTO feedback
Feedback: RELAY-AI_REPORT-255,0,OK


---------------------------------------------------------------
3. Read 4 channel analog inputs by MODBUS RS485

01 03 01 2C 00 04 CRCH CRCL   
Feedback: 01 03 08 A0 A1 A2 A3 CRCH CRCL

01:RS485 address ID
01 2C=300 register address
00 04 register number

example:
if A0 connect with 3.29V
Send: 01 03 01 2C 00 04 84 3C
Feedback: 01 03 08 01 49 00 00 00 00 00 00 8C DF
01 49 =329 = 3.29V

if A1 connect with 3.31V
Send: 01 03 01 2C 00 04 84 3C
Feedback: 01 03 08 00 00 01 4B 00 00 00 00 30 08
01 4B =331 = 3.31V

Print this item