Hello,
I have a water tank to harvest rain water used for my toilets and washing machine.
I wanted to have a visual display and the info in my HA to save me opening the cover.
So I started buying some stuff to start with my project:
- esp8266
- ultrasonic HC-SR04 sensor
- ssd1306 oled display
- sht40 temp and humidity sensor
- 3d printed housing for my ultrasonic sensor
some pictures of the WIP:
The code is used:
esphome:
name: esphome-web-863f1b
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-863F1B"
password: "zen0qxS0Jec0"
captive_portal:
i2c:
sda: 4
scl: 5
font:
- file: "gfonts://Roboto"
id: my_font
size: 16
# https://esphome.io/cookbook/display_time_temp_oled.html
# https://gist.github.com/tubalainen/19103e725c1d7331bc16eae130a6757d
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
id: my_display
pages:
- id: page1
lambda: |-
it.printf(0, 0, id(my_font), "WIFI: %.0f", id(puissance_wifi).state);
it.printf(0, 16, id(my_font), "Eau: %.2f / %.0f", id(distance).state, id(distance).state);
it.printf(0, 32, id(my_font), "T: %.1f°C H: %.0f", id(temp).state, id(hum).state);
sensor:
- platform: sht4x
temperature:
name: "Temperature"
unit_of_measurement: "°C"
device_class: "temperature"
state_class: "measurement"
icon: "mdi:thermometer"
accuracy_decimals: 1
id: temp
humidity:
name: "Relative Humidity"
unit_of_measurement: "%"
device_class: "humidity"
state_class: "measurement"
icon: "mdi:water-percent"
accuracy_decimals: 0
id: hum
- platform: ultrasonic
trigger_pin: 12
echo_pin: 14
name: "Hauteur d'eau cuve"
update_interval: 10s
timeout: 3m
id: distance
filters:
- lambda: return (2.32-x);
- filter_out: nan
# Qualité du signal
- platform: wifi_signal
name: "Signal Wifi"
update_interval: 60s
id: puissance_wifi
# Temps de fonctionnement
- platform: uptime
name: "Allumé depuis (s)"
id: uptime_sec
binary_sensor:
# statut
- platform: status
name: "Statut"
switch:
# Bouton de redémarrage
- platform: restart
name: "Redémarrage"
# Transformation des secondes en jours
text_sensor:
- platform: template
name: "Allumé depuis (j)"
lambda: |-
int seconds = (id(uptime_sec).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
icon: mdi:clock-start
update_interval: 60s
My current challenge is being able to convert the water tank height into liter.
My tank looks like this:
Can anynody help with the formula to calculate the volume knowing the diameter and lenght of the tank and the height of the water?
Thank you!