You were right with a flow control pin. I definitely need to write something to sensor - commands for reading. So I need a flow control pin for MAX485.
Finally my wiring:
I have also switched the A and B (blue and yellow) wires from sensor to MAX485. Now it is working. Sensor is sending unit “cm”, but is measuring in “mm”. Measurements are very quick and very accurate (water level in the bucket 122mm, value returned: 122). Current draw by sensor is stable 5.7mA.
My final esphome yaml for those, who will look for working setup in a future:
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: DEBUG
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: "mm"
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
flow_control_pin: GPIO35
modbus_controller:
- id: qd
address: 0x01
modbus_id: modbus1
setup_priority: -10
update_interval: 5s
status_led:
pin:
number: GPIO15
Thanks a lot to all!
