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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 9,584
» Latest member: soicauxsmbioo
» Forum threads: 4,191
» Forum posts: 20,830

Full Statistics

Online Users
There are currently 48 online users.
» 0 Member(s) | 38 Guest(s)
Amazonbot, Applebot, Baidu, Bing, PetalBot, bot

Latest Threads
N60 Sensor channel label
Forum: N60
Last Post: admin
3 hours ago
» Replies: 17
» Views: 2,104
solar production and cons...
Forum: N30
Last Post: admin
4 hours ago
» Replies: 3
» Views: 5
Current direction detecti...
Forum: N30
Last Post: admin
4 hours ago
» Replies: 3
» Views: 7
MQTT Discovery: missing s...
Forum: N30
Last Post: admin
Yesterday, 02:48 PM
» Replies: 1
» Views: 3
ai automation
Forum: KinCony integrate with Loxone home automation
Last Post: mediverticals
Yesterday, 06:56 AM
» Replies: 0
» Views: 5
Connecting sensors to Kin...
Forum: F16
Last Post: admin
Yesterday, 12:18 AM
» Replies: 1
» Views: 11
CT Sensor Direction
Forum: N60
Last Post: admin
08-12-2026, 08:14 AM
» Replies: 1
» Views: 14
N60 Voltage reference
Forum: N60
Last Post: admin
08-11-2026, 11:09 PM
» Replies: 3
» Views: 26
4-20mA loop voltage consi...
Forum: B4M
Last Post: admin
08-11-2026, 08:05 AM
» Replies: 1
» Views: 23
K868-a32 plastic case
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
08-10-2026, 08:48 AM
» Replies: 3
» Views: 1,187

  [arduino code examples for B2]-06 How to use SD Card
Posted by: admin - 07-25-2026, 06:35 AM - Forum: B2 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* SD Card File Operations
*
* This program demonstrates basic file operations on an SD card using the ESP32.
* It includes functionality to:
* - Initialize and test the SD card
* - Read from, write to, append to, and delete files on the SD card
* - Measure file read and write performance
*
* Hardware Connections:
* - SCK: GPIO 11
* - MISO: GPIO 12
* - MOSI: GPIO 10
* - CS: GPIO 9
*/

#include "FS.h"
#include "SD.h"
#include "SPI.h"

// Pin definitions for SD card
#define SCK  11
#define MISO 12
#define MOSI 10
#define CS   9

/**
* @brief Reads the contents of a file from the SD card and prints it to the serial monitor.
*
* @param fs File system to use (in this case, SD).
* @param path Path of the file to read.
*/
void readFile(fs::FS &fs, const char * path) {
  Serial.printf("Reading file: %s\n", path);

  File file = fs.open(path);
  if (!file) {
    Serial.println("Failed to open file for reading");
    return;
  }

  Serial.print("Read from file: ");
  while (file.available()) {
    Serial.print((char)file.read());
  }
  file.close();
}

/**
* @brief Writes a message to a file on the SD card.
*
* @param fs File system to use (in this case, SD).
* @param path Path of the file to write.
* @param message Message to write to the file.
*/
void writeFile(fs::FS &fs, const char * path, const char * message) {
  Serial.printf("Writing file: %s\n", path);

  File file = fs.open(path, FILE_WRITE);
  if (!file) {
    Serial.println("Failed to open file for writing");
    return;
  }
  if (file.print(message)) {
    Serial.println("File written");
  } else {
    Serial.println("Write failed");
  }
  file.close();
}

/**
* @brief Appends a message to a file on the SD card.
*
* @param fs File system to use (in this case, SD).
* @param path Path of the file to append.
* @param message Message to append to the file.
*/
void appendFile(fs::FS &fs, const char * path, const char * message) {
  Serial.printf("Appending to file: %s\n", path);

  File file = fs.open(path, FILE_APPEND);
  if (!file) {
    Serial.println("Failed to open file for appending");
    return;
  }
  if (file.print(message)) {
    Serial.println("Message appended");
  } else {
    Serial.println("Append failed");
  }
  file.close();
}

/**
* @brief Deletes a file from the SD card.
*
* @param fs File system to use (in this case, SD).
* @param path Path of the file to delete.
*/
void deleteFile(fs::FS &fs, const char * path) {
  Serial.printf("Deleting file: %s\n", path);
  if (fs.remove(path)) {
    Serial.println("File deleted");
  } else {
    Serial.println("Delete failed");
  }
}

/**
* @brief Tests file read and write performance.
*
* @param fs File system to use (in this case, SD).
* @param path Path of the file to test.
*/
void testFileIO(fs::FS &fs, const char * path) {
  File file = fs.open(path);
  static uint8_t buf[512];
  size_t len = 0;
  uint32_t start = millis();
  uint32_t end = start;

  if (file) {
    len = file.size();
    size_t flen = len;
    start = millis();
    while (len) {
      size_t toRead = len;
      if (toRead > 512) {
        toRead = 512;
      }
      file.read(buf, toRead);
      len -= toRead;
    }
    end = millis() - start;
    Serial.printf("%u bytes read for %u ms\n", flen, end);
    file.close();
  } else {
    Serial.println("Failed to open file for reading");
  }

  file = fs.open(path, FILE_WRITE);
  if (!file) {
    Serial.println("Failed to open file for writing");
    return;
  }

  size_t i;
  start = millis();
  for (i = 0; i < 2048; i++) {
    file.write(buf, 512);
  }
  end = millis() - start;
  Serial.printf("%u bytes written for %u ms\n", 2048 * 512, end);
  file.close();
}

void setup() {
  // Initialize serial communication
  Serial.begin(115200);
 
  // Initialize SPI and SD card
  SPIClass spi = SPIClass(HSPI);
  spi.begin(SCK, MISO, MOSI, CS);

  if (!SD.begin(CS, spi, 80000000)) {
    Serial.println("Card Mount Failed");
    return;
  }

  uint8_t cardType = SD.cardType();

  if (cardType == CARD_NONE) {
    Serial.println("No SD card attached");
    return;
  }

  Serial.print("SD Card Type: ");
  if (cardType == CARD_MMC) {
    Serial.println("MMC");
  } else if (cardType == CARD_SD) {
    Serial.println("SDSC");
  } else if (cardType == CARD_SDHC) {
    Serial.println("SDHC");
  } else {
    Serial.println("UNKNOWN");
  }

  uint64_t cardSize = SD.cardSize() / (1024 * 1024);
  Serial.printf("SD Card Size: %lluMB\n", cardSize);
  delay(2000);

  // Perform file operations
  deleteFile(SD, "/hello.txt");
  writeFile(SD, "/hello.txt", "Hello ");
  appendFile(SD, "/hello.txt", "World!\n");
  readFile(SD, "/hello.txt");
  testFileIO(SD, "/test.txt");
  Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024));
  Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024));
}

void loop() {
  // No operation in loop
}
arduino ino file download: 

.zip   6-SD.zip (Size: 1.53 KB / Downloads: 76)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download: 

.zip   6-SD.ino.merged.zip (Size: 219.15 KB / Downloads: 77)

Print this item

  [arduino code examples for B2]-05 Read free GPIO state
Posted by: admin - 07-25-2026, 06:33 AM - Forum: B2 - No Replies

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

   Demo: KinCony B2 GPIO State Monitor
   Board: KinCony B2 (ESP32)

   1-Wire-1 -> GPIO47
   1-Wire-2 -> GPIO48
   1-Wire-3 -> GPIO17
   1-Wire-4 -> GPIO40
*/

#define GPIO1_PIN 47
#define GPIO2_PIN 48
#define GPIO3_PIN 17
#define GPIO4_PIN 40

// Store previous GPIO states
int lastState1;
int lastState2;
int lastState3;
int lastState4;

void setup()
{
  // Initialize serial monitor
  Serial.begin(115200);
  Serial.println("KinCony B2 GPIO State Monitor");

  // Configure GPIOs as inputs
  // Change INPUT to INPUT_PULLUP if required by your hardware
  pinMode(GPIO1_PIN, INPUT);
  pinMode(GPIO2_PIN, INPUT);
  pinMode(GPIO3_PIN, INPUT);
  pinMode(GPIO4_PIN, INPUT);

  // Read initial states
  lastState1 = digitalRead(GPIO1_PIN);
  lastState2 = digitalRead(GPIO2_PIN);
  lastState3 = digitalRead(GPIO3_PIN);
  lastState4 = digitalRead(GPIO4_PIN);

  // Print initial states
  Serial.printf("GPIO47 Initial: %d\n", lastState1);
  Serial.printf("GPIO48 Initial: %d\n", lastState2);
  Serial.printf("GPIO17 Initial: %d\n", lastState3);
  Serial.printf("GPIO40 Initial: %d\n", lastState4);
}

void loop()
{
  int state;

  // Check GPIO47
  state = digitalRead(GPIO1_PIN);
  if (state != lastState1)
  {
    lastState1 = state;
    Serial.printf("GPIO47 Changed: %d\n", state);
  }

  // Check GPIO48
  state = digitalRead(GPIO2_PIN);
  if (state != lastState2)
  {
    lastState2 = state;
    Serial.printf("GPIO48 Changed: %d\n", state);
  }

  // Check GPIO17
  state = digitalRead(GPIO3_PIN);
  if (state != lastState3)
  {
    lastState3 = state;
    Serial.printf("GPIO17 Changed: %d\n", state);
  }

  // Check GPIO40
  state = digitalRead(GPIO4_PIN);
  if (state != lastState4)
  {
    lastState4 = state;
    Serial.printf("GPIO40 Changed: %d\n", state);
  }

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

.zip   5-free-gpio-state.zip (Size: 757 bytes / Downloads: 57)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:

.zip   5-free-gpio-state.ino.merged.zip (Size: 180.31 KB / Downloads: 50)

Print this item

  [arduino code examples for B2]-04 RS485 communication test
Posted by: admin - 07-25-2026, 06:32 AM - Forum: B2 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* RS485 Communication Test
*
* This program is a simple test for RS485 communication using ESP32-S3.
* It will send a message over RS485 and then read incoming messages.
* The TXD pin is defined as GPIO 18 and RXD pin is defined as GPIO 8.
*/

#include <HardwareSerial.h>

// Define RS485 pins
#define RS485_RXD 39
#define RS485_TXD 38

// Create a hardware serial object
HardwareSerial rs485Serial(1);

void setup() {
  // Start serial communication for debugging
  Serial.begin(115200);
  while (!Serial);

  // Initialize RS485 Serial communication
  rs485Serial.begin(9600, SERIAL_8N1, RS485_RXD, RS485_TXD);
 
  Serial.println("RS485 Test Start");
}

void loop() {
  // Send a test message
  rs485Serial.println("Hello from KinCony");

  // Wait for a short period
  delay(1000);

  // Check if data is available to read
  if (rs485Serial.available()) {
    String receivedMessage = "";
    while (rs485Serial.available()) {
      char c = rs485Serial.read();
      receivedMessage += c;
    }
    // Print the received message
    Serial.print("Received: ");
    Serial.println(receivedMessage);
  }

  // Wait before sending the next message
  delay(2000);
}
arduino ino file download: 

.zip   4-RS485-Test.zip (Size: 758 bytes / Downloads: 62)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download: 

.zip   4-RS485-Test.ino.merged.zip (Size: 185.84 KB / Downloads: 48)

Print this item

  [arduino code examples for B2]-03 Read ADS1115 analog input ports value
Posted by: admin - 07-25-2026, 06:30 AM - Forum: B2 - No Replies

Code:
/*
* This program reads voltage values from the ADS1115 analog-to-digital converter
* on all four channels (A0, A1, A2, A3) and prints the results through the serial port.
* The ADS1115 communicates via the I2C protocol. This version of the code includes
* the capability to specify custom SDA and SCL pins for I2C communication.
*
* Copyright: Made by KinCony IoT: https://www.kincony.com
*
*/

#include <Wire.h>                // Library for I2C communication
#include <DFRobot_ADS1115.h>     // Library for ADS1115 ADC module

// Define the I2C SDA and SCL pins for communication with ADS1115
#define SDA_PIN 8 
#define SCL_PIN 18 

// Initialize ADS1115 instance using the Wire library
DFRobot_ADS1115 ads(&Wire);

void setup(void)
{
    // Begin serial communication at a baud rate of 115200
    Serial.begin(115200);

    // Initialize the I2C bus using the defined SDA and SCL pins
    Wire.begin(SDA_PIN, SCL_PIN);

    // Set the I2C address for the ADS1115 (default: 0x49)
    ads.setAddr_ADS1115(ADS1115_IIC_ADDRESS0);   // Address is 0x49

    // Set the gain for the ADS1115 (2/3x gain allows for a maximum input voltage of 6.144V)
    ads.setGain(eGAIN_TWOTHIRDS);

    // Set the ADS1115 to operate in single-shot mode (each reading is a single conversion)
    ads.setMode(eMODE_SINGLE);

    // Set the sample rate to 128 samples per second (SPS)
    ads.setRate(eRATE_128);

    // Set the operational status mode to single-conversion start
    ads.setOSMode(eOSMODE_SINGLE);

    // Initialize the ADS1115 module
    ads.init();
}

void loop(void)
{
    // Check if the ADS1115 is properly connected and functioning
    if (ads.checkADS1115())
    {
        // Variables to store the voltage readings for each channel
        int16_t adc0, adc1, adc2, adc3;

        // Read the voltage from channel A0 and print the value
        adc0 = ads.readVoltage(0);
        Serial.print("A0:");
        Serial.print(adc0);
        Serial.print("mV,  ");    // Print the value in millivolts

        // Read the voltage from channel A1 and print the value
        adc1 = ads.readVoltage(1);
        Serial.print("A1:");
        Serial.print(adc1);
        Serial.print("mV,  ");    // Print the value in millivolts

        // Read the voltage from channel A2 and print the value
        adc2 = ads.readVoltage(2);
        Serial.print("A2:");
        Serial.print(adc2);
        Serial.print("mV,  ");    // Print the value in millivolts

        // Read the voltage from channel A3 and print the value
        adc3 = ads.readVoltage(3);
        Serial.print("A3:");
        Serial.print(adc3);
        Serial.println("mV");     // Print the value in millivolts and end the line
    }
    else
    {
        // If ADS1115 is not connected, print a message indicating disconnection
        Serial.println("ADS1115 Disconnected!");
    }

    // Wait for 1 second before the next loop iteration
    delay(1000);
}
arduino ino file download: 

.zip   3-ads1115_adc.zip (Size: 1.2 KB / Downloads: 48)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:

.zip   3-ads1115_adc.ino.merged.zip (Size: 192.69 KB / Downloads: 52)

Print this item

  [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: 48)
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: 44)

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: 42)
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: 41)

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: 44)

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: 35)

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:GPIO16
TXD:GPIO15

Print this item