Greeting all
I need your support to resolve an issue that faced me for my first ESPhome project to create water tank level sensor.
following this guide: Water tank monitoring with ESPHome
Parts in this project:
ESP32 Development Board Wireless WiFi Bluetooth module Ultra-Low Power Consumption Dual Core 30Pin ESP32-WROOM-32S 32D ESP 32
I tried many scripts and trils with no luck to get a any value for the level.
screen shot and code :
code:
esphome:
name: "tank-level"
friendly_name: "tank-level"
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
wifi:
ssid:
password:
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "tank-level Fallback Hotspot"
password: "OFLmnY89P7zG"
captive_portal:
sensor:
# Wifi signal sensor.
- platform: wifi_signal
name: garden_watertank_wifi
update_interval: 600s
unit_of_measurement: '%'
filters:
- lambda: |-
if (x <= -100) {
return 0;
} else {
if (x >= -50) {
return 100;
} else {
return 2 * (x + 100);
}
}
# Templates for calculated liter & percent
- platform: template
name: garden_watertank_liter
id: garden_watertank_liter
icon: 'mdi:water'
unit_of_measurement: 'l'
accuracy_decimals: 0
- platform: template
name: garden_watertank_percent
id: garden_watertank_percent
icon: 'mdi:water-percent'
unit_of_measurement: '%'
# The actual distance sensor
- platform: ultrasonic
trigger_pin:
number: GPIO12
inverted: True
echo_pin: GPIO14
name: garden_watertank_distance
update_interval: 600s
pulse_time: 50us
filters:
- filter_out: nan
- median:
window_size: 7
send_every: 4
send_first_at: 3
- calibrate_linear:
- 0.23 -> 1.86
- 2.41 -> 0.0
on_value:
then:
- sensor.template.publish:
id: garden_watertank_liter
state: !lambda 'return x * 3141.592653589793238;'
- sensor.template.publish:
id: garden_watertank_percent
state: !lambda 'return x * 53.979255216319471;'
kindly support me on how i can get the issue solved as i try it in tasmota and Arduino and both give a numeric value