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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 10,550
» Latest member: neurobalancetec
» Forum threads: 4,337
» Forum posts: 21,344

Full Statistics

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

Latest Threads
KCS debounce option for K...
Forum: KC868-A16
Last Post: tech1977
1 hour ago
» Replies: 0
» Views: 14
[arduino code examples fo...
Forum: F32
Last Post: admin
10 hours ago
» Replies: 0
» Views: 15
[arduino code examples fo...
Forum: F32
Last Post: admin
10 hours ago
» Replies: 0
» Views: 14
KC868-A16 wiring diagram
Forum: KC868-A16
Last Post: admin
Yesterday, 09:31 PM
» Replies: 24
» Views: 22,059
N20 energy
Forum: N20
Last Post: admin
Yesterday, 09:29 PM
» Replies: 1
» Views: 20
Automatic Modbus Sensor p...
Forum: "KCS" v3 firmware
Last Post: admin
Yesterday, 09:27 PM
» Replies: 4
» Views: 115
[arduino code examples fo...
Forum: CO16
Last Post: admin
Yesterday, 04:33 AM
» Replies: 0
» Views: 20
KC868-A8 PCB V1.7 - Maxim...
Forum: KC868-A8
Last Post: admin
11-16-2026, 09:29 AM
» Replies: 1
» Views: 53
Device change after damag...
Forum: Getting Started with ESPHome and Home Assistant
Last Post: grayweird
11-16-2026, 04:43 AM
» Replies: 2
» Views: 775
CT Clamp Compatibility
Forum: KC868-M16 / M1 / MB / M30
Last Post: admin
11-14-2026, 11:38 PM
» Replies: 16
» Views: 3,843

  [arduino code examples for B2]-02 Read digital input ports state
Posted by: admin - 07-25-2026, 06:29 AM - Forum: B2 - No Replies

Code:
/*
   Made by KinCony IoT
   https://www.kincony.com

   Demo: KinCony B2 Digital Input Read
   Board: KinCony B2 (ESP32)

   Digital Input 1 -> GPIO6
   Digital Input 2 -> GPIO7
*/

#define DI1_PIN 6
#define DI2_PIN 7

// Store previous input states
int lastDI1State = HIGH;
int lastDI2State = HIGH;

void setup()
{
  // Initialize serial monitor
  Serial.begin(115200);
  Serial.println("KinCony B2 Digital Input Demo");

  // Configure digital input pins
  // Change INPUT to INPUT_PULLUP if your hardware requires internal pull-up
  pinMode(DI1_PIN, INPUT_PULLUP);
  pinMode(DI2_PIN, INPUT_PULLUP);

  // Read initial states
  lastDI1State = digitalRead(DI1_PIN);
  lastDI2State = digitalRead(DI2_PIN);

  Serial.print("DI1 Initial State: ");
  Serial.println(lastDI1State);

  Serial.print("DI2 Initial State: ");
  Serial.println(lastDI2State);
}

void loop()
{
  // Read current input states
  int di1State = digitalRead(DI1_PIN);
  int di2State = digitalRead(DI2_PIN);

  // Check if DI1 state changed
  if (di1State != lastDI1State)
  {
    lastDI1State = di1State;

    Serial.print("DI1 Changed: ");
    Serial.println(di1State);
  }

  // Check if DI2 state changed
  if (di2State != lastDI2State)
  {
    lastDI2State = di2State;

    Serial.print("DI2 Changed: ");
    Serial.println(di2State);
  }

  // Small delay for stability
  delay(10);
}
arduino ino file download:

.zip   2-digital-input.zip (Size: 697 bytes / Downloads: 187)
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: 180.26 KB / Downloads: 183)

Print this item

  [arduino code examples for B2]-01 Turn ON/OFF OUTPUT
Posted by: admin - 07-25-2026, 06:28 AM - Forum: B2 - No Replies

Code:
/*
   Made by KinCony IoT
   https://www.kincony.com

   Demo: KinCony B2 Relay Control
*/

#define RELAY1_PIN 4
#define RELAY2_PIN 46

// Relay logic (Active LOW)
#define RELAY_ON  LOW
#define RELAY_OFF HIGH

void setup()
{

  pinMode(RELAY1_PIN, OUTPUT);
  pinMode(RELAY2_PIN, OUTPUT);

  // Turn OFF both relays at startup
  digitalWrite(RELAY1_PIN, RELAY_OFF);
  digitalWrite(RELAY2_PIN, RELAY_OFF);
}

void loop()
{
  digitalWrite(RELAY1_PIN, RELAY_ON);
  delay(1000);

  digitalWrite(RELAY1_PIN, RELAY_OFF);
  delay(1000);

  digitalWrite(RELAY2_PIN, RELAY_ON);
  delay(1000);

  Serial.println("Relay 2 OFF");
  digitalWrite(RELAY2_PIN, RELAY_OFF);
  delay(1000);

  digitalWrite(RELAY1_PIN, RELAY_ON);
  digitalWrite(RELAY2_PIN, RELAY_ON);
  delay(1000);

  digitalWrite(RELAY1_PIN, RELAY_OFF);
  digitalWrite(RELAY2_PIN, RELAY_OFF);
  delay(1000);
}
arduino ino file download:

.zip   1-relay.zip (Size: 450 bytes / Downloads: 187)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:

.zip   1-relay.ino.merged.zip (Size: 179.96 KB / Downloads: 195)

Print this item

  B2 Smart Controller ESP32 system block diagram
Posted by: admin - 07-25-2026, 06:26 AM - Forum: B2 - No Replies

   

Print this item

  B2 ESPHome yaml for home assistant with tuya
Posted by: admin - 07-25-2026, 06:25 AM - Forum: B2 - No Replies

Code:
esphome:
  name: b2
  friendly_name: b2
  platformio_options:
    board_build.extra_flags:
      # WIFI_CONTROL_SELF_MODE = 0
      # WIFI_CONTROL_SELF_MODE = 1
      - "-DWIFI_CONTROL_SELF_MODE=1"

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

external_components:
  - source:
      type: git
      url: https://github.com/hzkincony/esphome-tuya-wifi-mcu
      ref: v1.3.1

# Enable logging
logger:
#   hardware_uart: USB_SERIAL_JTAG
# Enable Home Assistant API
api:

ethernet:
  type: W5500
  clk_pin: GPIO1
  mosi_pin: GPIO2
  miso_pin: GPIO41
  cs_pin: GPIO42
  interrupt_pin: GPIO43
  reset_pin: GPIO44

i2c:
   - id: bus_a
     sda: 8
     scl: 18
     scan: true
     frequency: 400kHz

uart:
  - id: uart_1    #RS485
    baud_rate: 9600
    debug:
      direction: BOTH
      dummy_receiver: true
      after:
        timeout: 10ms
    tx_pin: 38
    rx_pin: 39

  - id: tuya_mcu_uart
    tx_pin: GPIO14
    rx_pin: GPIO13
    baud_rate: 9600

tuya_wifi_mcu:
  # tuya mcu product id
  product_id: qk4eefxayleh2x5s
  uart_id: tuya_mcu_uart
  wifi_reset_pin: 28
  wifi_led_pin: 16

switch:
  - platform: uart
    uart_id: uart_1
    name: "RS485 Button"
    data: [0x11, 0x22, 0x33, 0x44, 0x55]

  - platform: gpio
    name: "b2-output01"
    id: "b2_output01"
    pin: 4
    inverted: false
  - platform: tuya_wifi_mcu
    name: b2-output1-tuya
    dp_id: 1
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b2_output01"

  - platform: gpio
    name: "b2-output02"
    id: "b2_output02"
    pin: 46
    inverted: false
  - platform: tuya_wifi_mcu
    name: b2-output2-tuya
    dp_id: 2
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b2_output02"   

binary_sensor:
  - platform: gpio
    name: "b2-input01"
    id: "b2_input01"
    pin:
      number: 6
      inverted: true
  - platform: tuya_wifi_mcu
    name: b2-input1-tuya
    dp_id: 111
    bind_binary_sensor_id: b2_input01
    internal: true


  - platform: gpio
    name: "b2-input02"
    id: "b2_input02"
    pin:
      number: 7
      inverted: true
  - platform: tuya_wifi_mcu
    name: b2-input2-tuya
    dp_id: 112
    bind_binary_sensor_id: b2_input02
    internal: true

##pull-up resistance on PCB
  - platform: gpio
    name: "b2-W1-io47"
    pin:
      number: 47
      inverted: true

  - platform: gpio
    name: "b2-W1-io48"
    pin:
      number: 48
      inverted: true

  - platform: gpio
    name: "b2-W1-io17"
    pin:
      number: 17
      inverted: true

  - platform: gpio
    name: "b2-W1-io40"
    pin:
      number: 40
      inverted: true


ads1115:
  - address: 0x48
sensor:
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 6.144
    resolution: 16_BITS
    name: "ADS1115 Channel A0-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A1_GND'
    gain: 6.144
    name: "ADS1115 Channel A1-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A2_GND'
    gain: 6.144
    name: "ADS1115 Channel A2-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A3_GND'
    gain: 6.144
    name: "ADS1115 Channel A3-GND"
    update_interval: 5s

web_server:
  port: 80

font:
  - file: "gfonts://Roboto"
    id: roboto
    size: 20

display:
  - platform: ssd1306_i2c
    i2c_id: bus_a
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(roboto), "KinCony B2");
download yaml file:

.txt   B2-HA-Tuya.txt (Size: 3.58 KB / Downloads: 203)

Print this item

  B2 ESPHome yaml for home assistant without tuya
Posted by: admin - 07-25-2026, 06:24 AM - Forum: B2 - No Replies

Code:
esphome:
  name: b2
  friendly_name: b2

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino
   

# Enable logging
logger:
   hardware_uart: USB_SERIAL_JTAG
# Enable Home Assistant API
api:

ethernet:
  type: W5500
  clk_pin: GPIO1
  mosi_pin: GPIO2
  miso_pin: GPIO41
  cs_pin: GPIO42
  interrupt_pin: GPIO43
  reset_pin: GPIO44

i2c:
   - id: bus_a
     sda: 8
     scl: 18
     scan: true
     frequency: 400kHz

uart:
  - id: uart_1    #RS485
    baud_rate: 9600
    debug:
      direction: BOTH
      dummy_receiver: true
      after:
        timeout: 10ms
    tx_pin: 38
    rx_pin: 39


switch:
  - platform: uart
    uart_id: uart_1
    name: "RS485 Button"
    data: [0x11, 0x22, 0x33, 0x44, 0x55]

  - platform: gpio
    name: "b2-output01"
    pin: 4
    inverted: false

  - platform: gpio
    name: "b2-output02"
    pin: 46
    inverted: false

binary_sensor:
  - platform: gpio
    name: "b2-input01"
    pin:
      number: 6
      inverted: true

  - platform: gpio
    name: "b2-input02"
    pin:
      number: 7
      inverted: true


##pull-up resistance on PCB
  - platform: gpio
    name: "b2-W1-io47"
    pin:
      number: 47
      inverted: true

  - platform: gpio
    name: "b2-W1-io48"
    pin:
      number: 48
      inverted: true

  - platform: gpio
    name: "b2-W1-io17"
    pin:
      number: 17
      inverted: true

  - platform: gpio
    name: "b2-W1-io40"
    pin:
      number: 40
      inverted: true


ads1115:
  - address: 0x48
sensor:
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 6.144
    resolution: 16_BITS
    name: "ADS1115 Channel A0-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A1_GND'
    gain: 6.144
    name: "ADS1115 Channel A1-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A2_GND'
    gain: 6.144
    name: "ADS1115 Channel A2-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A3_GND'
    gain: 6.144
    name: "ADS1115 Channel A3-GND"
    update_interval: 5s

web_server:
  port: 80

font:
  - file: "gfonts://Roboto"
    id: roboto
    size: 20

display:
  - platform: ssd1306_i2c
    i2c_id: bus_a
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(roboto), "KinCony B2");
download yaml file:

.txt   B2-HA-Without-Tuya.txt (Size: 2.35 KB / Downloads: 147)

Print this item

  B2 ESP32-S3 IO pins define
Posted by: admin - 07-25-2026, 06:23 AM - Forum: B2 - No Replies

IIC Bus:

SDA:GPIO8
SCL:GPIO18

24C02 EPROM i2c address: 0x50
DS3231 RTC i2c address: 0x68
SSD1306 display: i2c address:0x3c
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)


digital input-1:GPIO6
digital input-2:GPIO7

relay1:GPIO4
relay2:GPIO46

-----------------
1-wire GPIOs (with pull-up resistance on PCB):
1-wire-1:GPIO47
1-wire-2:GPIO48
1-wire-3:GPIO17
1-wire-4:GPIO40
-----------------

-----------------

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:GPIO39
TXD:GPIO38

Tuya module:
RXD:GPIO13
TXD:GPIO14

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
SPI-CD:GPIO5
--------------------
4G SIM7600
RXD:GPIO15
TXD:GPIO16

Print this item

  home assistant configuration yaml file for Pi5R8
Posted by: admin - 07-25-2026, 06:17 AM - Forum: Pi5R8 - No Replies

Code:
# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

ssd1306_i2c:
  - model: "128x64"
    address: 0x3C
    i2c_bus: 1
    rotate: 0


ads1115:
  - address: 0x48
    i2c_bus: 1
   
sensor:
  - platform: ads1115
    multiplexer: A0_GND
    gain: 4.096
    name: "A1"
    multiplier: 1.51
  - platform: ads1115
    multiplexer: A1_GND
    gain: 4.096         
    name: "A2"
    multiplier: 1.51
  - platform: ads1115
    multiplexer: A2_GND
    gain: 4.096
    name: "A3"
    multiplier: 6.67
    device_class: current
    unit_of_measurement: mA
  - platform: ads1115
    multiplexer: A3_GND
    gain: 4.096
    name: "A4"
    multiplier: 6.67
    device_class: current
    unit_of_measurement: mA
   
binary_sensor:
  - platform: mcp23017
    i2c_address: 0x20
    invert_logic: true
    pins:
      0 : Button_1
      1 : Button_2
      2 : Button_3
      3 : Button_4
      4 : Button_5
      5 : Button_6
      6 : Button_7
      7 : Button_8

switch:
  - platform: mcp23017
    i2c_address: 0x20
    hw_sync: false
    invert_logic: true
    pins:
      8 : Output_1
      9 : Output_2
      10 : Output_3
      11 : Output_4
      12 : Output_5
      13 : Output_6
      14 : Output_7
      15 : Output_8
yaml file download:

.txt   configuration-yaml.txt (Size: 1.46 KB / Downloads: 161)

Print this item

  home assistant configuration yaml file for Pi5M8
Posted by: admin - 07-25-2026, 06:17 AM - Forum: Pi5M8 - No Replies

Code:
# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

ssd1306_i2c:
  - model: "128x64"
    address: 0x3C
    i2c_bus: 1
    rotate: 0


ads1115:
  - address: 0x48
    i2c_bus: 1
   
sensor:
  - platform: ads1115
    multiplexer: A0_GND
    gain: 4.096
    name: "A1"
    multiplier: 1.51
  - platform: ads1115
    multiplexer: A1_GND
    gain: 4.096         
    name: "A2"
    multiplier: 1.51
  - platform: ads1115
    multiplexer: A2_GND
    gain: 4.096
    name: "A3"
    multiplier: 6.67
    device_class: current
    unit_of_measurement: mA
  - platform: ads1115
    multiplexer: A3_GND
    gain: 4.096
    name: "A4"
    multiplier: 6.67
    device_class: current
    unit_of_measurement: mA
   
binary_sensor:
  - platform: mcp23017
    i2c_address: 0x20
    invert_logic: true
    pins:
      0 : Button_1
      1 : Button_2
      2 : Button_3
      3 : Button_4
      4 : Button_5
      5 : Button_6
      6 : Button_7
      7 : Button_8

switch:
  - platform: mcp23017
    i2c_address: 0x20
    hw_sync: false
    invert_logic: true
    pins:
      8 : Output_1
      9 : Output_2
      10 : Output_3
      11 : Output_4
      12 : Output_5
      13 : Output_6
      14 : Output_7
      15 : Output_8
yaml file download:

.txt   configuration-yaml.txt (Size: 1.46 KB / Downloads: 143)

Print this item

  how to install home assistant for Pi5R8 beginner guide
Posted by: admin - 07-25-2026, 06:13 AM - Forum: Pi5R8 - No Replies

1. make home assistant OS SD card or SSD disk for KinCony Pi5R16.

download  https://www.raspberrypi.com/software/

2. enable i2c for home assistant.

Add files to enable I2C

In the root of the hassos-boot partition, add a new folder called CONFIG.
In the CONFIG folder, add another new folder called modules.
Inside the modules folder add a text file called rpi-i2c.conf with the following content:
i2c-dev

In the root of the hassos-boot partition, edit the file called config.txt at last add two lines to it:
dtparam=i2c_arm=on
dtoverlay=i2c1-pi5,pins_2_3

Note: if you using Windows OS computer, you can use "DiskGenius.exe" free software to modify the files. Because Linux format file not visable on windows OS. 

3. install HACS addon

https://hacs.xyz/docs/use/download/downl...supervised

4. MCP23017 implementation for Home Assistant (HA)

https://github.com/jpcornil-git/HA-mcp23017

5. KinCony SSD1306 I2C Display implementation for Home Assistant

https://github.com/hzkincony/hass-ssd1306

6. KinCony ADS1115 ADC Sensor  implementation for Home Assistant

https://github.com/hzkincony/hass-ads1115

7. config yaml for MCP23017, ADS1115

install "file edit" add-on for HA , then config configuration.yaml

https://www.kincony.com/forum/showthread.php?tid=9664

Print this item

  how to install home assistant for Pi5M8 beginner guide
Posted by: admin - 07-25-2026, 06:13 AM - Forum: Pi5M8 - No Replies

1. make home assistant OS SD card or SSD disk for KinCony Pi5M8.

download  https://www.raspberrypi.com/software/

2. enable i2c for home assistant.

Add files to enable I2C

In the root of the hassos-boot partition, add a new folder called CONFIG.
In the CONFIG folder, add another new folder called modules.
Inside the modules folder add a text file called rpi-i2c.conf with the following content:
i2c-dev

In the root of the hassos-boot partition, edit the file called config.txt at last add two lines to it:
dtparam=i2c_arm=on
dtoverlay=i2c1-pi5,pins_2_3

Note: if you using Windows OS computer, you can use "DiskGenius.exe" free software to modify the files. Because Linux format file not visable on windows OS. 

3. install HACS addon

https://hacs.xyz/docs/use/download/downl...supervised

4. MCP23017 implementation for Home Assistant (HA)

https://github.com/jpcornil-git/HA-mcp23017

5. KinCony SSD1306 I2C Display implementation for Home Assistant

https://github.com/hzkincony/hass-ssd1306

6. KinCony ADS1115 ADC Sensor  implementation for Home Assistant

https://github.com/hzkincony/hass-ads1115

7. config yaml for MCP23017, ADS1115

install "file edit" add-on for HA , then config configuration.yaml

https://www.kincony.com/forum/showthread.php?tid=9664

Print this item