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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,903
» Latest member: 122ramazan@gmail.com
» Forum threads: 3,896
» Forum posts: 19,875

Full Statistics

Online Users
There are currently 32 online users.
» 0 Member(s) | 12 Guest(s)
AhrefsBot, Amazonbot, Applebot, Baidu, Bytespider, DataForSeoBot, Sogou web, bot

Latest Threads
KC868-16A crashing in inf...
Forum: KC868-A series and Uair Smart Controller
Last Post: vdeconinck
2 hours ago
» Replies: 0
» Views: 2
Current and Power not add...
Forum: N60
Last Post: edalquist
10 hours ago
» Replies: 0
» Views: 6
A24 configure yaml for ES...
Forum: KinCony A24
Last Post: admin
Yesterday, 12:12 AM
» Replies: 25
» Views: 7,190
KC868-A4 with Tuya app
Forum: "KCS" v2 firmware system
Last Post: admin
Yesterday, 12:04 AM
» Replies: 1
» Views: 10
N60 N30 N20 N10 ARM CPU f...
Forum: N30
Last Post: admin
Yesterday, 12:02 AM
» Replies: 10
» Views: 192
Connecting Nextion NX3224...
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
Yesterday, 12:00 AM
» Replies: 3
» Views: 80
T16M
Forum: News
Last Post: admin
04-11-2026, 11:58 PM
» Replies: 1
» Views: 8
T16M en panne
Forum: News
Last Post: lulu01
04-11-2026, 04:29 PM
» Replies: 4
» Views: 19
Digital input GND
Forum: KC868-A32/A32 Pro
Last Post: Korenktom
04-10-2026, 04:34 AM
» Replies: 2
» Views: 27
Z1
Forum: KC868-A16v3
Last Post: admin
04-09-2026, 11:20 PM
» Replies: 18
» Views: 905

  [Arduino source code for KC868-A2]-05 RS485 modbus temperature humidity sensor
Posted by: admin - 10-09-2024, 07:44 AM - Forum: KC868-A2 - No Replies

Code:
/*
  RS485 Modbus Temperature and Humidity Sensor Reader
  Made by KinCony: https://www.kincony.com
 
  This program reads temperature and humidity data from a Modbus RS485 sensor
  and prints the values via the Serial monitor.

  Hardware configuration:
  - RS485 communication using GPIO TX (32) and RX (35)
  - Modbus RTU protocol
  - Temperature and humidity values are stored in separate registers

  You must install the ModbusMaster library in Arduino IDE.
*/

#include <ModbusMaster.h>  // Include the ModbusMaster library for Modbus communication

// Define GPIO pins for RS485 communication (TX and RX)
#define TXD_PIN 32  // Transmit pin for RS485
#define RXD_PIN 35  // Receive pin for RS485

// Define the Modbus slave ID (this should match the sensor's address)
#define SLAVE_ID 1

// Create a ModbusMaster object to handle Modbus communication
ModbusMaster node;

/*
  This function is called before starting a Modbus transmission.
  If your hardware needs control of RS485 DE/RE pins, configure them here.
*/
void preTransmission()
{
  // Optional: Control DE/RE pins for RS485 if necessary
}

/*
  This function is called after completing a Modbus transmission.
  If your hardware needs to reset DE/RE pins, configure them here.
*/
void postTransmission()
{
  // Optional: Control DE/RE pins for RS485 if necessary
}

void setup()
{
  // Start the Serial communication for debugging at 9600 baud rate
  Serial.begin(9600);
 
  // Start Serial2 for RS485 communication using GPIO 32 (TX) and GPIO 35 (RX) at 9600 baud rate
  Serial2.begin(9600, SERIAL_8N1, RXD_PIN, TXD_PIN);

  // Initialize the Modbus communication with the slave ID and associate it with Serial2
  node.begin(SLAVE_ID, Serial2);

  // Set the pre- and post-transmission handlers for controlling RS485 hardware if needed
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);

  // Print an initial message to Serial monitor
  Serial.println("RS485 Modbus Sensor Example - Reading Temperature and Humidity");
}

void loop()
{
  uint8_t result;  // Variable to store the result of Modbus operations
  uint16_t data[2];  // Array to store the raw temperature and humidity data from the sensor

  // Read two input registers starting from address 0x0000, where temperature and humidity are stored
  result = node.readInputRegisters(0x0000, 2);  // Read 2 registers (temperature and humidity)

  // Check if the read operation was successful
  if (result == node.ku8MBSuccess)
  {
    // Retrieve raw temperature and humidity data from Modbus response buffer
    uint16_t temperatureRaw = node.getResponseBuffer(0);  // Temperature is in the first register
    uint16_t humidityRaw = node.getResponseBuffer(1);     // Humidity is in the second register

    // Parse temperature value
    float temperature;
    if (temperatureRaw < 10000)  // Check if the value represents a positive temperature
      temperature = temperatureRaw * 0.1;  // Positive temperature
    else
      temperature = -1 * (temperatureRaw - 10000) * 0.1;  // Negative temperature

    // Parse humidity value (always positive)
    float humidity = humidityRaw * 0.1;

    // Print the parsed temperature value to the Serial monitor
    Serial.print("Temperature: ");
    Serial.print(temperature);
    Serial.println(" °C");

    // Print the parsed humidity value to the Serial monitor
    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.println(" %RH");
  }
  else
  {
    // If the read operation failed, print the error code to the Serial monitor
    Serial.print("Failed to read from sensor, error: ");
    Serial.println(result);
  }

  // Wait for 5 seconds before reading the sensor again
  delay(5000);
}
   
   
arduino ino file download:
.zip   rs485-sensor.zip (Size: 1.47 KB / Downloads: 510)
BIN file (you can use esp32 download tool download to ESP32 with address 0x0 then directly to use) download:
.zip   rs485-sensor.ino.merged.zip (Size: 172.69 KB / Downloads: 538)

Print this item

  B16M vS A16
Posted by: admin - 10-08-2024, 11:38 AM - Forum: KC868-A16 - No Replies

   

Print this item

  A32 Pro ESPHome yaml include RS485 modbus temperature humidity sensor
Posted by: admin - 10-08-2024, 01:51 AM - Forum: KC868-A32/A32 Pro - Replies (23)

   
   
here we use RS485 long distance sensor connect with A32 Pro controller using A and B.
the sensor default setting is 9600bps, RS485 address is 1
   
we can use USB-RS485 adapter connect PC with sensor , monitor the sensor value, or maybe you want change the sensor address and baud rate, so just use PC software to set. Then we can let sensor connect to A32 Pro's RS485 port directly.
   
mainly add these code for modbus:
uart:
  - id: uart_modbus
    baud_rate: 9600
    tx_pin: 9
    rx_pin: 8


# Config Modbus
modbus:
  uart_id: uart_modbus
  id: modbus1

modbus_controller:
  - id: modbus_sensor
    address: 0x01  # device address
    modbus_id: modbus1


sensor:
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor
    name: "RS485 Temperature Sensor"
    id: temperature_sensor
    address: 0x0000
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    filters:
      - lambda: if (x < 10000) return x * 0.1; else return -1 * (x - 10000) * 0.1;
   
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor
    name: "RS485 Humidity Sensor"
    id: humidity_sensor
    address: 0x0001
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "%"
    accuracy_decimals: 1
    filters:
      - multiply: 0.1


whole ESPHome ymal code:

Code:
esphome:
  name: a32-pro-arduino
  friendly_name: a32-Pro-arduino
  platformio_options:
    board_build.extra_flags:
      # WIFI_CONTROL_SELF_MODE = 0
      # WIFI_CONTROL_SELF_MODE = 1
      - "-DWIFI_CONTROL_SELF_MODE=0"

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

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

# Enable logging
# logger:

# Enable Home Assistant API
api:
  encryption:
    key: "fBpihEYPVlfKaE4ZIcY0uRcJ134u7DBKzzskk994+Lw="

ethernet:
  type: W5500
  clk_pin: GPIO42
  mosi_pin: GPIO44
  miso_pin: GPIO40
  cs_pin: GPIO39
  interrupt_pin: GPIO41
  reset_pin: GPIO43

uart:
  - id: uart_modbus
    baud_rate: 9600
    tx_pin: 9
    rx_pin: 8

  - id: tuya_mcu_uart
    baud_rate: 9600
    tx_pin: 15
    rx_pin: 16

tuya_wifi_mcu:
  # tuya mcu product id
  product_id: fwy7fk4mzay3kern
  uart_id: tuya_mcu_uart
  wifi_reset_pin: 21
  wifi_led_pin: 45

# Config Modbus
modbus:
  uart_id: uart_modbus
  id: modbus1

modbus_controller:
  - id: modbus_sensor
    address: 0x01  # device address
    modbus_id: modbus1

i2c:
   - id: bus_a
     sda: 11
     scl: 10
     scan: true
     frequency: 400kHz

xl9535:
  - id: xl9535_hub_out1 # for output channel 1-16
    address: 0x21
  - id: xl9535_hub_out2 # for output channel 17-32
    address: 0x22
  - id: xl9535_hub_in1 # for input channel 1-16
    address: 0x24
  - id: xl9535_hub_in2 # for input channel 17-32
    address: 0x25

pcf8574:
  - id: 'pcf8574_in_3'  # for input channel 33-40
    address: 0x23



switch:

  - platform: gpio
    pin: 45
    name: "LED"

  - platform: gpio
    name: A32 Pro Switch01
    id: "a32_pro_switch01"
    pin:
      xl9535: xl9535_hub_out1
      number: 0
      mode: OUTPUT
      inverted: true
 
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch01 Tuya
    dp_id: 101
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch01"
 
 
  - platform: gpio
    name: A32 Pro Switch02
    id: "a32_pro_switch02"
    pin:
      xl9535: xl9535_hub_out1
      number: 1
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch02 Tuya
    dp_id: 102
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch02"

  - platform: gpio
    name: A32 Pro Switch03
    id: "a32_pro_switch03"
    pin:
      xl9535: xl9535_hub_out1
      number: 2
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch03 Tuya
    dp_id: 103
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch03"

  - platform: gpio
    name: A32 Pro Switch04
    id: "a32_pro_switch04"
    pin:
      xl9535: xl9535_hub_out1
      number: 3
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch04 Tuya
    dp_id: 104
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch04"

  - platform: gpio
    name: A32 Pro Switch05
    id: "a32_pro_switch05"
    pin:
      xl9535: xl9535_hub_out1
      number: 4
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch05 Tuya
    dp_id: 105
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch05"

  - platform: gpio
    name: A32 Pro Switch06
    id: "a32_pro_switch06"
    pin:
      xl9535: xl9535_hub_out1
      number: 5
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch06 Tuya
    dp_id: 106
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch06"

  - platform: gpio
    name: A32 Pro Switch07
    id: "a32_pro_switch07"
    pin:
      xl9535: xl9535_hub_out1
      number: 6
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch07 Tuya
    dp_id: 107
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch07"

  - platform: gpio
    name: A32 Pro Switch08
    id: "a32_pro_switch08"
    pin:
      xl9535: xl9535_hub_out1
      number: 7
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch08 Tuya
    dp_id: 108
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch08"

  - platform: gpio
    name: A32 Pro Switch09
    id: "a32_pro_switch09"
    pin:
      xl9535: xl9535_hub_out1
      number: 10
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch09 Tuya
    dp_id: 109
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch09"

  - platform: gpio
    name: A32 Pro Switch10
    id: "a32_pro_switch10"
    pin:
      xl9535: xl9535_hub_out1
      number: 11
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch10 Tuya
    dp_id: 110
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch10"

  - platform: gpio
    name: A32 Pro Switch11
    id: "a32_pro_switch11"
    pin:
      xl9535: xl9535_hub_out1
      number: 12
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch11 Tuya
    dp_id: 111
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch11"

  - platform: gpio
    name: A32 Pro Switch12
    id: "a32_pro_switch12"
    pin:
      xl9535: xl9535_hub_out1
      number: 13
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch12 Tuya
    dp_id: 112
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch12"

  - platform: gpio
    name: A32 Pro Switch13
    id: "a32_pro_switch13"
    pin:
      xl9535: xl9535_hub_out1
      number: 14
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch13 Tuya
    dp_id: 113
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch13"

  - platform: gpio
    name: A32 Pro Switch14
    id: "a32_pro_switch14"
    pin:
      xl9535: xl9535_hub_out1
      number: 15
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch14 Tuya
    dp_id: 114
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch14"

  - platform: gpio
    name: A32 Pro Switch15
    id: "a32_pro_switch15"
    pin:
      xl9535: xl9535_hub_out1
      number: 16
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch15 Tuya
    dp_id: 115
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch15"

  - platform: gpio
    name: A32 Pro Switch16
    id: "a32_pro_switch16"
    pin:
      xl9535: xl9535_hub_out1
      number: 17
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch16 Tuya
    dp_id: 116
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch16"

  - platform: gpio
    name: A32 Pro Switch17
    id: "a32_pro_switch17"
    pin:
      xl9535: xl9535_hub_out2
      number: 0
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch17 Tuya
    dp_id: 117
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch17"

  - platform: gpio
    name: A32 Pro Switch18
    id: "a32_pro_switch18"
    pin:
      xl9535: xl9535_hub_out2
      number: 1
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch18 Tuya
    dp_id: 118
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch18"

  - platform: gpio
    name: A32 Pro Switch19
    id: "a32_pro_switch19"
    pin:
      xl9535: xl9535_hub_out2
      number: 2
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch19 Tuya
    dp_id: 119
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch19"

  - platform: gpio
    name: A32 Pro Switch20
    id: "a32_pro_switch20"
    pin:
      xl9535: xl9535_hub_out2
      number: 3
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch20 Tuya
    dp_id: 120
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch20"

  - platform: gpio
    name: A32 Pro Switch21
    id: "a32_pro_switch21"
    pin:
      xl9535: xl9535_hub_out2
      number: 4
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch21 Tuya
    dp_id: 121
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch21"

  - platform: gpio
    name: A32 Pro Switch22
    id: "a32_pro_switch22"
    pin:
      xl9535: xl9535_hub_out2
      number: 5
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch22 Tuya
    dp_id: 122
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch22"

  - platform: gpio
    name: A32 Pro Switch23
    id: "a32_pro_switch23"
    pin:
      xl9535: xl9535_hub_out2
      number: 6
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch23 Tuya
    dp_id: 123
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch23"

  - platform: gpio
    name: A32 Pro Switch24
    id: "a32_pro_switch24"
    pin:
      xl9535: xl9535_hub_out2
      number: 7
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch24 Tuya
    dp_id: 124
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch24"

  - platform: gpio
    name: A32 Pro Switch25
    id: "a32_pro_switch25"
    pin:
      xl9535: xl9535_hub_out2
      number: 10
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch25 Tuya
    dp_id: 125
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch25"

  - platform: gpio
    name: A32 Pro Switch26
    id: "a32_pro_switch26"
    pin:
      xl9535: xl9535_hub_out2
      number: 11
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch26 Tuya
    dp_id: 126
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch26"

  - platform: gpio
    name: A32 Pro Switch27
    id: "a32_pro_switch27"
    pin:
      xl9535: xl9535_hub_out2
      number: 12
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch27 Tuya
    dp_id: 127
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch27"

  - platform: gpio
    name: A32 Pro Switch28
    id: "a32_pro_switch28"
    pin:
      xl9535: xl9535_hub_out2
      number: 13
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch28 Tuya
    dp_id: 128
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch28"

  - platform: gpio
    name: A32 Pro Switch29
    id: "a32_pro_switch29"
    pin:
      xl9535: xl9535_hub_out2
      number: 14
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch29 Tuya
    dp_id: 129
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch29"

  - platform: gpio
    name: A32 Pro Switch30
    id: "a32_pro_switch30"
    pin:
      xl9535: xl9535_hub_out2
      number: 15
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch30 Tuya
    dp_id: 130
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch30"

  - platform: gpio
    name: A32 Pro Switch31
    id: "a32_pro_switch31"
    pin:
      xl9535: xl9535_hub_out2
      number: 16
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch31 Tuya
    dp_id: 131
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch31"

  - platform: gpio
    name: A32 Pro Switch32
    id: "a32_pro_switch32"
    pin:
      xl9535: xl9535_hub_out2
      number: 17
      mode: OUTPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro Switch32 Tuya
    dp_id: 132
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "a32_pro_switch32"

binary_sensor:
  - platform: gpio
    name: A32 Pro DI01

    on_press:
      then:
        - switch.toggle: a32_pro_switch01

    id: "a32_pro_di01"
    pin:
      xl9535: xl9535_hub_in1
      number: 0
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro DI01 Tuya
    dp_id: 133
    bind_binary_sensor_id: a32_pro_di01
    internal: true



  - platform: gpio
    name: A32 Pro DI02
    id: "a32_pro_di02"
    pin:
      xl9535: xl9535_hub_in1
      number: 1
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro DI02 Tuya
    dp_id: 134
    bind_binary_sensor_id: a32_pro_di02
    internal: true

  - platform: gpio
    name: A32 Pro DI03
    id: "a32_pro_di03"
    pin:
      xl9535: xl9535_hub_in1
      number: 2
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro DI03 Tuya
    dp_id: 135
    bind_binary_sensor_id: a32_pro_di03
    internal: true

  - platform: gpio
    name: A32 Pro DI04
    id: "a32_pro_di04"
    pin:
      xl9535: xl9535_hub_in1
      number: 3
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: A32 Pro DI04 Tuya
    dp_id: 136
    bind_binary_sensor_id: a32_pro_di04
    internal: true

  - platform: gpio
    name: A32 Pro DI05
    pin:
      xl9535: xl9535_hub_in1
      number: 4
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI06
    pin:
      xl9535: xl9535_hub_in1
      number: 5
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI07
    pin:
      xl9535: xl9535_hub_in1
      number: 6
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI08
    pin:
      xl9535: xl9535_hub_in1
      number: 7
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI09
    pin:
      xl9535: xl9535_hub_in1
      number: 10
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI10
    pin:
      xl9535: xl9535_hub_in1
      number: 11
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI11
    pin:
      xl9535: xl9535_hub_in1
      number: 12
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI12
    pin:
      xl9535: xl9535_hub_in1
      number: 13
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI13
    pin:
      xl9535: xl9535_hub_in1
      number: 14
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI14
    pin:
      xl9535: xl9535_hub_in1
      number: 15
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI15
    pin:
      xl9535: xl9535_hub_in1
      number: 16
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI16
    pin:
      xl9535: xl9535_hub_in1
      number: 17
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "A32 Pro TMP1"
    pin:
      number: 1
      inverted: true


  - platform: gpio
    name: "A32 Pro TMP2"
    pin:
      number: 2
      inverted: true

  - platform: gpio
    name: "A32 Pro DL"
    pin:
      number: 0
      inverted: true

  - platform: gpio
    name: "A32 Pro DTUYA"
    pin:
      number: 21
      inverted: true

  - platform: gpio
    name: A32 Pro DI17
    pin:
      xl9535: xl9535_hub_in2
      number: 0
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI18
    pin:
      xl9535: xl9535_hub_in2
      number: 1
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI19
    pin:
      xl9535: xl9535_hub_in2
      number: 2
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI20
    pin:
      xl9535: xl9535_hub_in2
      number: 3
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI21
    pin:
      xl9535: xl9535_hub_in2
      number: 4
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI22
    pin:
      xl9535: xl9535_hub_in2
      number: 5
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI23
    pin:
      xl9535: xl9535_hub_in2
      number: 6
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI24
    pin:
      xl9535: xl9535_hub_in2
      number: 7
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI25
    pin:
      xl9535: xl9535_hub_in2
      number: 10
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI26
    pin:
      xl9535: xl9535_hub_in2
      number: 11
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI27
    pin:
      xl9535: xl9535_hub_in2
      number: 12
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI28
    pin:
      xl9535: xl9535_hub_in2
      number: 13
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI29
    pin:
      xl9535: xl9535_hub_in2
      number: 14
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI30
    pin:
      xl9535: xl9535_hub_in2
      number: 15
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI31
    pin:
      xl9535: xl9535_hub_in2
      number: 16
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI32
    pin:
      xl9535: xl9535_hub_in2
      number: 17
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI33
    pin:
      pcf8574: pcf8574_in_3
      number: 0
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI34
    pin:
      pcf8574: pcf8574_in_3
      number: 1
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI35
    pin:
      pcf8574: pcf8574_in_3
      number: 2
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI36
    pin:
      pcf8574: pcf8574_in_3
      number: 3
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI37
    pin:
      pcf8574: pcf8574_in_3
      number: 4
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI38
    pin:
      pcf8574: pcf8574_in_3
      number: 5
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI39
    pin:
      pcf8574: pcf8574_in_3
      number: 6
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI40
    pin:
      pcf8574: pcf8574_in_3
      number: 7
      mode: INPUT
      inverted: true

gp8403:
  id: my_gp8403
  voltage: 10V

output:
  - platform: gp8403
    id: gp8403_output_1
    gp8403_id: my_gp8403
    channel: 0
  - platform: gp8403
    id: gp8403_output_2
    gp8403_id: my_gp8403
    channel: 1

light:
  - platform: monochromatic
    name: "A32 Pro-DAC-0"
    id: a32_pro_dac_0
    output: gp8403_output_1
    gamma_correct: 1.0

  - platform: tuya_wifi_mcu
    name: "Tuya A32 Pro-DAC-0"
    # bind other light, sync state
    bind_light_id: a32_pro_dac_0
    output: gp8403_output_1
    dp_id: 173
    # hide from homeassistant ui
    internal: true
    gamma_correct: 1.0

  - platform: monochromatic
    name: "A32 Pro-DAC-1"
    id: a32_pro_dac_1
    output: gp8403_output_2
    gamma_correct: 1.0

  - platform: tuya_wifi_mcu
    name: "Tuya A32 Pro-DAC-1"
    # bind other light, sync state
    bind_light_id: a32_pro_dac_1
    output: gp8403_output_2
    dp_id: 174
    # hide from homeassistant ui
    internal: true
    gamma_correct: 1.0


sensor:
  - platform: adc
    pin: 7
    name: "A32 Pro 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: 6
    name: "A32 Pro 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: 5
    name: "A32 Pro A3 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666
  - platform: adc
    pin: 4
    name: "A32 Pro A4 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666

  - platform: modbus_controller
    modbus_controller_id: modbus_sensor
    name: "RS485 Temperature Sensor"
    id: temperature_sensor
    address: 0x0000
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    filters:
      - lambda: if (x < 10000) return x * 0.1; else return -1 * (x - 10000) * 0.1;
   
  - platform: modbus_controller
    modbus_controller_id: modbus_sensor
    name: "RS485 Humidity Sensor"
    id: humidity_sensor
    address: 0x0001
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "%"
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

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), "A32 Pro");

   
yaml file download: 
.txt   A32_Pro-ESPHome_arduino_type_RS485_MODBUS_SENSOR.txt (Size: 23.44 KB / Downloads: 450)

RS485 sensor config PC software:
.zip   RS485-sensor-PC-tool.zip (Size: 4.08 MB / Downloads: 585)

Print this item

  More then 3 DS18B20 sensors with KCS Firmware
Posted by: Jackson - 10-07-2024, 08:13 AM - Forum: KC868-A16 - Replies (3)

Hi! I want to know if it is possible to connect more than 3 DS18B20 sensors to the KC868-A16 board, using the KCS Firmware, not ESPHOME! Via ESPHOME, I can find the addresses, but is it possible to do it with KCS Firmware? Thanks!

Print this item

  sesnors
Posted by: BaconRanch - 10-07-2024, 02:29 AM - Forum: KinCony Server-Mini / Server-16 Raspberry Pi4 relay module - Replies (9)

Hello,

On the Kincony server 16, are the sensors only binary? 

If I want to display voltage of a vehicke do I have to use the native GPIO on the CM4?

Can I simply run a ground from the ground terminal to the metal frame?

Print this item

  Send RF from MQTT
Posted by: charlesrg - 10-07-2024, 01:56 AM - Forum: "KCS" v2 firmware system - Replies (1)

How can I trigger an RF code to be sent from MQTT ?


I have automations on NodeRed that I would like to use to send MQTT message to A32M to transmitt and RF433mhz signal.


(10-07-2024, 01:56 AM)charlesrg Wrote: How can I trigger an RF code to be sent from MQTT ?


I have automations on NodeRed that I would like to use to send MQTT message to A32M to transmitt and RF433mhz signal.

Found my answer at: https://youtu.be/k4iKJMzGIl0?t=901
Thank you for posting the video and instructions.

Print this item

  How to setup S3 Core Board + DO8 + HAv2 with Physical Switch using ESPHome?
Posted by: weedtop - 10-06-2024, 06:59 AM - Forum: DIY Project - Replies (2)

Hi ,

Below is my product list 
S3 core Board
DO8 relay board
HAv2 

I have successfully config DO8 and HAv2 with ESPHome in Home Assistant , please see attached photos.
           

Please help me to modify my yaml to use HAv2 and Siemens to control the relay on DO8

attached is my yaml


.txt   s3-core.txt (Size: 4.02 KB / Downloads: 328)

Thanks,

Print this item

  How to connect switch to A32Pro
Posted by: drazvan2003 - 10-05-2024, 02:44 PM - Forum: DIY Project - Replies (9)

Hello,

Could you provide some info on how to connect https://shop.kincony.com/products/moment...ush-button to the A32Pro 

What pin from A32 Pro goes to what pin on the switch ?
And do i need to change any code on the yaml file on esphome ?

I followed this document to get the firmware - https://www.kincony.com/esp32-kcsv2-firmware.html and after that i added it to ESPHome


Best regards
Razvan



Attached Files Thumbnail(s)
   
Print this item

  Firmware settings Backup
Posted by: charlesrg - 10-05-2024, 03:40 AM - Forum: "KCS" v2 firmware system - Replies (3)

How do I backup the firmware settings so I don't have to redo by hand after upgrade ?

Print this item

  KinCony F16 ESP32-S3 16A Removable Relay Board released
Posted by: admin - 10-05-2024, 02:29 AM - Forum: News - No Replies

KinCony F16 ESP32 smart controller based on ESP32-S3-WROOM-1U (N16R8) wifi chip. It have 16 manual control switch buttons can turn ON/OFF relay even if system is broken. 16 channel removable OMRON high-quality relay, 4 channel 1-wire GPIOs, 2 free GPIOs, 4 channel analog input ports. One SD card using SPI bus. KinCony F16 include DS3231 high precision RTC clock chip. LCD display will show wifi and ethernet IP address and Tuya connection state. F16 have RS485 port and RF433MHz RF receiver. You can write any code by Arduino IDE / MicroPython / ESP-IDF development tool to ESP32 module. We will supply Arduino / ESP-IDF demo code for different samples. Everyone can modify and change the code for your own smart home automation system project. it support use by ESPHome for home assistant or tasmota firmware for smart home automation DIY.
[Image: ESP32-F16-1.jpg]
Model No. KinCony F16
Description: KinCony 16 Channel ESP32-S3 Removable Relay Controller – F16
Power supply: 12/24V DC (Default install by 12V OMRON relay)
Processor: ESP32-S3-WROOM-1U (N16R8)
Size: 262mm*127mm*62mm
interfaces: Ethernet(RJ45)-LAN 100Mbps IPv4/IPv6,WiFi,RS485,Bluetooth,USB-C,LCD,Tuya Module
RTC: DS3231 high precision chip (battery socket on PCB)
SD Card: SPI bus
Installation method: DIN RAIL
LCD: SSD1306 I2C display
Outputs:
16CH OMRON removable relay, every channel have "COM"(common) and "NO"(normal open) ports.
MAX load 250VAC/16A 30VDC/16A
Inputs:
2CH analog input DC0-5V (A1,A2) 2CH analog input 4-20mA (A3,A4)
16CH dry contact inputs (optocoupler isolation, long distance circuit for MAX 500 meters cable)
3 buttons: 1:ESP32 Reset 2:ESP32 Download 3:Tuya config
1-Wire GPIO: 4CH (with pull-up resistance on PCB)
free GPIO: 2CH (without pull-up resistance on PCB, connect with ESP32 pin directly)
RF receiver socket: 433MHz RF receiver
[Image: ESP32-F16-6.jpg]
software solution:
1. download firmware by ESPHome, integrate to home assistant or use by web service.
2. download tasmota firmware.
3. write your own arudino code for your own requirements.
4. It is recommended to use home assistant and Tuya mobile phone app at the same time. So that remote control by internet using Tuya app, local control by LAN using home assistant app.
Related technical information
———————————
ESP32 I/O pin define: https://www.kincony.com/forum/showthread.php?tid=6814
config yaml file for ESPHome: https://www.kincony.com/forum/showthread.php?tid=6815
arduino demo source code: https://www.kincony.com/forum/forumdisplay.php?fid=63
Different views of the F16:
[Image: F16-view.jpg]
[Image: F16-size.jpg]

Print this item