DIY Smart gardening

Christian Kellner
4 min readJun 11, 2021

--

This is the next blog post in a series where I’m explaining how and what I did to.. well do less.. at least when it comes to watering the plants :)

This time, I finally make use of the weather station I build a couple of months ago. But I wanted to take it a couple of steps further. I wanted to build a system that is watering the plants automagically, based on temperature and whether or not it rained on that day.

After I put some thoughts into how I’d actually water the plants, I was pretty convinced, I was not trusting myself enough to build something that is directly connected to a tap. That is why I bought a big box that can hold up to 60l of water. I also bought a pump.
I can recommend using this pump as it is pretty cheap but comes with everything needed. The pump works in the way that you put it into the water and as soon as it’s connected to power, it’s running for a minute. To run it again, you have to switch off power and switch it back on again. Perfect for automation. Also for something that swims in the water all day, it’s actually pretty clever to cut the power.

My (hardware) setup

Hardware Setup
The box containing the water
Inside of the box

Measuring the water level

As you can see on the first photo, there’s a tiny box on the top of the box containing the water. This contains an ESP8266 connected to a battery as well as a HC-SR04 distance transducer. This measures the distance between the top of the box and the water level. If it reaches a max distance, I know the water level is too low, thus stop the automation.

HC-SR04 distance transducer
HC-SR04 distance transducer to check the water level
HC-SR04 distance transducer
Holes in the top of the box to check water level

My (software) setup

To run all of this, I’m using Homekit. The pump is connected to a Homekit power outlet. This enables me to create automations.

As always, the code is on Github.

Screenshot of sensors
The percentage is showing how much water is left in the box

I have 2 automations.

Automations

Regular watering

WHEN (Time => 8am or Time => 7pm)
AND (enough water in the box left)
AND (no rain)
THEN (turn on power outlet) (therefor start watering)
AND (turn off after 2 minutes)

Watering if it was a hot day

WHEN (Time => 7.05pm)
AND (enough water in the box left)
AND (no rain)
AND (temperature is still > 25c)
THEN (turn on power outlet) (therefor start watering)
AND (turn off after 2 minutes)

Alarms

If the water in the box falls below a certain threshold, I’m getting an alarm on my mobile, so that I know it’s time to refill. This check is important so that the pump is not running dry.

This is it. It works great and reliable. And most importantly it’s doing everything automagically. I don’t have to care while on vacation. (Well beside of asking a neighbour to refill the box every once in a while, but honestly, I will never trust myself enough to connect something that I build myself to a tap while not around ;))

Some impressions

--

--