Skip to content

Instantly share code, notes, and snippets.

@sakalauskas
Last active February 16, 2024 18:51
Show Gist options
  • Save sakalauskas/2720f0e28f66ae878b794c4af4c07ec4 to your computer and use it in GitHub Desktop.
Save sakalauskas/2720f0e28f66ae878b794c4af4c07ec4 to your computer and use it in GitHub Desktop.
CWT-TH03S sensor esphome configuration
uart:
# id: mod_bus
tx_pin: GPIO1
rx_pin: GPIO3
# baud_rate: 19200
baud_rate: 4800
stop_bits: 1
data_bits: 8
parity: NONE
debug:
direction: BOTH
modbus:
flow_control_pin: 5
id: modbus1
send_wait_time: 1500ms
modbus_controller:
- id: temp
## the Modbus device addr
address: 1
modbus_id: modbus1
command_throttle: 100ms
setup_priority: -10
update_interval: 3s
sensor:
- platform: modbus_controller
modbus_controller_id: temp
name: "Sauna Humidity"
id: sauna_humidity
device_class: humidity
register_type: holding
address: 0x0000
unit_of_measurement: "%"
value_type: S_WORD
filters:
- multiply: 0.1
state_class: measurement
- platform: modbus_controller
modbus_controller_id: temp
name: "Sauna Temperature"
id: sauna_temparature
register_type: holding
address: 0x0001
unit_of_measurement: "°C"
value_type: S_WORD
device_class: temperature
filters:
- multiply: 0.1
accuracy_decimals: 1
state_class: measurement
@Tolyanskiy
Copy link

Tolyanskiy commented Feb 16, 2024

Hi! Please can you help me with errors. I use your configuration but it did not work now. My bord - keystudio esp32 plus

My configurration:

esphome:
name: esphome-web-c23d6c
friendly_name: Keystudio

esp32:
board: esp32dev
framework:
type: arduino

Enable logging

logger:
level: verbose

Enable Home Assistant API

api:
encryption:
key: "#####################"

ota:

wifi:
ssid: ##################
password: ###############

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: "Esphome-Web-C23D6C"
password: "################"

captive_portal:

uart:
id: modbus_uart
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 4800
stop_bits: 1
data_bits: 8
parity: None
debug:
direction: BOTH

modbus:
id: modbus1
uart_id: modbus_uart
send_wait_time: 3000ms

modbus_controller:

  • id: temp

    the Modbus device addr

    address: 0x01
    command_throttle: 100ms
    setup_priority: -10
    modbus_id: modbus1
    update_interval: 3s

############ MODBUS ###################################################

  • platform: modbus_controller
    modbus_controller_id: temp
    name: "Humidity"
    id: humidity
    device_class: humidity
    register_type: holding
    address: 0x0000
    #custom_command: [ 0x01, 0x03, 0x00, 0x00, 0x00, 0x02]
    unit_of_measurement: "%"
    value_type: S_WORD
    filters:

    • multiply: 0.1
      state_class: measurement
  • platform: modbus_controller
    modbus_controller_id: temp
    name: "Temperature"
    id: temparature
    register_type: holding
    address: 0x0001
    #custom_command: [ 0x01, 0x03, 0x01, 0x00, 0x00, 0x02]
    unit_of_measurement: "°C"
    value_type: S_WORD
    device_class: temperature
    filters:

    • multiply: 0.1
      state_class: measurement

Logs with errors:

[20:39:43][V][modbus_controller:179]: 1 modbus commands already in queue
[20:39:43][V][modbus_controller:148]: Range : 0 Size: 2 (3) skip: 0
[20:39:43][W][modbus_controller:136]: Duplicate modbus command found: type=0x3 address=0 count=2
[20:39:44][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x00 count 2
[20:39:44][V][modbus:199]: Modbus write: 01.03.00.00.00.02.C4.0B (8)
[20:39:44][V][modbus_controller:509]: Command sent 3 0x0 2
[20:39:44][D][uart_debug:114]: >>> 01:03:00:00:00:02:C4:0B
[20:39:44][V][modbus:042]: Modbus received Byte 1 (0X1)
[20:39:44][V][modbus:042]: Modbus received Byte 3 (0X3)
[20:39:44][V][modbus:042]: Modbus received Byte 0 (0X0)
[20:39:44][V][modbus:042]: Modbus received Byte 0 (0X0)
[20:39:44][V][modbus:042]: Modbus received Byte 0 (0X0)
[20:39:44][W][modbus:108]: Modbus CRC Check failed! F020!=00
[20:39:44][V][modbus:042]: Modbus received Byte 2 (0X2)
[20:39:44][V][modbus:042]: Modbus received Byte 196 (0Xc4)
[20:39:44][V][modbus:042]: Modbus received Byte 11 (0Xb)
[20:39:44][W][component:214]: Component modbus took a long time for an operation (0.05 s).
[20:39:44][W][component:215]: Components should block for at most 20-30ms.
[20:39:45][D][uart_debug:114]: <<< 01:03:00:00:00:02:C4:0B
[20:39:46][V][modbus_controller:179]: 1 modbus commands already in queue
[20:39:46][V][modbus_controller:148]: Range : 0 Size: 2 (3) skip: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment