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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,624
» Latest member: dentistryforkids
» Forum threads: 3,780
» Forum posts: 19,319

Full Statistics

Online Users
There are currently 29 online users.
» 0 Member(s) | 14 Guest(s)
AhrefsBot, Amazonbot, Bing, Bytespider, Crawl, Google, bot

Latest Threads
ERROR SIM not inserted SI...
Forum: KC868-E8T
Last Post: admin
8 hours ago
» Replies: 10
» Views: 151
Separate loading Firmware...
Forum: B16
Last Post: admin
8 hours ago
» Replies: 1
» Views: 10
Custom sensors on pins?
Forum: KinCony ALR
Last Post: admin
02-12-2026, 11:13 PM
» Replies: 1
» Views: 28
KCS mqtt
Forum: KC868-A64
Last Post: admin
02-12-2026, 11:12 PM
» Replies: 5
» Views: 79
Where are the pins led ou...
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
02-12-2026, 09:32 AM
» Replies: 5
» Views: 867
ESPHome installing issue
Forum: KC868-A16v3
Last Post: admin
02-12-2026, 02:53 AM
» Replies: 1
» Views: 56
KC868-A6: Any accessible ...
Forum: KC868-A6
Last Post: admin
02-12-2026, 02:52 AM
» Replies: 1
» Views: 64
KC868-A6 with KC868-HAv2
Forum: KC868-A6
Last Post: admin
02-12-2026, 02:49 AM
» Replies: 1
» Views: 42
Free sample fos teaching
Forum: Apply for free sample product
Last Post: jllima
02-11-2026, 11:41 PM
» Replies: 0
» Views: 24
KinCony Z1 Problem
Forum: KC868-AG / AG Pro / AG8 / Z1
Last Post: siwybug
02-11-2026, 07:22 PM
» Replies: 7
» Views: 164

  [arduino code examples for F4]-01 Turn ON/OFF relay
Posted by: admin - 11-03-2025, 11:40 PM - Forum: F4 - 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: 146)
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: 141)

Print this item

  F4 ESPHome yaml for home assistant with tuya
Posted by: admin - 11-03-2025, 11:39 PM - Forum: F4 - No Replies

Code:
esphome:
  name: f4
  friendly_name: f4
  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

  # hardware_uart: USB_SERIAL_JTAG
# Enable Home Assistant API
api:
  encryption:
    key: "WeVOuL5oNhjXcfzXtTirlOwvtWvCD5yqIxd3oV4es1k="

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

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

pcf8574:
  - id: 'pcf8574_hub_in_1'  # for DI1-DI4 Relay1-Relay4
    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: 16
    rx_pin: 17

  - id: tuya_mcu_uart
    tx_pin: GPIO39
    rx_pin: GPIO38
    baud_rate: 9600

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

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

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

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

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

  - platform: gpio
    name: "f4-input02"
    id: "f4_input02"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 1
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: f4-input2-tuya
    dp_id: 112
    bind_binary_sensor_id: f4_input02
    internal: true

  - platform: gpio
    name: "f4-input03"
    id: "f4_input03"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 2
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: f4-input3-tuya
    dp_id: 113
    bind_binary_sensor_id: f4_input03
    internal: true

  - platform: gpio
    name: "f4-input04"
    id: "f4_input04"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 3
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: f4-input4-tuya
    dp_id: 114
    bind_binary_sensor_id: f4_input04
    internal: true

##pull-up resistance on PCB
  - platform: gpio
    name: "f4-W1-io48"
    pin:
      number: 48
      inverted: true

  - platform: gpio
    name: "f4-W1-io47"
    pin:
      number: 47
      inverted: true

  - platform: gpio
    name: "f4-W1-io21"
    pin:
      number: 21
      inverted: true

  - platform: gpio
    name: "f4-W1-io15"
    pin:
      number: 15
      inverted: true
## without resistance on PCB
  - platform: gpio
    name: "f4-W1-io14"
    pin:
      number: 14
      inverted:  false

  - platform: gpio
    name: "f4-433M"
    pin:
      number: 40
      inverted:  false

  - platform: gpio
    name: "f4-io0"
    pin:
      number: 0
      inverted:  false

sensor:
  - platform: adc
    pin: 5
    name: "f4 A1 Voltage"
    update_interval: 5s
    attenuation: 11db
    filters:
      - lambda:
          if (x >= 3.11) {
            return x * 1.60256;
          } else if (x <= 0.15) {
            return 0;
          } else {
            return x * 1.51;
          }
  - platform: adc
    pin: 7
    name: "f4 A2 Voltage"
    update_interval: 5s
    attenuation: 11db
    filters:
      # - multiply: 1.51515
      - lambda:
          if (x >= 3.11) {
            return x * 1.60256;
          } else if (x <= 0.15) {
            return 0;
          } else {
            return x * 1.51;
          }
  - platform: adc
    pin: 6
    name: "f4 A3 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666
  - platform: adc
    pin: 4
    name: "f4 A4 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666

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 f4");
esphome yaml file:

.txt   F4-HA-tuya.txt (Size: 6.04 KB / Downloads: 114)

Print this item

  F4 ESPHome yaml for home assistant without tuya
Posted by: admin - 11-03-2025, 11:38 PM - Forum: F4 - No Replies

Code:
esphome:
  name: f4
  friendly_name: f4

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino
   
# Enable logging

  # hardware_uart: USB_SERIAL_JTAG
# Enable Home Assistant API
api:

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

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

pcf8574:
  - id: 'pcf8574_hub_in_1'  # for DI1-DI4 Relay1-Relay4
    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: 16
    rx_pin: 17


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

  - platform: gpio
    name: "f4-output01"
    id: "f4_output01"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 4
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "f4-output02"
    id: "f4_output02"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 5
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "f4-output03"
    id: "f4_output03"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 6
      mode: OUTPUT
      inverted: true


  - platform: gpio
    name: "f4-output04"
    id: "f4_output04"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 7
      mode: OUTPUT
      inverted: true

binary_sensor:
  - platform: gpio
    name: "f4-input01"
    id: "f4_input01"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 0
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f4-input02"
    id: "f4_input02"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 1
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f4-input03"
    id: "f4_input03"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 2
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f4-input04"
    id: "f4_input04"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 3
      mode: INPUT
      inverted: true


##pull-up resistance on PCB
  - platform: gpio
    name: "f4-W1-io48"
    pin:
      number: 48
      inverted: true

  - platform: gpio
    name: "f4-W1-io47"
    pin:
      number: 47
      inverted: true

  - platform: gpio
    name: "f4-W1-io21"
    pin:
      number: 21
      inverted: true

  - platform: gpio
    name: "f4-W1-io15"
    pin:
      number: 15
      inverted: true
## without resistance on PCB
  - platform: gpio
    name: "f4-W1-io14"
    pin:
      number: 14
      inverted:  false

  - platform: gpio
    name: "f4-433M"
    pin:
      number: 40
      inverted:  false

  - platform: gpio
    name: "f4-io0"
    pin:
      number: 0
      inverted:  false

sensor:
  - platform: adc
    pin: 5
    name: "f4 A1 Voltage"
    update_interval: 5s
    attenuation: 11db
    filters:
      - lambda:
          if (x >= 3.11) {
            return x * 1.60256;
          } else if (x <= 0.15) {
            return 0;
          } else {
            return x * 1.51;
          }
  - platform: adc
    pin: 7
    name: "f4 A2 Voltage"
    update_interval: 5s
    attenuation: 11db
    filters:
      # - multiply: 1.51515
      - lambda:
          if (x >= 3.11) {
            return x * 1.60256;
          } else if (x <= 0.15) {
            return 0;
          } else {
            return x * 1.51;
          }
  - platform: adc
    pin: 6
    name: "f4 A3 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666
  - platform: adc
    pin: 4
    name: "f4 A4 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666

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 f4");
esphome yaml file:

.txt   F4-HA-without-tuya.txt (Size: 4.2 KB / Downloads: 103)

Print this item

  F4 ESP32-S3 IO pins define
Posted by: admin - 11-03-2025, 11:36 PM - Forum: F4 - No Replies

ANALOG_A1(0-5v)    GPIO5
ANALOG_A2(0-5v)    GPIO7
ANALOG_A3(4-20mA)  GPIO6
ANALOG_A4(4-20mA)  GPIO4

IIC SDA:GPIO8
IIC SCL:GPIO18

PCF8574:U23  i2c address:0x24

PCF8574->P0 (DI1)
PCF8574->P1 (DI2)
PCF8574->P2 (DI3)
PCF8574->P3 (DI4)

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

RF433MHz wireless receiver: GPIO40
------------------------

Ethernet (W5500) I/O define:

clk_pin: GPIO42
mosi_pin: GPIO43
miso_pin: GPIO44
cs_pin: GPIO41

interrupt_pin: GPIO2
reset_pin: GPIO1

--------------------
RS485:
RXD:GPIO17
TXD:GPIO16
--------------------
Tuya module:
RXD:GPIO38
TXD:GPIO39

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

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

1-wire (without resistance on PCB):
1-wire2:GPIO14
------------------------
SD Card:
SPI-MOSI:GPIO10
SPI-SCK:GPIO11
SPI-MISO:GPIO12
SPI-CS:GPIO9
SPI-CD:GPIO13
------------------------
24C02 EPROM i2c address: 0x50
DS3231 RTC i2c address: 0x68
SSD1306 display: i2c address:0x3c

Print this item

  [arduino code examples for F32]-11 digital INPUT trigger OUTPUT directly
Posted by: admin - 11-03-2025, 11:33 PM - Forum: F32 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* This program reads 32 input states from three PCF8575 I/O expanders and
* controls a corresponding 32-channel relay module.
* When an input pin is LOW, the corresponding relay is turned ON (LOW means ON for the relay).
* When the input pin is HIGH, the corresponding relay is turned OFF.
*
* Pin Definitions:
* - SDA: GPIO 8
* - SCL: GPIO 18

PCF8575:U27 (relay17-32) i2c address:0x25
PCF8575:U23 (DI1-16) i2c address:0x24
PCF8575:U49 i2c address: 0x26
  PCF8575(pin number0-7):DI17-24
  PCF8575(pin number8-11):relay13-16
  PCF8575(pin number12-15):relay9-12

PCF8575:U62 i2c address: 0x27
  PCF8575(pin number0-7):DI25-32
  PCF8575(pin number8-15):relay1-8
*/

#include <Wire.h>        // I2C communication
#include <PCF8575.h>     // Library to control the PCF8575 I/O expander

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

// I2C addresses for the PCF8575 modules
#define INPUT_I2C_ADDRESS_1 0x24   
#define INPUT_RELAY_I2C_ADDRESS_2 0x26 
#define RELAY_I2C_ADDRESS_3 0x25 
#define INPUT_RELAY_I2C_ADDRESS_3 0x27   

PCF8575 pcf8575_IN1(INPUT_I2C_ADDRESS_1);   
PCF8575 pcf8575_IN2(INPUT_RELAY_I2C_ADDRESS_2);   
PCF8575 pcf8575_RL(RELAY_I2C_ADDRESS_3);   
PCF8575 pcf8575_IN3(INPUT_RELAY_I2C_ADDRESS_3);

void setup() {
  // Initialize I2C communication
  Wire.begin(SDA, SCL);
 
  // Initialize serial communication
  Serial.begin(115200);
 
  // Initialize input and relay modules
  pcf8575_IN1.begin(); 
  pcf8575_IN2.begin(); 
  pcf8575_IN3.begin();
  pcf8575_RL.begin(); 
 
  // Turn off all relays at the start (LOW means OFF)
  for (int i = 8; i < 16; i++) {
    pcf8575_IN2.write(i, HIGH);
  }
  for (int i = 0; i < 16; i++) {
    pcf8575_RL.write(i, HIGH);
  }
  for (int i = 8; i < 16; i++) {
    pcf8575_IN3.write(i, HIGH); 
  }
  Serial.println("System started: Input state controlling 24 relays");
}

void loop() {
    bool inputState;
    inputState = pcf8575_IN1.read(0);  // input1 control relay1
    if (inputState) {
      pcf8575_IN3.write(8, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN3.write(8, LOW);   // If input is LOW, turn the corresponding relay ON
    }
 
    inputState = pcf8575_IN1.read(1);  // input2 control relay2
    if (inputState) {
      pcf8575_IN3.write(9, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN3.write(9, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(2);  // input3 control relay3
    if (inputState) {
      pcf8575_IN3.write(10, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN3.write(10, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(3);  // input4 control relay4
    if (inputState) {
      pcf8575_IN3.write(11, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN3.write(11, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(4);  // input5 control relay5
    if (inputState) {
      pcf8575_IN3.write(12, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN3.write(12, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(5);  // input6 control relay6
    if (inputState) {
      pcf8575_IN3.write(13, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN3.write(13, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(6);  // input7 control relay7
    if (inputState) {
      pcf8575_IN3.write(14, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN3.write(14, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(7);  // input8 control relay8
    if (inputState) {
      pcf8575_IN3.write(15, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN3.write(15, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(8);  // input9 control relay9
    if (inputState) {
      pcf8575_IN2.write(12, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN2.write(12, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(9);  // input10 control relay10
    if (inputState) {
      pcf8575_IN2.write(13, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN2.write(13, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(10);  // input11 control relay11
    if (inputState) {
      pcf8575_IN2.write(14, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN2.write(14, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(11);  // input12 control relay12
    if (inputState) {
      pcf8575_IN2.write(15, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN2.write(15, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(12);  // input13 control relay13
    if (inputState) {
      pcf8575_IN2.write(8, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN2.write(8, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(13);  // input14 control relay14
    if (inputState) {
      pcf8575_IN2.write(9, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN2.write(9, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(14);  // input15 control relay15
    if (inputState) {
      pcf8575_IN2.write(10, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN2.write(10, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN1.read(15);  // input16 control relay16
    if (inputState) {
      pcf8575_IN2.write(11, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_IN2.write(11, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN2.read(0);  // input17 control relay17
    if (inputState) {
      pcf8575_RL.write(0, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(0, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN2.read(1);  // input18 control relay18
    if (inputState) {
      pcf8575_RL.write(1, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(1, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN2.read(2);  // input19 control relay19
    if (inputState) {
      pcf8575_RL.write(2, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(2, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN2.read(3);  // input20 control relay20
    if (inputState) {
      pcf8575_RL.write(3, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(3, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN2.read(4);  // input21 control relay21
    if (inputState) {
      pcf8575_RL.write(4, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(4, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN2.read(5);  // input22 control relay22
    if (inputState) {
      pcf8575_RL.write(5, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(5, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN2.read(6);  // input23 control relay23
    if (inputState) {
      pcf8575_RL.write(6, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(6, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN2.read(7);  // input24 control relay24
    if (inputState) {
      pcf8575_RL.write(7, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(7, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN3.read(0);  // input25 control relay25
    if (inputState) {
      pcf8575_RL.write(8, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(8, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN3.read(1);  // input26 control relay26
    if (inputState) {
      pcf8575_RL.write(9, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(9, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN3.read(2);  // input27 control relay27
    if (inputState) {
      pcf8575_RL.write(10, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(10, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN3.read(3);  // input28 control relay28
    if (inputState) {
      pcf8575_RL.write(11, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(11, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN3.read(4);  // input29 control relay29
    if (inputState) {
      pcf8575_RL.write(12, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(12, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN3.read(5);  // input30 control relay30
    if (inputState) {
      pcf8575_RL.write(13, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(13, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN3.read(6);  // input31 control relay31
    if (inputState) {
      pcf8575_RL.write(14, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(14, LOW);   // If input is LOW, turn the corresponding relay ON
    }

    inputState = pcf8575_IN3.read(7);  // input32 control relay32
    if (inputState) {
      pcf8575_RL.write(15, HIGH);  // If input is HIGH, turn the corresponding relay OFF
    } else {
      pcf8575_RL.write(15, LOW);   // If input is LOW, turn the corresponding relay ON
    }

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

.zip   11-input-trigger-output.zip (Size: 1.54 KB / Downloads: 138)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:

.zip   11-input-trigger-output.ino.merged.zip (Size: 198.09 KB / Downloads: 127)

Print this item

  [arduino code examples for F32]-02 Read digital input ports state
Posted by: admin - 11-03-2025, 11:27 PM - Forum: F32 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
*
* Pin Definitions:
* - SDA: GPIO 8
* - SCL: GPIO 18
* - PCF8575 I2C Address: 0x24 for inputs 1-16, 0x26 for inputs 17-24, 0x27 for inputs 18-25
*/

#include "Arduino.h"
#include "PCF8575.h"

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

// Set I2C addresses
PCF8575 pcf8575_IN1(0x24); // The I2C address of the first PCF8575 (inputs 1-16)
PCF8575 pcf8575_IN2(0x26); // The I2C address of the second PCF8575 (inputs 17-24)
PCF8575 pcf8575_IN3(0x27); // The I2C address of the second PCF8575 (inputs 25-32)

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

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

    // Initialize both PCF8575 modules
    pcf8575_IN1.begin();
    pcf8575_IN2.begin();
    pcf8575_IN3.begin();

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

void loop() {
    uint32_t state = 0; // Use a 32-bit variable to store the state of all 24 pins

    // Read the state of each pin from the first PCF8575 (inputs 1-16)
    for (int pin = 0; pin < 16; pin++) {
        if (pcf8575_IN1.read(pin)) {
            state |= (1UL << pin); // Set the bit for the active pin (inputs 1-16)
        }
    }

    // Read the state of each pin from the second PCF8575 (inputs 17-24, corresponding to pins 0-7)
    for (int pin = 0; pin < 8; pin++) {
        if (pcf8575_IN2.read(pin)) {
            state |= (1UL << (pin + 16)); // Set the bit for the active pin (inputs 17-24)
        }
    }

    // Read the state of each pin from the second PCF8575 (inputs 25-32, corresponding to pins 0-7)
    for (int pin = 0; pin < 8; pin++) {
        if (pcf8575_IN3.read(pin)) {
            state |= (1UL << (pin + 24));
        }
    }

    // Print the state of all 24 inputs in binary format
    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: 885 bytes / Downloads: 138)
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.91 KB / Downloads: 133)

Print this item

  [arduino code examples for F32]-01 Turn ON/OFF relay
Posted by: admin - 11-03-2025, 11:25 PM - Forum: F32 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* This program controls a 32-channel relay board via two PCF8575 I/O expanders.
* 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 <PCF8575.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 addresses of the PCF8575 modules
#define I2C_ADDRESS_R1 0x25 // I2C address of the first PCF8575 module
#define I2C_ADDRESS_R2 0x26 // I2C address of the second PCF8575 module
#define I2C_ADDRESS_R3 0x27 // I2C address of the second PCF8575 module

PCF8575 pcf8575_R1(I2C_ADDRESS_R1); // Create a PCF8575 object for the first module (for relays 17-32)
PCF8575 pcf8575_R2(I2C_ADDRESS_R2); // Create a PCF8575 object for the second module (for relays 9-16)
PCF8575 pcf8575_R3(I2C_ADDRESS_R3); // Create a PCF8575 object for the second module (for relays 1-8)

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...");

  // Initialize the PCF8575 modules
  pcf8575_R1.begin();
  pcf8575_R2.begin();
  pcf8575_R3.begin();

  // Turn off all relays initially (set all pins HIGH)
  for (int i = 0; i < 16; i++) {
    pcf8575_R1.write(i, HIGH); // Set relays 17-32 to OFF (assuming HIGH means OFF for relays)
    pcf8575_R2.write(i, HIGH); // Set relays 9-16 to OFF (assuming HIGH means OFF for relays)
  }

  // Turn off all relays initially (set all pins HIGH)
  for (int i = 8; i < 16; i++) {
    pcf8575_R3.write(i, HIGH); // Set relays 1-8 to OFF (assuming HIGH means OFF for relays)
  }

}

void loop() {
  // Sequentially turn on each relay (1-32)

  // First control the relays on the second PCF8575 (relays 1-8, corresponding to pins 8-15)
  for (int i = 8; i < 16; i++) {
    pcf8575_R3.write(i, LOW);   // Turn on the relay at pin i (LOW means ON for the relay)
    delay(DELAY_TIME);          // Wait for DELAY_TIME milliseconds
  }

  // First control the relays on the second PCF8575 (relays 9-16, corresponding to pins 8-15)
  for (int i = 8; i < 16; i++) {
    pcf8575_R2.write(i, LOW);   // Turn on the relay at pin i (LOW means ON for the relay)
    delay(DELAY_TIME);          // Wait for DELAY_TIME milliseconds
  }

  // Then control the relays on the first PCF8575 (relays 17-32)
  for (int i = 0; i < 16; i++) {
    pcf8575_R1.write(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 (1-24)
 
  // First control the relays on the second PCF8575 (relays 1-8, corresponding to pins 8-15)
  for (int i = 8; i < 16; i++) {
    pcf8575_R3.write(i, HIGH);   // Turn on the relay at pin i (LOW means ON for the relay)
    delay(DELAY_TIME);          // Wait for DELAY_TIME milliseconds
  }

  // First control the relays on the second PCF8575 (relays 9-16, corresponding to pins 8-15)
  for (int i = 8; i < 16; i++) {
    pcf8575_R2.write(i, HIGH);  // Turn off the relay at pin i (HIGH means OFF for the relay)
    delay(DELAY_TIME);          // Wait for DELAY_TIME milliseconds
  }

  // Then control the relays on the first PCF8575 (relays 17-32)
  for (int i = 0; i < 16; i++) {
    pcf8575_R1.write(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: 1.08 KB / Downloads: 134)
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: 197.73 KB / Downloads: 117)

Print this item

  F32 ESPHome yaml for home assistant without tuya
Posted by: admin - 11-03-2025, 11:22 PM - Forum: F32 - Replies (2)

Code:
esphome:
  name: f32
  friendly_name: f32

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

# Enable logging

logger:
  level: DEBUG 
  hardware_uart: USB_CDC
# Enable Home Assistant API

api:

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


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

pcf8574:
  - id: 'pcf8574_hub_out_1'  # for output channel 17-32
    i2c_id: bus_a
    address: 0x25
    pcf8575: true

  - id: 'pcf8574_hub_in_1'  # for digital input channel 1-16
    i2c_id: bus_a
    address: 0x24
    pcf8575: true

  - id: 'pcf8574_hub_out_in_2'  # for output channel 9-16  + (input 17-24)
    i2c_id: bus_a
    address: 0x26
    pcf8575: true

  - id: 'pcf8574_hub_out_in_3'  # for output channel 1-8  + (input 17-24)
    i2c_id: bus_a
    address: 0x27
    pcf8575: true

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

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

  - platform: gpio
    name: "f32-output01"
    id: "f32_output01"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 8
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output02"
    id: "f32_output02"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 9
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output03"
    id: "f32_output03"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 10
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output04"
    id: "f32_output04"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 11
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output05"
    id: "f32_output05"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 12
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output06"
    id: "f32_output06"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 13
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output07"
    id: "f32_output07"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 14
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output08"
    id: "f32_output08"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 15
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output09"
    id: "f32_output09"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 12
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output10"
    id: "f32_output10"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 13
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output11"
    id: "f32_output11"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 14
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output12"
    id: "f32_output12"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 15
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output13"
    id: "f32_output13"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 8
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output14"
    id: "f32_output14"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 9
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output15"
    id: "f32_output15"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 10
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output16"
    id: "f32_output16"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 11
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output17"
    id: "f32_output17"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output18"
    id: "f32_output18"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output19"
    id: "f32_output19"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output20"
    id: "f32_output20"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output21"
    id: "f32_output21"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output22"
    id: "f32_output22"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output23"
    id: "f32_output23"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output24"
    id: "f32_output24"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output25"
    id: "f32_output25"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 8
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output26"
    id: "f32_output26"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 9
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output27"
    id: "f32_output27"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 10
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output28"
    id: "f32_output28"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 11
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output29"
    id: "f32_output29"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 12
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output30"
    id: "f32_output30"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 13
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output31"
    id: "f32_output31"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 14
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "f32-output32"
    id: "f32_output32"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 15
      mode: OUTPUT
      inverted: true


binary_sensor:
  - platform: gpio
    name: "f32-input01"
    id: "f32_input01"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 0
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input02"
    id: "f32_input02"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 1
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input03"
    id: "f32_input03"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 2
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input04"
    id: "f32_input04"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 3
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input05"
    id: "f32_input05"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 4
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input06"
    id: "f32_input06"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 5
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input07"
    id: "f32_input07"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 6
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input08"
    id: "f32_input08"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 7
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input09"
    id: "f32_input09"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 8
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input10"
    id: "f32_input10"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 9
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input11"
    id: "f32_input11"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 10
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input12"
    id: "f32_input12"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 11
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input13"
    id: "f32_input13"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 12
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input14"
    id: "f32_input14"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 13
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input15"
    id: "f32_input15"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 14
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input16"
    id: "f32_input16"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 15
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f32-input17"
    id: "f32_input17"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 0
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f32-input18"
    id: "f32_input18"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 1
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f32-input19"
    id: "f32_input19"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 2
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f32-input20"
    id: "f32_input20"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 3
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f32-input21"
    id: "f32_input21"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 4
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f32-input22"
    id: "f32_input22"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 5
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f32-input23"
    id: "f32_input23"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 6
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "f32-input24"
    id: "f32_input24"
    pin:
      pcf8574: pcf8574_hub_out_in_2
      number: 7
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input25"
    id: "f32_input25"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 0
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input26"
    id: "f32_input26"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 1
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input27"
    id: "f32_input27"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 2
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input28"
    id: "f32_input28"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 3
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input29"
    id: "f32_input29"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 4
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input30"
    id: "f32_input30"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 5
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input31"
    id: "f32_input31"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 6
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "f32-input32"
    id: "f32_input32"
    pin:
      pcf8574: pcf8574_hub_out_in_3
      number: 7
      mode: INPUT
      inverted: true

##pull-up resistance on PCB
  - platform: gpio
    name: "f32-W1-io48"
    pin:
      number: 48
      inverted: true

  - platform: gpio
    name: "f32-W1-io47"
    pin:
      number: 47
      inverted: true

  - platform: gpio
    name: "f32-W1-io21"
    pin:
      number: 21
      inverted: true

  - platform: gpio
    name: "f32-W1-io15"
    pin:
      number: 15
      inverted: true
## without resistance on PCB
  - platform: gpio
    name: "f32-W1-io13"
    pin:
      number: 13
      inverted: false

  - platform: gpio
    name: "f32-W1-io14"
    pin:
      number: 14
      inverted:  false

  - platform: gpio
    name: "f32-433M"
    pin:
      number: 40
      inverted:  false

sensor:
  - platform: adc
    pin: 5
    name: "f32 A1 Voltage"
    update_interval: 5s
    attenuation: 11db
    filters:
      - lambda:
          if (x >= 3.11) {
            return x * 1.60256;
          } else if (x <= 0.15) {
            return 0;
          } else {
            return x * 1.51;
          }
  - platform: adc
    pin: 7
    name: "f32 A2 Voltage"
    update_interval: 5s
    attenuation: 11db
    filters:
      # - multiply: 1.51515
      - lambda:
          if (x >= 3.11) {
            return x * 1.60256;
          } else if (x <= 0.15) {
            return 0;
          } else {
            return x * 1.51;
          }
  - platform: adc
    pin: 6
    name: "f32 A3 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666
  - platform: adc
    pin: 4
    name: "f32 A4 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666

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

.txt   F32-HA-without-tuya.txt (Size: 14.25 KB / Downloads: 151)

Print this item

  F32 ESP32-S3 IO pins define
Posted by: admin - 11-03-2025, 11:21 PM - Forum: F32 - Replies (2)

ANALOG_A1(0-5v)    GPIO5
ANALOG_A2(0-5v)    GPIO7
ANALOG_A3(4-20mA)  GPIO6
ANALOG_A4(4-20mA)  GPIO4

IIC SDA:GPIO8
IIC SCL:GPIO18

PCF8575:U27 (relay17-32) i2c address:0x25
PCF8575:U23 (DI1-16) i2c address:0x24
PCF8575:U49 i2c address: 0x26
  PCF8575(pin number0-7) : DI17-24
  PCF8575(pin number8-11) : relay13-16
  PCF8575(pin number12-15) : relay9-12

PCF8575:U62 i2c address: 0x27
  PCF8575(pin number0-7) : DI25-32
  PCF8575(pin number8-15) :relay1-8


if config by ESPHome:

relay9: pcf8575(U49) number:12
relay10: pcf8575(U49) number:13
relay11: pcf8575(U49) number:14
relay12: pcf8575(U49) number:15
relay13: pcf8575(U49) number:8
relay14: pcf8575(U49) number:9
relay15: pcf8575(U49) number:10
relay16: pcf8575(U49) number:11

RF433MHz wireless receiver: GPIO40
------------------------

Ethernet (W5500) I/O define:

clk_pin: GPIO42
mosi_pin: GPIO43
miso_pin: GPIO44
cs_pin: GPIO41

interrupt_pin: GPIO2
reset_pin: GPIO1

--------------------
RS485:
RXD:GPIO17
TXD:GPIO16
--------------------
Tuya module:
RXD:GPIO38
TXD:GPIO39

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

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

1-wire (without resistance on PCB):
1-wire1:GPIO13
1-wire2:GPIO14
------------------------
SD Card:
SPI-MOSI:GPIO10
SPI-SCK:GPIO11
SPI-MISO:GPIO12
SPI-CS:GPIO9
------------------------
24C02 EPROM i2c address: 0x50
DS3231 RTC i2c address: 0x68
SSD1306 display: i2c address:0x3c

Print this item

  Using KC868_A8 as switch
Posted by: dco333 - 11-02-2025, 03:52 PM - Forum: KC868-A8 - Replies (3)

Hi

I want to use the board as a switch with the relays.
I have installed KCS Firmware 2.2.14 and activated MQTT to my MQTT broker on Home Assistant.
I followed the instructions with the configuration.yaml File and also replaced all serials by mine.
I can see the switches in HomeAssistant. But when I push the switches, nothing happens on the board. No relay is clicking.

I think I missed something. What else do I have to configure in the KCS Firmware Gui to switch the relays?
I've read many tutorials, intructions and so on, but I don't understand it how to switch the relays.
Also in the KCS Gui I didn't find any switches to test is.
I think, there has to be configured more in the firmware.

I hope to get any adice from you.

Regards
dco333

Print this item