Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RS485 TS sensor with A16v3 esphome yaml
#1
here is sample ESPHome yaml code for 3 TS together with one RS485 bus using KC868-A16v3 board.
   
   
   
set every TS with different RS485 address by PC software, make sure PC software can read the data:
   
   
   
here is ESPHome yaml
   
Code:
esphome:
  name: a16v3-ts
  friendly_name: a16v3_ts

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

# Enable logging
logger:
  hardware_uart: USB_SERIAL_JTAG

api:

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

uart:
  - id: uart_RS485
    baud_rate: 9600
    tx_pin: 16
    rx_pin: 17

modbus:
  - id: modbus_ts
    uart_id: uart_RS485
    send_wait_time: 50ms

# Sensor 1 - Address 1
modbus_controller:
  - id: ts_sensor_1
    modbus_id: modbus_ts
    address: 0x01
    command_throttle: 200ms
    setup_priority: -10
    update_interval: 10s

  - id: ts_sensor_2
    modbus_id: modbus_ts
    address: 0x02
    command_throttle: 200ms
    setup_priority: -10
    update_interval: 10s

  - id: ts_sensor_3
    modbus_id: modbus_ts
    address: 0x03
    command_throttle: 200ms
    setup_priority: -10
    update_interval: 10s

sensor:
  # Sensor 1 Temperature (Address 1)
  - platform: modbus_controller
    modbus_controller_id: ts_sensor_1
    name: "TS Sensor 1 Temperature"
    id: ts1_temperature
    register_type: holding
    address: 0x0000
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - lambda: |-
          if (x >= 10000) {
            return -1 * (x - 10000) * 0.1;
          } else {
            return x * 0.1;
          }

  # Sensor 1 Humidity (Address 1)
  - platform: modbus_controller
    modbus_controller_id: ts_sensor_1
    name: "TS Sensor 1 Humidity"
    id: ts1_humidity
    register_type: holding
    address: 0x0001
    unit_of_measurement: "%RH"
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - lambda: return x * 0.1;

# Sensor 2 - Address 2

  # Sensor 2 Temperature (Address 2)
  - platform: modbus_controller
    modbus_controller_id: ts_sensor_2
    name: "TS Sensor 2 Temperature"
    id: ts2_temperature
    register_type: holding
    address: 0x0000
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - lambda: |-
          if (x >= 10000) {
            return -1 * (x - 10000) * 0.1;
          } else {
            return x * 0.1;
          }

  # Sensor 2 Humidity (Address 2)
  - platform: modbus_controller
    modbus_controller_id: ts_sensor_2
    name: "TS Sensor 2 Humidity"
    id: ts2_humidity
    register_type: holding
    address: 0x0001
    unit_of_measurement: "%RH"
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - lambda: return x * 0.1;




# Sensor 3 - Address 3
  # Sensor 3 Temperature (Address 3)
  - platform: modbus_controller
    modbus_controller_id: ts_sensor_3
    name: "TS Sensor 3 Temperature"
    id: ts3_temperature
    register_type: holding
    address: 0x0000
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - lambda: |-
          if (x >= 10000) {
            return -1 * (x - 10000) * 0.1;
          } else {
            return x * 0.1;
          }

  # Sensor 3 Humidity (Address 3)
  - platform: modbus_controller
    modbus_controller_id: ts_sensor_3
    name: "TS Sensor 3 Humidity"
    id: ts3_humidity
    register_type: holding
    address: 0x0001
    unit_of_measurement: "%RH"
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - lambda: return x * 0.1;




web_server:
  port: 80

download yaml: 
.txt   TS-HA.txt (Size: 3.45 KB / Downloads: 13)
firmware download: 
.zip   TS_V10Build241223SP0518.zip (Size: 10.25 KB / Downloads: 14)
Reply


Messages In This Thread
RS485 TS sensor with A16v3 esphome yaml - by admin - Yesterday, 07:24 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)