Hello everyone,
I would like to introduce my latest project to you. Nothing earth-shattering, but for me the first project I realized with ESPhome.
It is a ground humidity sensor based on a Wemos D1 mini, a small OLED display with SSD1306 chip and of course a capacitive sensor.
The sensor is working so far and could be used in this way, but I noticed a few small things which I would like to discuss with you.
Here is the YAML code:
# ESPhome Soil Moisture Sensor v 0.1
esphome:
name: soilsensor
platform: ESP8266
board: d1_mini
# WIFI Credentials
wifi:
ssid: "MY WIFI"
password: "password"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Soilsensor Fallback Hotspot"
password: "password"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "password"
ota:
password: "password"
# Deep Sleep Feature. Needs adjustments...
deep_sleep:
run_duration: 70s
sleep_duration: 120min
i2c:
sda: D2
scl: D1
scan: True
sensor:
platform: adc
pin: A0
id: moisture_sensor
name: "Soil Moisture"
unit_of_measurement: "%"
update_interval: 10s
filters:
# Sensor dry around 0.825 Volt, sensor wet around 0.425 Volt. Volts are were flickering
- calibrate_linear:
- 0.825 -> 0.0
- 0.425 -> 100.0
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
reset_pin: D0
address: 0x3C
# Display output needs adjustments
lambda: |-
it.printf(0, 10, id(my_font), "Feuchtigkeit");
it.printf(0, 32, id(my_font), "liegt bei:");
it.printf(0, 54, id(my_font), "%.1f %%", id(moisture_sensor).state);
font:
- file: "arial.ttf"
id: my_font
size: 20
I noticed the following:
- the values of the sensor are not very stable and fluctuate a bit. Not too bad, but it will get better. Since I want to do the whole thing battery powered anyway and therefore have to use Deep Sleep, I thought of the following. After waking up, the values are determined several times within one minute and then simply calculate an average value for this measurement.
- i had already written it, battery operation and deep sleep should also be included. I played a bit with the possibilities and the sensor goes to sleep after 70 seconds, but it doesn’t wake up properly. After the Deep Sleep phase I can see what’s happening by the power consumption. However, the power consumption is always about half as much as before the first deep sleep phase. Wifi can not be connected either.
- is there a possibility to display the battery status of the sensor? I would like to realize this with a battery shield for the Wemos D1 mini. The A0 pin of the Wemos is already occupied by the humidity sensor…
- in general I would like to interrupt the deep sleep somehow. That would make maintenance a bit easier.
- I’m also not quite satisfied with the output on the display. There is certainly room for improvement.
So far my thoughts first. What are your thoughts about this project? What would you change in the code and why?
Maybe you have some ideas how to realize my wishes?
I am happy about your suggestions and comments.
Thanks a lot
JAD