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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,983
» Latest member: vidalista
» Forum threads: 3,955
» Forum posts: 20,082

Full Statistics

Online Users
There are currently 24 online users.
» 0 Member(s) | 14 Guest(s)
Baidu, Bytespider, Crawl, Google, bot

Latest Threads
N10 - no KWH shown
Forum: N10
Last Post: admin
2 hours ago
» Replies: 3
» Views: 12
N60 N30 N20 N10 ARM CPU f...
Forum: N30
Last Post: pvana
7 hours ago
» Replies: 19
» Views: 759
KC868-A16V3 - what is the...
Forum: News
Last Post: admin
04-30-2026, 09:34 PM
» Replies: 1
» Views: 16
F16 relay stopped functio...
Forum: F16
Last Post: admin
04-30-2026, 12:09 PM
» Replies: 5
» Views: 52
"KCS" v3.24.5 firmware BI...
Forum: "KCS" v3 firmware
Last Post: admin
04-29-2026, 11:38 PM
» Replies: 0
» Views: 74
Analoge input for door se...
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
04-28-2026, 11:05 PM
» Replies: 1
» Views: 50
KINCONY IN KSA
Forum: DIY Project
Last Post: Maxsys249
04-28-2026, 10:19 AM
» Replies: 10
» Views: 410
KC868-E16S/E16P demo conf...
Forum: KC868-E16S/E16P
Last Post: admin
04-26-2026, 01:01 PM
» Replies: 24
» Views: 11,705
Add uptime to board infor...
Forum: Suggestions and feedback on KinCony's products
Last Post: twostar
04-26-2026, 04:06 AM
» Replies: 7
» Views: 158
KC868-A16 rev1.6 firmware
Forum: "KCS" v2 firmware system
Last Post: admin
04-26-2026, 01:04 AM
» Replies: 5
» Views: 273

  KinCony Z1 Problem
Posted by: siwybug - 02-04-2026, 09:42 PM - Forum: KC868-AG / AG Pro / AG8 / Z1 - Replies (14)

Hello, I purchased a KinCony Z1. I have already tried many different ways of flashing various firmware versions, but the device is generally unstable. It connects to Wi-Fi and to MQTT, but nothing more than that works. No MQTT entities appear and nothing is discovered automatically. When I try to add ZigBee devices, it scans for them, detects them, pairs successfully, sends signals, and everything seems fine — but after a short while, those devices disappear.

Print this item

  Digital Input Voltage
Posted by: wojtekkk87 - 02-04-2026, 08:36 AM - Forum: T64M - Replies (1)

What is the acceptable Voltage range for the Digital Inputs?

Print this item

  DTSU 666 energy meter - any code?
Posted by: marekw - 02-03-2026, 07:13 PM - Forum: KC868-A8S - Replies (1)

I'm trying read from CHINT DTSU-666 meter, but no success. My code below. Anyone can help?

Code:
uart:
  id: mod_bus
  tx_pin: 17
  rx_pin: 16
  baud_rate: 9600
  parity: NONE
  stop_bits: 1
  data_bits: 8
  debug:
    direction: BOTH

modbus:
  id: modbus_hub
  uart_id: mod_bus
  flow_control_pin: 32

modbus_controller:
  id: dtsu666
  address: 0x02
  modbus_id: modbus_hub
  update_interval: 10s
  command_throttle: 500ms

sensor:
  - platform: modbus_controller
    modbus_controller_id: dtsu666
    name: "Test - Napięcie UA"
    address: 0x2006
    register_type: read
    value_type: FP32
    unit_of_measurement: "V"
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: dtsu666
    name: "Test - Prąd IA"
    address: 0x200C
    register_type: read
    value_type: FP32
    unit_of_measurement: "A"
    accuracy_decimals: 2
    filters:
      - multiply: 0.001

Print this item

  DM32 ESP32-S3 IO pins define
Posted by: admin - 02-03-2026, 12:35 AM - Forum: DM32 - No Replies

SDA:GPIO8
SCL:GPIO18

PCF8575: (input1-16): i2c address:0x22 by B16-core

P8:input1
P9:input2
P10:input3
P11:input4
P12:input5
P13:input6
P14:input7
P15:input8

P0:input9
P1:input10
P2:input11
P3:input12
P4:input13
P5:input14
P6:input15
P7:input16

PCF8575: (input17-32): i2c address:0x24

P0:input17
P1:input18
P2:input19
P3:input20
P4:input21
P5:input22
P6:input23
P7:input24

P8:input25
P9:input26
P10:input27
P11:input28
P12:input29
P13:input30
P14:input31
P15:input32

ADS1115 (4CH ADC): i2c address:0x48
Analog input (A1: DC 0-5v)
Analog input (A2: DC 0-5v)
Analog input (A3: DC 4-20mA)
Analog input (A4: DC 4-20mA)

24C02 EPROM i2c address: 0x50
DS3231 RTC i2c address: 0x68

1-wire (pull-up resistance on PCB):
1-wire1:GPIO47
1-wire2:GPIO48
1-wire3:GPIO7
1-wire4:GPIO40

free GPIOs:
GPIO13
GPIO14
GPIO21

-----------------------
Ethernet (W5500) I/O define:

clk_pin: GPIO1
mosi_pin: GPIO2
miso_pin: GPIO41
cs_pin: GPIO42

interrupt_pin: GPIO43
reset_pin: GPIO44

--------------------
RS485:
RXD:GPIO38
TXD:GPIO39

Tuya module:
RXD:GPIO17
TXD:GPIO16

Tuya network button: Tuya module's P28
Tuya network LED: Tuya module's P16

ARM CPU TXD:GPIO4
ARM CPU RXD:GPIO6


SD Card:
SPI-MOSI:GPIO10
SPI-SCK:GPIO11
SPI-MISO:GPIO12
SPI-CS:GPIO9
SD-Detect: GPIO5

Print this item

  [arduino code examples for DM32]-02 Read digital input ports state
Posted by: admin - 02-03-2026, 12:31 AM - Forum: DM32 - No Replies

Code:
#include <Wire.h>
#include "PCF8575.h"

#define I2C_SDA 8
#define I2C_SCL 18

PCF8575 pcf8575_IN1(0x22); // DI1–DI16
PCF8575 pcf8575_IN2(0x24); // DI17–DI32

uint8_t pin_order_dm16[16] = {
    8, 9, 10, 11, 12, 13, 14, 15,
    0, 1, 2, 3, 4, 5, 6, 7
};

uint8_t pin_order_ext[16] = {
    0, 1, 2, 3, 4, 5, 6, 7,
    8, 9, 10, 11, 12, 13, 14, 15
};

void setup() {
    Serial.begin(115200);
    Wire.begin(I2C_SDA, I2C_SCL);

    pcf8575_IN1.begin();
    pcf8575_IN2.begin();

    Serial.println("DI1–DI32 (0=ON 1=OFF)");
}

void loop() {
    Serial.print("DI1–DI32: ");

    // DI1–DI16
    for (int i = 0; i < 16; i++) {
        Serial.print(pcf8575_IN1.read(pin_order_dm16[i]));
        Serial.print(" ");
    }

    // DI17–DI32
    for (int i = 0; i < 16; i++) {
        Serial.print(pcf8575_IN2.read(pin_order_ext[i]));
        Serial.print(" ");
    }

    Serial.println();
    delay(500);
}
arduino ino file download:

.zip   2-digital-input.zip (Size: 547 bytes / Downloads: 103)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download: 

.zip   2-digital-input.ino.merged.zip (Size: 197.89 KB / Downloads: 112)

Print this item

  [arduino code examples for DM32]-01 32 Channel DAC output by digital input buttons
Posted by: admin - 02-03-2026, 12:30 AM - Forum: DM32 - No Replies

Code:
#include <Adafruit_PCF8575.h>
#include <HardwareSerial.h>

// Define Modbus RTU frame format constants
#define MODBUS_READ_COILS 0x01
#define MODBUS_READ_REGISTERS 0x03
#define MODBUS_WRITE_SINGLE_REGISTER 0x06
#define MODBUS_WRITE_MULTIPLE_REGISTERS 0x10

/* Example for 16 input buttons that are connected from the GPIO expander pins to ground.
* Note the buttons must be connected with the other side of the switch to GROUND. There is
* a built in pull-up 'resistor' on each input, but no pull-down resistor capability.
*/

#define DM_NUMS 32 // change for 16, 32 for KinCony DM16, DM32 Smart Dimmer Controller


#define SDA_PIN 8
#define SCL_PIN 18
#define ADDRESS_PCF8575     0x22
#define ADDRESS_PCF8575_2   0x24

#define ST_RX   4 ////ESP32_RCV
#define ST_TX   6 ///ESP32_SEND
typedef enum{KEY_RELEASE=0,KEY_SHORT_PRESSED,KEY_LONG_PRESSED}KEY_STATUS;

typedef struct{
  uint8_t key_index;
  KEY_STATUS key_status;
  long key_time_start;
  long key_time_rec;
  long key_press_time;
  int16_t key_press_cnt; ////Send serial data once every 100 ms
  int16_t key_press_cnt_old;
  float current_light; ///Percentage of 0–4095
}KEY_PRESS_PROP;

KEY_PRESS_PROP key_press_prop[32] = {0};


Adafruit_PCF8575 pcf,pcf2;
HardwareSerial myst_serial(1);

TwoWire myI2c = TwoWire(0);
ushort dm_num = DM_NUMS;

// Modbus CRC16 Calculation function
uint16_t modbus_crc16(uint8_t *data, uint16_t length) {
  uint16_t crc = 0xFFFF;
 
  for (uint16_t i = 0; i < length; i++) {
    crc ^= data[i];
    for (uint8_t j = 0; j < 8; j++) {
      if (crc & 0x0001) {
        crc = (crc >> 1) ^ 0xA001;
      } else {
        crc = crc >> 1;
      }
    }
  }
  return crc;
}

/**
* Send a Modbus RTU frame
*
* @param serial HardwareSerial object
* @param address Slave address (1-247)
* @param function function code
* @param data
* @param dataLen
*/
void send_modbus_frame(HardwareSerial &serial, uint8_t address, uint8_t function,
                      const uint8_t *data, uint16_t dataLen) {
  // Create a transmit buffer
  uint16_t totalLen = 1 + 1 + dataLen + 2; // address + function code + data + CRC
  uint8_t buffer[totalLen];
 
  buffer[0] = address;
  buffer[1] = function;
 
  memcpy(&buffer[2], data, dataLen);
 
  uint16_t crc = modbus_crc16(buffer, 2 + dataLen);
 
  // Add CRC (low byte first)
  buffer[2 + dataLen] = crc & 0xFF;      // CRC low byte
  buffer[3 + dataLen] = (crc >> 8) & 0xFF; // CRC high byte
 
  // Send the complete frame
  for (uint16_t i = 0; i < totalLen; i++) {
    serial.write(buffer[i]);
  }
 
  // Flush the transmit buffer to ensure all data is sent
  serial.flush();
}

// Encapsulate commonly used Modbus functions

/**
* Send a Read Holding Registers request
*
* @param serial
* @param address
* @param startReg
* @param numRegs
*/
void modbus_read_registers(HardwareSerial &serial, uint8_t address,
                          uint16_t startReg, uint16_t numRegs) {
  uint8_t data[4];
 
 
  data[0] = (startReg >> 8) & 0xFF; // High byte of the register address
  data[1] = startReg & 0xFF;        // Low byte of the register address
  data[2] = (numRegs >> 8) & 0xFF;  // High byte of the register count
  data[3] = numRegs & 0xFF;         // Low byte of the register count
 
  send_modbus_frame(serial, address, MODBUS_READ_REGISTERS, data, sizeof(data));
}

/**
*
* @param serial
* @param address
* @param regAddress
* @param value
*/
void modbus_write_single_register(HardwareSerial &serial, uint8_t address,
                                uint16_t regAddress, uint16_t value) {
  uint8_t data[4];
 
  data[0] = (regAddress >> 8) & 0xFF; // High byte of the register address
  data[1] = regAddress & 0xFF;        // Low byte of the register address
  data[2] = (value >> 8) & 0xFF;      // High byte of the data
  data[3] = value & 0xFF;             // Low byte of the
 
  send_modbus_frame(serial, address, MODBUS_WRITE_SINGLE_REGISTER, data, sizeof(data));
}

/**
*
* @param serial
* @param address
* @param startReg
* @param values
* @param numRegs
*/
void modbus_write_multiple_registers(HardwareSerial &serial, uint8_t address,
                                   uint16_t startReg, const uint16_t *values,
                                   uint16_t numRegs) {

  uint8_t byteCount = numRegs * 2;
  uint8_t data[5 + byteCount];
 

  data[0] = (startReg >> 8) & 0xFF; 
  data[1] = startReg & 0xFF;         
  data[2] = (numRegs >> 8) & 0xFF;   
  data[3] = numRegs & 0xFF;       
  data[4] = byteCount;             
 

  for (uint8_t i = 0; i < numRegs; i++) {
    data[5 + i*2] = (values[i] >> 8) & 0xFF;   
    data[6 + i*2] = values[i] & 0xFF;         
  }
 
  send_modbus_frame(serial, address, MODBUS_WRITE_MULTIPLE_REGISTERS, data, sizeof(data));
}

void setup() {
  Serial.begin(115200);
  myI2c.begin(SDA_PIN,SCL_PIN,100000);
  myst_serial.begin(115200,SERIAL_8N1,ST_RX,ST_TX);///RXPIN FIRST

  while (!Serial) { delay(10); }
  Serial.println("Adafruit PCF8575 button read test");

  if (!pcf.begin(ADDRESS_PCF8575, &myI2c)) {
    Serial.println("err:DMxx Couldn't find 1_PCF8575!");
    while (1);
  }
  else Serial.println("Find 1_PCF8575!");

  if(dm_num==32)
  {
    if (!pcf2.begin(ADDRESS_PCF8575_2, &myI2c)) {
    Serial.println("DM32 Couldn't find 2_PCF8575");
    }
    else Serial.println("Find 2_PCF8575!");
  }
   

  for (uint8_t p=0; p<DM_NUMS; p++) {
    pcf.pinMode(p, INPUT_PULLUP);
    if(dm_num==32) pcf2.pinMode(p-16, INPUT_PULLUP);
   
    key_press_prop[p].key_index = p+1;
    key_press_prop[p].key_status = KEY_RELEASE;
    key_press_prop[p].key_press_time = 0;
  }

  Serial.println("Now, starting!");


}



static uint16_t input_value_old[2] = {0xffff,0xffff};
uint16_t input_value[2] = {0} ;
int8_t current_operator_key = -1;
int8_t key_index = -1,key_index_last = -1;
int16_t key_press_cnt_old = 0;
uint16_t write_value=0;

static int8_t get_key_press(int8_t chip,uint16_t key_value)
{
  if(key_value == 0xffff || key_value == 0) return -1;

  for(int16_t i=0;i<16;i++)
  {
    if((key_value & (1<<i) ) == 0)  return (chip==0)?i:i+16;
  }
}

static uint16_t getKeycode()
{
  uint16_t input_value = 0,tmp_value;
  uint8_t h_value = 0 ,l_value = 0;
  tmp_value = pcf.digitalReadWord();
  h_value = tmp_value>>8;
  l_value = tmp_value&0xff;
  input_value = (l_value<<8 ) | h_value;

  return input_value;
}

static uint16_t getKeycode2()
{
  uint16_t input_value = 0,tmp_value;
  uint8_t h_value = 0 ,l_value = 0;
  tmp_value = pcf2.digitalReadWord();
  h_value = tmp_value>>8;
  l_value = tmp_value&0xff;
  input_value = (l_value ) | (h_value<<8);

  return input_value;
}

static void checkKeyPress(int8_t chip);

static uint16_t key_old_arr[2] = {0};

void loop() {

  input_value[0] = getKeycode();
  /*if(key_old_arr[0] != input_value[0] )
  {
    key_old_arr[0] = input_value[0];
    Serial.printf("input0:%d\r\n",input_value[0]);
  }*/
 
  checkKeyPress(0);

  if(dm_num == 32)
  {
    delay(10);
    input_value[1] = getKeycode2();
    checkKeyPress(1);
    /*if(key_old_arr[1] != input_value[1] )
    {
      key_old_arr[1] = input_value[1];
      Serial.printf("input1:%d\r\n",input_value[1]);
    }*/
  }
 


  delay(10); // a short debounce delay
}

static void checkKeyPress(int8_t chip)
{
  uint8_t start_index = (chip==0)?0:16;
  if(input_value_old[chip] != input_value[chip])
  {
    input_value_old[chip] = input_value[chip];
    if(input_value[chip] == 0xffff)
    {
      Serial.printf("key is released!");
       
      current_operator_key = -1;
      key_index_last = key_index = -1;

      for (uint8_t p=start_index; p<16+start_index; p++) ///all key status init.
      {
        key_press_prop[p].key_index = p+1;
        key_press_prop[p].key_status = KEY_RELEASE;
        key_press_prop[p].key_time_start = 0;
        key_press_prop[p].key_press_time = 0;
        key_press_prop[p].key_time_rec = 0;
        key_press_prop[p].key_press_cnt = 0;
        key_press_prop[p].key_press_cnt_old = 0;
      }
    }
    else ///key press
    {
      //Serial.printf("input_value = %04X \r\n",input_value);
      key_index = get_key_press(chip,input_value[chip]);
      if(key_index >= 0)
      {
        key_index_last = key_index;
        Serial.printf("key %02d # is pressed! \r\n",key_index+1);
        current_operator_key = key_index;
        key_press_prop[current_operator_key].key_status = KEY_SHORT_PRESSED;
        key_press_prop[current_operator_key].key_time_start = millis();
        key_press_prop[current_operator_key].key_press_time = 0;
      }
    }
  }
  else
  {
    if(input_value[chip] != 0xffff) ///LONG PRESS!
    {
      //Serial.printf("key long pressed! \r\n");

      key_index = get_key_press(chip,input_value[chip]);
      if(key_index >= 0 && key_index_last == key_index)
      {
        //Serial.printf("key long pressed! key_index = %d\r\n",key_index);

        current_operator_key = key_index;
        key_press_prop[current_operator_key].key_status = KEY_LONG_PRESSED;
        key_press_prop[current_operator_key].key_time_rec = millis();
        key_press_prop[current_operator_key].key_press_time = key_press_prop[current_operator_key].key_time_rec - key_press_prop[current_operator_key].key_time_start;
        key_press_prop[current_operator_key].key_press_cnt = (key_press_prop[current_operator_key].key_press_time % 4080 ) / 100; ////100MS发一次

        //Serial.printf("key long time = %d, cnt = %d \r\n",key_press_prop[current_operator_key].key_press_time,key_press_prop[current_operator_key].key_press_cnt);

        if(key_press_prop[current_operator_key].key_press_cnt_old != key_press_prop[current_operator_key].key_press_cnt)
        {
          key_press_prop[current_operator_key].key_press_cnt_old = key_press_prop[current_operator_key].key_press_cnt;
          /////send st_tx information.
          key_press_prop[current_operator_key].current_light = (float)key_press_prop[current_operator_key].key_press_cnt * 100.0f;
          write_value = (uint16_t) key_press_prop[current_operator_key].current_light;

          Serial.printf("key_long_press_time = %d, current_light = %d \r\n",key_press_prop[current_operator_key].key_press_time,write_value);

          modbus_write_multiple_registers(myst_serial,1,4000+current_operator_key,&write_value,1);


        }
      }
    }
  }

}
arduino ino file download:

.zip   1-dac-32ch.zip (Size: 2.95 KB / Downloads: 117)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:

.zip   1-dac-32ch.ino.merged.zip (Size: 205.71 KB / Downloads: 97)

Print this item

  DM8 DM16 DM32 PC software using USB-RS485 adapter
Posted by: admin - 02-03-2026, 12:27 AM - Forum: DM16 - No Replies

   
PC software download:
.zip   DMxx_SIMPLE1220.zip (Size: 1.66 MB / Downloads: 97)

Print this item

  DM8 DM16 DM32 PC software using USB-RS485 adapter
Posted by: admin - 02-03-2026, 12:27 AM - Forum: DM8 - No Replies

   
PC software download:
.zip   DMxx_SIMPLE1220.zip (Size: 1.66 MB / Downloads: 131)

Print this item

  DM8 DM16 DM32 PC software using USB-RS485 adapter
Posted by: admin - 02-03-2026, 12:27 AM - Forum: DM32 - No Replies

   
PC software download:
.zip   DMxx_SIMPLE1220.zip (Size: 1.66 MB / Downloads: 103)

Print this item

  DM8 ESP32-S3 IO pins define
Posted by: admin - 02-03-2026, 12:23 AM - Forum: DM8 - No Replies

SDA:GPIO8
SCL:GPIO18

PCF8574: (input1-8): i2c address:0x24

P0:input1
P1:input2
P2:input3
P3:input4
P4:input5
P5:input6
P6:input7
P7:input8

ADS1115 (4CH ADC): i2c address:0x48
Analog input (A1: DC 0-5v)
Analog input (A2: DC 0-5v)
Analog input (A3: DC 4-20mA)
Analog input (A4: DC 4-20mA)

24C02 EPROM i2c address: 0x50
DS3231 RTC i2c address: 0x68



1-wire (pull-up resistance on PCB):
1-wire1:GPIO47
1-wire2:GPIO48
1-wire3:GPIO17
1-wire4:GPIO40

free GPIOs:
GPIO13
GPIO14
GPIO21

-----------------------
Ethernet (W5500) I/O define:

clk_pin: GPIO1
mosi_pin: GPIO2
miso_pin: GPIO41
cs_pin: GPIO42

interrupt_pin: GPIO43
reset_pin: GPIO44

--------------------
RS485:
RXD:GPIO38
TXD:GPIO39

Tuya module:
RXD:GPIO15
TXD:GPIO16

Tuya network button: Tuya module's P28
Tuya network LED: Tuya module's P16

SD Card:
SPI-MOSI:GPIO10
SPI-SCK:GPIO11
SPI-MISO:GPIO12
SPI-CS:GPIO9
SD-Detect: GPIO5

ARM CPU TXD:GPIO4
ARM CPU RXD:GPIO6

Print this item