I have bought water level sensor QDY30A from Ali QDY30A - the modbus RS485 version. I am trying to read its values using Wemos ESP32 S2 mini with Esphome and Max485, but no luck. Looks like the modbus connection is completely dead. Sensor docs are not so good, only wiring on that Ali page (and those colors are not correct as I have green instead of black). Some datasheet I found here (PDF). Modbus data sequence written in logs seems to be ok.
What I have also tried with no result:
- connect DE and RE pins on MAX485 and put them to GND (signalizing always “read”)
- switch RX and TX on ESP32
- switch blue and yellow from sensor (A to B) as some docs shows them switched
Any hints what is wrong?
My wiring:
My yaml
substitutions:
devicename: water-tank
friendly_name: Water tank sensor
device_description: Water tank sensor (Carat 4m3)
esphome:
name: ${devicename}
friendly_name: ${friendly_name}
comment: ${device_description}
esp32:
board: lolin_s2_mini #Pinout: https://www.wemos.cc/en/latest/s2/s2_mini.html
variant: esp32s2
framework:
type: arduino
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${friendly_name} Hotspot
password: !secret wifi_ap_password
ota:
password: !secret ota_password
# Enable logging
logger:
level: VERBOSE
baud_rate: 0
captive_portal:
# restart
button:
- platform: restart
name: Restart
sensor:
# Reports how long the device has been powered (in minutes)
- platform: uptime
name: Uptime
filters:
- lambda: return x / 60.0;
unit_of_measurement: minutes
# water level sensor
# https://esphome.io/components/sensor/modbus_controller.html
- platform: modbus_controller
modbus_controller_id: qd
name: "Water level"
id: modbus_water_level
register_type: holding
address: 0x0004
unit_of_measurement: "cm"
value_type: S_WORD
# Reports the WiFi signal strength
- platform: wifi_signal
name: Wifi Signal
update_interval: 60s
text_sensor:
- platform: version
name: ESPHome Version
- platform: wifi_info
ip_address: # exposes the IP Address when connected
internal: true
id: wifi_ip_addr
name: "IP Address"
uart:
id: mod_bus
tx_pin: GPIO39
rx_pin: GPIO37
baud_rate: 9600
data_bits: 8
stop_bits: 1
parity: NONE
debug:
modbus:
id: modbus1
uart_id: mod_bus
send_wait_time: 500ms
modbus_controller:
- id: qd
address: 0x01
modbus_id: modbus1
setup_priority: -10
update_interval: 5s
status_led:
pin:
number: GPIO15
Logs:
INFO Successfully connected to water-tank @ 172.16.1.243 in 0.347s
INFO Successful handshake with water-tank @ 172.16.1.243 in 8.833s
[19:28:14][I][app:102]: ESPHome version 2024.2.1 compiled on Mar 3 2024, 17:39:55
[19:28:14][C][status_led:019]: Status LED:
[19:28:14][C][status_led:020]: Pin: GPIO15
[19:28:16][C][wifi:577]: WiFi:
[19:28:16][C][wifi:409]: Local MAC: 80:65:99:49:8A:98
[19:28:16][C][wifi:414]: SSID: 'Vega'
[19:28:16][C][wifi:415]: IP Address: 172.16.1.243
[19:28:16][C][wifi:417]: BSSID: 2A:3B:82:4D:2D:6C
[19:28:16][C][wifi:418]: Hostname: 'water-tank'
[19:28:16][C][wifi:420]: Signal strength: -50 dB ▂▄▆█
[19:28:16][V][wifi:422]: Priority: 0.0
[19:28:16][C][wifi:424]: Channel: 9
[19:28:16][C][wifi:425]: Subnet: 255.255.255.0
[19:28:16][C][wifi:426]: Gateway: 172.16.1.1
[19:28:16][C][wifi:427]: DNS1: 192.168.1.1
[19:28:16][C][wifi:428]: DNS2: 0.0.0.0
[19:28:16][C][logger:447]: Logger:
[19:28:16][C][version.text_sensor:021]: Version Text Sensor 'ESPHome Version'
[19:28:16][C][mdns:115]: mDNS:
[19:28:16][C][mdns:116]: Hostname: water-tank
[19:28:16][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x04 count 1
[19:28:16][V][modbus:199]: Modbus write: 01.03.00.04.00.01.C5.CB (8)
[19:28:16][V][modbus_controller:509]: Command sent 3 0x4 1
[19:28:16][D][uart_debug:114]: >>> 01:03:00:04:00:01:C5:CB
[19:28:16][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x04 count 1
[19:28:16][V][modbus:199]: Modbus write: 01.03.00.04.00.01.C5.CB (8)
[19:28:16][V][modbus_controller:509]: Command sent 3 0x4 1
[19:28:16][D][uart_debug:114]: >>> 01:03:00:04:00:01:C5:CB
[19:28:17][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x04 count 1
[19:28:17][V][modbus:199]: Modbus write: 01.03.00.04.00.01.C5.CB (8)
[19:28:17][V][modbus_controller:509]: Command sent 3 0x4 1
[19:28:17][D][uart_debug:114]: >>> 01:03:00:04:00:01:C5:CB
[19:28:17][D][modbus_controller:043]: Modbus command to device=1 register=0x04 countdown=0 no response received - removed from send queue
[19:28:20][V][modbus_controller:181]: Updating modbus component
[19:28:20][V][modbus_controller:148]: Range : 4 Size: 1 (3) skip: 0
[19:28:20][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x04 count 1
[19:28:20][V][modbus:199]: Modbus write: 01.03.00.04.00.01.C5.CB (8)
[19:28:20][V][modbus_controller:509]: Command sent 3 0x4 1
[19:28:20][D][uart_debug:114]: >>> 01:03:00:04:00:01:C5:CB
[19:28:21][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x04 count 1
[19:28:21][V][modbus:199]: Modbus write: 01.03.00.04.00.01.C5.CB (8)
[19:28:21][V][modbus_controller:509]: Command sent 3 0x4 1
[19:28:21][D][uart_debug:114]: >>> 01:03:00:04:00:01:C5:CB
[19:28:21][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x04 count 1
[19:28:21][V][modbus:199]: Modbus write: 01.03.00.04.00.01.C5.CB (8)
[19:28:21][V][modbus_controller:509]: Command sent 3 0x4 1
[19:28:21][D][uart_debug:114]: >>> 01:03:00:04:00:01:C5:CB
[19:28:21][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x04 count 1
[19:28:21][V][modbus:199]: Modbus write: 01.03.00.04.00.01.C5.CB (8)
[19:28:21][V][modbus_controller:509]: Command sent 3 0x4 1
[19:28:21][D][uart_debug:114]: >>> 01:03:00:04:00:01:C5:CB
[19:28:22][V][modbus_controller:047]: Sending next modbus command to device 1 register 0x04 count 1
[19:28:22][V][modbus:199]: Modbus write: 01.03.00.04.00.01.C5.CB (8)
[19:28:22][V][modbus_controller:509]: Command sent 3 0x4 1
[19:28:22][D][uart_debug:114]: >>> 01:03:00:04:00:01:C5:CB
...