This was a super fun project that actually combines so many disciplines. We have some tinkering, some fun designs, 3D-Printing. There are sensors and motors and microcontrollers and code. And the best about it, it actually works now and my lemon and chilli plants are flourishing. 

I'll describe a little bit on how I build it and try to give as many insights about stuff that didn't go as planned. The code for this project is all published on my GitHub.

The first part I had was this huge jar that I thought was a nice base / water tank. So all the electronics were supposed to sit on top of it. The heart of it is an ESP-32 that connects to the wifi in my shop to check for the time. In the future I might connect it to a cloud to to track what is happening there as well.

The system is powered with a 12V Mini-USB phone charger. This can supply the pump directly and gets converted to 5V for: 

- the ESP

- the 128 x128 OLED display

- two capacitive soil moisture sensors

- a water level sensor

The pump is controlled via a relay but can also be bypassed with the second button without even starting the esp. The moisture sensors are programmed to measure five times in a row and the average value of these is then displayed on the screen.

capacitive soil moisture sensor

Before watering the water level sensor checks if the tank is properly filled. Since these sensors tend do corrode when used, this only happens once and the pins, that provide power to the sensor is only set HIGH for the very moment it is needed. I'm not sure if that actually helps keeping corrosion to a minimum. If anybody has input on that. I'm happy to hear it.

water level sensor

To keep energy consumption to a minimum, the ESP is in sleep mode most of the time. There are a couple of interrupt. First the button on the panel. When pressed, the oled will show water level, soil moisture, the time and the hours left til it wakes up for watering. This countdown is actually the second interrupt. When the ESP starts, it connects to the local wifi, checks for the current time, calculates the milliseconds until the set watering time and goes to sleep again. 

If the tank is empty, the system will wake up more often and a blue LED will flash inside the tank.

A lot of variables are summed up and can be defined in a constants.h file:

Besides the microcontroller Pins and other system variables, there are also so thresholds, watering times and other details. What the system actually does is: 

check for the , moisture and water level -> if all is cool -> water for some seconds -> sleep for a couple of minutes -> repeat this process until watering time is over.

I separated all the sensors and outputs in reusable blocks and files so they might be useful for other projects.

The pipes are just punctured aquarium tubes and one pump supplies both of them. Therefor there is a calculation that only starts pumping if both pots are dry enough.

After now five month of running it, I really think it was a success. The start was a bit rough. I just put a lot of seeds in there which needed a lot of water but couldn't suck it up from the soil. So I had to water quite often, even though the soil was already pretty moist which caused a pest infestation with small flies. So for everyone starting a project like this I would recommend using plants that already grew a certain height and consume water from the ground straight from the beginning and are already a little more robust.

For the future. 

As mentioned above, The step to hook the system up to a cloud and check or even control it from a smartphone is totally an option.

Maybe rather than improving this system. Building a bigger one, that uses valves or more pumps to water plants more selective would be cool. For example for the balcony, which is a less closed system anyway. Also running it with solar power would be nice. 

That's it. I hope you enjoyed the little read. Don't hesitate to ask, If you have any questions or comments and listen to Mort Garsons...

Read more »