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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,769
» Latest member: henrycavil
» Forum threads: 3,838
» Forum posts: 19,632

Full Statistics

Online Users
There are currently 44 online users.
» 0 Member(s) | 31 Guest(s)
AhrefsBot, Amazonbot, Crawl, Google, PetalBot, Yandex, bot

Latest Threads
A8 brick
Forum: KC868-A series and Uair Smart Controller
Last Post: kid
5 hours ago
» Replies: 2
» Views: 10
kWh resolution
Forum: N30
Last Post: Painy
6 hours ago
» Replies: 26
» Views: 715
KC868-M16v2 configure yam...
Forum: KC868-M16 / M1 / MB / M30
Last Post: admin
7 hours ago
» Replies: 157
» Views: 32,245
KC868-A16 ethernet work w...
Forum: KC868-A16
Last Post: admin
7 hours ago
» Replies: 29
» Views: 18,515
Kincony KC868-A16 (ESP32)...
Forum: KC868-A16
Last Post: admin
Yesterday, 11:37 PM
» Replies: 1
» Views: 10
Dimensions for KC868-E16 ...
Forum: Schematic & diagram & Dimensions of KinCony PCB layout CAD file
Last Post: davisjame
Yesterday, 08:29 AM
» Replies: 5
» Views: 1,685
DM32 ESPHome yaml for hom...
Forum: DM32
Last Post: admin
Yesterday, 12:50 AM
» Replies: 0
» Views: 6
DM8 ESPHome yaml for home...
Forum: DM8
Last Post: admin
Yesterday, 12:49 AM
» Replies: 0
» Views: 9
How restart а board using...
Forum: "KCS" v2 firmware system
Last Post: admin
03-16-2026, 11:45 PM
» Replies: 1
» Views: 23
Battery backup model on A...
Forum: AIO Hybrid
Last Post: admin
03-16-2026, 10:54 AM
» Replies: 1
» Views: 10

  [arduino code examples for B4M]-02 Read digital input ports state
Posted by: admin - 01-14-2026, 03:52 AM - Forum: B4M - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* Description:
* This Arduino program reads the state of a 16-channel PCF8574 I/O expander
* and prints the state of all input pins to the Serial Monitor. The state of
* each pin is represented as a bit in a 8-bit value, where each bit corresponds
* to an input pin. The program prints the input state in binary format.
*
* Pin Definitions:
* - SDA: GPIO 21
* - SCL: GPIO 22
* - PCF8575 I2C Address: 0x24
*/

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

// Define I2C pins
#define I2C_SDA 8  // Define SDA pin
#define I2C_SCL 18  // Define SCL pin

// Set I2C address
PCF8574 pcf8574_IN1(0x24); // The I2C address of the PCF8575

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

    // Initialize I2C communication
    Wire.begin(I2C_SDA, I2C_SCL); // Initialize I2C with defined SDA and SCL pins

    pcf8574_IN1.pinMode(P0, INPUT);
    pcf8574_IN1.pinMode(P1, INPUT);
    pcf8574_IN1.pinMode(P2, INPUT);
    pcf8574_IN1.pinMode(P3, INPUT);

    pcf8574_IN1.begin(); // Initialize the PCF8575

    Serial.println("KinCony F4 4 channel input state 0:ON  1:OFF");
}

void loop() {
    uint16_t state = 0;

    // Read the state of each pin (assuming 16 pins)
    for (int pin = 0; pin < 4; pin++) {
        if (pcf8574_IN1.digitalRead(pin)) {
            state |= (1 << pin); // Set the bit for the active pin
        }
    }

    Serial.print("Input state: ");
    Serial.println(state, BIN); // Print the state of inputs in binary

    delay(500); // Delay 500ms
}
arduino ino file download:

.zip   2-digital-input.zip (Size: 879 bytes / Downloads: 86)
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: 199.52 KB / Downloads: 94)

Print this item

  [arduino code examples for B4]-01 Turn ON/OFF OUTPUT
Posted by: admin - 01-14-2026, 03:49 AM - Forum: B4 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* This program controls a 8-channel relay board via a PCF8574 I/O expander.
* It sequentially turns on each relay and then turns them off in a loop.
*
* Pin Definitions:
* - SDA: GPIO 8
* - SCL: GPIO 18
*
* Delay Time:
* - 200 milliseconds between switching relays
*/

#include <Wire.h>        // Include the Wire library for I2C communication
#include <PCF8574.h>     // Include the PCF8575 library to control the I/O expander

#define SDA 8            // Define the SDA pin
#define SCL 18           // Define the SCL pin
#define DELAY_TIME 200   // Define the delay time in milliseconds

// Set I2C address of the PCF8575 module
#define I2C_ADDRESS 0x24 // I2C address of the PCF8575 module

PCF8574 pcf8574_R1(I2C_ADDRESS); // Create a PCF8575 object with the specified I2C address

void setup() {
  // Initialize I2C communication
  Wire.begin(SDA, SCL); // SDA on GPIO 8, SCL on GPIO 18 (according to your board's configuration)
 
  // Initialize serial communication for debugging (optional)
  Serial.begin(115200);
  Serial.println("PCF8575 Relay Control: Starting...");

    pcf8574_R1.pinMode(P4, OUTPUT);
  pcf8574_R1.pinMode(P5, OUTPUT);
  pcf8574_R1.pinMode(P6, OUTPUT);
  pcf8574_R1.pinMode(P7, OUTPUT);

  // Initialize the PCF8575 module
  pcf8574_R1.begin();

  // Turn off all relays initially (set all pins HIGH)
  for (int i = 4; i < 8; i++) {
    pcf8574_R1.digitalWrite(i, HIGH); // Set all relays to OFF (assuming HIGH means OFF for relays)
  }
}

void loop() {
  // Sequentially turn on each relay
  for (int i = 4; i < 8; i++) {
    pcf8574_R1.digitalWrite(i, LOW);   // Turn on the relay at pin i (LOW means ON for the relay)
    delay(DELAY_TIME);          // Wait for DELAY_TIME milliseconds
  }

  // Sequentially turn off each relay
  for (int i = 4; i < 8; i++) {
    pcf8574_R1.digitalWrite(i, HIGH);  // Turn off the relay at pin i (HIGH means OFF for the relay)
    delay(DELAY_TIME);          // Wait for DELAY_TIME milliseconds
  }
}
arduino ino file download:

.zip   1-relay.zip (Size: 964 bytes / Downloads: 75)
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: 199.39 KB / Downloads: 60)

Print this item

  [arduino code examples for B4M]-01 Turn ON/OFF OUTPUT
Posted by: admin - 01-14-2026, 03:49 AM - Forum: B4M - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* This program controls a 8-channel relay board via a PCF8574 I/O expander.
* It sequentially turns on each relay and then turns them off in a loop.
*
* Pin Definitions:
* - SDA: GPIO 8
* - SCL: GPIO 18
*
* Delay Time:
* - 200 milliseconds between switching relays
*/

#include <Wire.h>        // Include the Wire library for I2C communication
#include <PCF8574.h>     // Include the PCF8575 library to control the I/O expander

#define SDA 8            // Define the SDA pin
#define SCL 18           // Define the SCL pin
#define DELAY_TIME 200   // Define the delay time in milliseconds

// Set I2C address of the PCF8575 module
#define I2C_ADDRESS 0x24 // I2C address of the PCF8575 module

PCF8574 pcf8574_R1(I2C_ADDRESS); // Create a PCF8575 object with the specified I2C address

void setup() {
  // Initialize I2C communication
  Wire.begin(SDA, SCL); // SDA on GPIO 8, SCL on GPIO 18 (according to your board's configuration)
 
  // Initialize serial communication for debugging (optional)
  Serial.begin(115200);
  Serial.println("PCF8575 Relay Control: Starting...");

    pcf8574_R1.pinMode(P4, OUTPUT);
  pcf8574_R1.pinMode(P5, OUTPUT);
  pcf8574_R1.pinMode(P6, OUTPUT);
  pcf8574_R1.pinMode(P7, OUTPUT);

  // Initialize the PCF8575 module
  pcf8574_R1.begin();

  // Turn off all relays initially (set all pins HIGH)
  for (int i = 4; i < 8; i++) {
    pcf8574_R1.digitalWrite(i, HIGH); // Set all relays to OFF (assuming HIGH means OFF for relays)
  }
}

void loop() {
  // Sequentially turn on each relay
  for (int i = 4; i < 8; i++) {
    pcf8574_R1.digitalWrite(i, LOW);   // Turn on the relay at pin i (LOW means ON for the relay)
    delay(DELAY_TIME);          // Wait for DELAY_TIME milliseconds
  }

  // Sequentially turn off each relay
  for (int i = 4; i < 8; i++) {
    pcf8574_R1.digitalWrite(i, HIGH);  // Turn off the relay at pin i (HIGH means OFF for the relay)
    delay(DELAY_TIME);          // Wait for DELAY_TIME milliseconds
  }
}
arduino ino file download:

.zip   1-relay.zip (Size: 964 bytes / Downloads: 77)
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: 199.39 KB / Downloads: 78)

Print this item

  B4 ESPHome yaml for home assistant with tuya
Posted by: admin - 01-14-2026, 03:46 AM - Forum: B4 - No Replies

Code:
esphome:
  name: b4
  friendly_name: b4
  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.0

# 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

pcf8574:
  - id: 'pcf8574_hub_out_1'  # for output channel 0-7| input channel 8-15   
    i2c_id: bus_a
    address: 0x24

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: GPIO15
    rx_pin: GPIO16
    baud_rate: 9600

tuya_wifi_mcu:
  # tuya mcu product id
  product_id: fotgrf8rowhk1nm3
  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: "b4-output01"
    id: "b4_output01"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-output1-tuya
    dp_id: 1
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b4_output01"

  - platform: gpio
    name: "b4-output02"
    id: "b4_output02"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-output2-tuya
    dp_id: 2
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b4_output02"

  - platform: gpio
    name: "b4-output03"
    id: "b4_output03"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-output3-tuya
    dp_id: 3
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b4_output03"

  - platform: gpio
    name: "b4-output04"
    id: "b4_output04"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-output4-tuya
    dp_id: 4
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b4_output04"

binary_sensor:
  - platform: gpio
    name: "b4-input01"
    id: "b4_input01"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-input1-tuya
    dp_id: 111
    bind_binary_sensor_id: b4_input01
    internal: true

  - platform: gpio
    name: "b4-input02"
    id: "b4_input02"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-input2-tuya
    dp_id: 112
    bind_binary_sensor_id: b4_input02
    internal: true

  - platform: gpio
    name: "b4-input03"
    id: "b4_input03"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-input3-tuya
    dp_id: 113
    bind_binary_sensor_id: b4_input03
    internal: true

  - platform: gpio
    name: "b4-input04"
    id: "b4_input04"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-input4-tuya
    dp_id: 114
    bind_binary_sensor_id: b4_input04
    internal: true

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

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

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

  - platform: gpio
    name: "b8-W1-io40"
    pin:
      number: 40
      inverted: true
## without resistance on PCB
  - platform: gpio
    name: "b8-13"
    pin:
      number: 13
      inverted:  false
  - platform: gpio
    name: "b8-14"
    pin:
      number: 14
      inverted:  false
  - platform: gpio
    name: "b8-21"
    pin:
      number: 21
      inverted:  false
  - platform: gpio
    name: "b8-0"
    pin:
      number: 0
      inverted:  false

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 B4");
download yaml file:

.txt   B4-HA-Tuya.txt (Size: 5.63 KB / Downloads: 56)

Print this item

  B4M ESPHome yaml for home assistant with tuya
Posted by: admin - 01-14-2026, 03:46 AM - Forum: B4M - No Replies

Code:
esphome:
  name: b4
  friendly_name: b4
  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.0

# 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

pcf8574:
  - id: 'pcf8574_hub_out_1'  # for output channel 0-7| input channel 8-15   
    i2c_id: bus_a
    address: 0x24

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: GPIO15
    rx_pin: GPIO16
    baud_rate: 9600

tuya_wifi_mcu:
  # tuya mcu product id
  product_id: fotgrf8rowhk1nm3
  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: "b4-output01"
    id: "b4_output01"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-output1-tuya
    dp_id: 1
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b4_output01"

  - platform: gpio
    name: "b4-output02"
    id: "b4_output02"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-output2-tuya
    dp_id: 2
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b4_output02"

  - platform: gpio
    name: "b4-output03"
    id: "b4_output03"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-output3-tuya
    dp_id: 3
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b4_output03"

  - platform: gpio
    name: "b4-output04"
    id: "b4_output04"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-output4-tuya
    dp_id: 4
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b4_output04"

binary_sensor:
  - platform: gpio
    name: "b4-input01"
    id: "b4_input01"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-input1-tuya
    dp_id: 111
    bind_binary_sensor_id: b4_input01
    internal: true

  - platform: gpio
    name: "b4-input02"
    id: "b4_input02"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-input2-tuya
    dp_id: 112
    bind_binary_sensor_id: b4_input02
    internal: true

  - platform: gpio
    name: "b4-input03"
    id: "b4_input03"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-input3-tuya
    dp_id: 113
    bind_binary_sensor_id: b4_input03
    internal: true

  - platform: gpio
    name: "b4-input04"
    id: "b4_input04"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: b4-input4-tuya
    dp_id: 114
    bind_binary_sensor_id: b4_input04
    internal: true

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

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

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

  - platform: gpio
    name: "b8-W1-io40"
    pin:
      number: 40
      inverted: true
## without resistance on PCB
  - platform: gpio
    name: "b8-13"
    pin:
      number: 13
      inverted:  false
  - platform: gpio
    name: "b8-14"
    pin:
      number: 14
      inverted:  false
  - platform: gpio
    name: "b8-21"
    pin:
      number: 21
      inverted:  false
  - platform: gpio
    name: "b8-0"
    pin:
      number: 0
      inverted:  false

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 B4");
download yaml file:

.txt   B4-HA-Tuya.txt (Size: 5.63 KB / Downloads: 59)

Print this item

  B4 ESPHome yaml for home assistant without tuya
Posted by: admin - 01-14-2026, 03:45 AM - Forum: B4 - No Replies

Code:
esphome:
  name: b4
  friendly_name: b4

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

pcf8574:
  - id: 'pcf8574_hub_out_1'  # for output channel 0-7| input channel 8-15   
    i2c_id: bus_a
    address: 0x24

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: "b4-output01"
    id: "b4_output01"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "b4-output02"
    id: "b4_output02"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "b4-output03"
    id: "b4_output03"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "b4-output04"
    id: "b4_output04"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true


binary_sensor:
  - platform: gpio
    name: "b4-input01"
    id: "b4_input01"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "b4-input02"
    id: "b4_input02"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "b4-input03"
    id: "b4_input03"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "b4-input04"
    id: "b4_input04"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: INPUT
      inverted: true


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

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

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

  - platform: gpio
    name: "b8-W1-io40"
    pin:
      number: 40
      inverted: true
## without resistance on PCB
  - platform: gpio
    name: "b8-13"
    pin:
      number: 13
      inverted:  false
  - platform: gpio
    name: "b8-14"
    pin:
      number: 14
      inverted:  false
  - platform: gpio
    name: "b8-21"
    pin:
      number: 21
      inverted:  false
  - platform: gpio
    name: "b8-0"
    pin:
      number: 0
      inverted:  false

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 B4");
download yaml file:

.txt   B4-HA-Without-Tuya.txt (Size: 3.87 KB / Downloads: 49)

Print this item

  B4M ESPHome yaml for home assistant without tuya
Posted by: admin - 01-14-2026, 03:45 AM - Forum: B4M - No Replies

Code:
esphome:
  name: b4
  friendly_name: b4

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

pcf8574:
  - id: 'pcf8574_hub_out_1'  # for output channel 0-7| input channel 8-15   
    i2c_id: bus_a
    address: 0x24

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: "b4-output01"
    id: "b4_output01"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "b4-output02"
    id: "b4_output02"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "b4-output03"
    id: "b4_output03"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "b4-output04"
    id: "b4_output04"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true


binary_sensor:
  - platform: gpio
    name: "b4-input01"
    id: "b4_input01"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "b4-input02"
    id: "b4_input02"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "b4-input03"
    id: "b4_input03"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "b4-input04"
    id: "b4_input04"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: INPUT
      inverted: true


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

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

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

  - platform: gpio
    name: "b8-W1-io40"
    pin:
      number: 40
      inverted: true
## without resistance on PCB
  - platform: gpio
    name: "b8-13"
    pin:
      number: 13
      inverted:  false
  - platform: gpio
    name: "b8-14"
    pin:
      number: 14
      inverted:  false
  - platform: gpio
    name: "b8-21"
    pin:
      number: 21
      inverted:  false
  - platform: gpio
    name: "b8-0"
    pin:
      number: 0
      inverted:  false

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 B4");
download yaml file:

.txt   B4-HA-Without-Tuya.txt (Size: 3.87 KB / Downloads: 55)

Print this item

  B4 ESP32-S3 IO pins define
Posted by: admin - 01-14-2026, 03:43 AM - Forum: B4 - No Replies

IIC Bus:

SDA:GPIO8
SCL:GPIO18

PCF8574: i2c address:0x24

PCF8574->P0 (digital input-1)
PCF8574->P1 (digital input-2)
PCF8574->P2 (digital input-3)
PCF8574->P3 (digital input-4)

PCF8574->P4 (relay1)
PCF8574->P5 (relay2)
PCF8574->P6 (relay3)
PCF8574->P7 (relay4)

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)


-----------------
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
-----------------
free GPIOs (without pull-up resistance on PCB):
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:GPIO39
TXD:GPIO38

Tuya module:
RXD:GPIO16
TXD:GPIO15

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

Print this item

  B4M ESP32-S3 IO pins define
Posted by: admin - 01-14-2026, 03:42 AM - Forum: B4M - No Replies

IIC Bus:

SDA:GPIO8
SCL:GPIO18

PCF8574: i2c address:0x24

PCF8574->P0 (digital input-1)
PCF8574->P1 (digital input-2)
PCF8574->P2 (digital input-3)
PCF8574->P3 (digital input-4)

PCF8574->P4 (relay1)
PCF8574->P5 (relay2)
PCF8574->P6 (relay3)
PCF8574->P7 (relay4)

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)


-----------------
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
-----------------
free GPIOs (without pull-up resistance on PCB):
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:GPIO39
TXD:GPIO38

Tuya module:
RXD:GPIO16
TXD:GPIO15

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

Print this item

  B24M output mosfet relay load voltage
Posted by: Alex1987new - 01-13-2026, 08:22 AM - Forum: B24M - Replies (3)

Hello
There is info about output mosfet:
24CH MOSFET Outputs, every channel use MAX 10A driver IC

what kind on load I can put on it?
can I connect to ouput 220V? the load will be some lamp 220V 75W
or only DC 12-24V and connecting "-" minus ?

Print this item