ESP32 Plant waterer, (ESPHome managed device with Home Assistant automation)
This is a simple low-cost automated plant watering system, designed to work with Home Assistant based on ESP32 configuration and Over-The-Air (OTA) updates and management from the ESPHome plugin.
The setup uses MQTT protocol to publish sensor data allowing Home Assistant to monitor and trigger watering automations based on automation patterns described in this setup.
The setup includes the following instructions and (working) code;
- ESPHome code that needs to be flashed onto your ESP32 device
- Home Assistant Dashboard YAML
- Home Assistant watering automation YAML
- historical_stat sensor YAML (acts as failsafe for watering automation)
- Home Assistant Error & Alerting automation YAML
The project and code is built around low cost M Stack Atom Lite, a low cost minature ESP32-pico based board. I originally tested this with smaller ESP-32 pico based boards, however most of these do not have embedded USB ports so an additional USB/ TTL convertor is required to initially flash these devices and potentially a separate power regulator board would be required.
The M5 Atom Lite includes USB-C connector, onboard RGB LED, and exposes enough GPIO pins to support this project in a single 24mm x 24mm package and available for around $7 USD at the time of writing.
At the time of writing M5Stack also have a nicely packaged watering addon retailing at arround $8 USD, which combines a capacitive water sensor (capacitive sensors have a longer lifespan than the cheaper conductive sensors out there) and low powered water pump in a single unit which is designed to plug straight into the M5 range via a Grove connection which makes the hardware easy to assemble.
The M5 Atom Lite can provide enough power to run the water pump, (only tested when plugged into use power).
Bill of materials
- M5Stack Atom Lite (SKU:C008)
- Watering Unit with Moisture Sensor and Pump (SKU: U101)
- 1 x empty water bottle/ container
- 1 x USB power adaptor
Hardware
Setup is pretty easy – as the M5 Atom Lite and the watering unit both use a compatible grove connector (cable is provided in the watering kit).
ESP32 setup
The easiest way to set this up is to set up a new device in ESPHome and paste the YAML code and run the installation process.
This guide assumes you are familiar with ESPHome, and have installed the MQTT broker service in Home Assistant.
You need to add the “historical_stats” code to Home Assistant “configuration.yaml”, and restart Home Assistant, this sensor monitors the number of times watering automations have run in the last 4 hours, and is used to prevent the automation getting in a loop and overwatering. Also as this project does not have a water level sensor in the resevoir this is also used to raise alerts that the water reservoir has run out or the water pipe or is not spraying water into the plant pot. (this last one could save a whole container of water being fed to your carpet if things go wrong!).
Once complete you should see the device show up in MQTT
The example folder has example YAML for the following;
(working) example dashboard, automation, alerting YAML available in the GitHub link at the top of this page.