The best way for me to participate in Justine’s hobbies is to over-engineer them and her garden is no different. To reduce the water we use to water her garden I came up with a smart water barrel that:
- Can turn the pump for the barrel water on and off
- Has four float switches to detect the barrel water level
- Uses two valves to select barrel water or city water
- Monitors two soil moisture sensors to determine if watering is needed
- Connects to my Home Assistant automation server for control and logging
- Uses the weather forecast to postpone watering if rain is imminent
Here is my Friday Demo presentation about the rain barrel I gave at the beginning of Recurse Center.
The components are all installed in a waterproof project box. I 3D printed brackets to hold the miscellaneous circuit boards. I used various waterproof cable glands and cheap waterproof connectors to connect the pumps, valves, and sensors to the box. The wiring is messy in this photo because I didn’t want to lock it down until all the programming is done.
The communication between Home Assistant and the rain barrel controller is via MQTT – a simple messaging service for IOT devices. It’s very easy to do things like “send the water level” and then have Home Assistant recognize that as sensor data. The MQTT client controlling the rain barrel runs code I wrote in C++ running on an ESP8266 IoT board. The rain barrel controller sends periodic sensor data and listens for command messages to actuate the valves and pumps.
Here is the wiring for the rain barrel.
Right now I’m just manually triggering the rain barrel to water but the next step is to implement a “water tomorrow at 6am for X amount of time” button to delay watering to an optimal time of day. If that goes well and I feel like I have a good handle on the sensor data I’d like to implement a “water tomorrow at 6am for X amount of time if it’s not going to rain and the soil is dry” routine.
The barrel is a trash can which I bought in white to match the house but turns out to be a poor color choice since algae gets enough light to grow inside. Since it’s below the garden, there’s a sump pump inside and or this project I redid the plumbing after the pump to add the two automatic valves in a Y configuration feeding the spigot.
Here’s what the rain barrel dashboard looks like in Home Assistant. I created custom control panels using Home Assistant community components.
One page is the controls where you can actuate the valves and turn the pump on and off. There’s also two commands you can send to the rain barrel to enable faster logging of the soil moisture (because I’m using an extra mechanical relay to mux the two soil moisture sensors to one analog input, I only check the soil moisture a few times an hour because otherwise the relay would have hundreds of thousands of cycles in only a few years of operation). The one soil moisture sensor is unplugged at the moment so the readings are screwy. For that matter, I’m still trying to figure out if the capacitive soil moisture sensor actually produces any useful data. The water level data seem reasonably well behaved after lots of averaging.
The other page is a weather dashboard centered around the weather forecast for the next few days including a grid of dials that show the amount of rain and probability of the next four days.