Automatic plant watering and illumination (smallest version)

26 Jul 2020 - tsp
Last update 22 Nov 2020

Note: Product links in this blog post are Amazon affilate links, this pages author profits from qualified purchases.

Disclaimer: As usual - no guarantees are made that this stuff works, is safe or satisfies any regulations (even if it fulfills them in my area). If you don’t know how to wire devices for the electric power grid don’t do it - electicity might not be complicated but there are some basic things to know (and also some regulations) - and in case your house burns down insurances might not pay anything in case you’ve been not qualified or allowed to perform such work. The same goes for piping: Even small leakage might lead to huge damage on buildings - bringing the same liability problems if you don’t know local regulations or are not allowed to perform such work.


So after a few years of growing basil, capsicum and chili pepper indoor one gets some problems: One gets tired of everyday watering (sometimes necessary) because that takes at least 30 minutes a day, tired of dead plants after being on vacation and of course slow growing plants during winter. To counter these problems this little plant watering and illuminating project has emerged - in fact this is a so short project that writing this blog post took longer than the realization. Basically it tries to address these problems:


The basic structure has been built from cheap construction wood (note that this is wood that’s not been planed or shaped but got directly from the band-saw cutting at the lumber mill). This is a somewhat simple construction using three planks in parallel - two to reach the required depth and one to reinforce against bending. Pillars are cut at every floor so that planks can directly lay on top of them to avoid any unnecessary torque carrying connections. Screws are only used to keep the planks and pillars in place, not to carry any load or torque - like with every timber frame. Since the structure is that narrow and high it’s attached to the wall using four screws at the top end.


Yes, that’s not the most good looking structure but it’s rather cheap and since it was assumed to possibly get wet the cheapest solution has been used.


There are different solutions for plant illumination available:

Since LEDs are rather expensive the decision was to use a combination of fluorescent tubes and LED stripes. The LED stripes alone did not provide enough energy density but are used for a longer duration in addition to fluorescent tubes. Each of the used column already contains an electronic ballast to ignite the lamps and limit current so they can be directly attached to mains voltage.

Illumination can be switched via:

The LED stripes are powered by a 200W 12V power supply that’s also switched on the primary side using the same technique as the fluorescent lamps.

Illumination and 5V power supply

The 5V power supply seen on the right was not connected during the take of the photograph - it is used to power logic components and sensors as well as some 5V fans.

Note during wiring to use the correct cable cross sections and follow regulations for phase shifting when connecting fluorescent lamps in series - you might require power factor correction in case of too many lamps or you’d have to wire them in parallel rather than in series.


Spray nozzles

Irrigation is rather simple and done using a high pressure membrane pump since the water has to be pumped at least two and a half meter above the ground - and there still has to be enough pressure to be sprayed at the spray nozzles.

Membrane pump

Membrane pump mount

The pump itself is using a main distribution hose with 8mm inner diameter and 10mm outer diameter, the branches in each level use hoses with 8mm outer diameter and 6mm inner diameter that perfectly match the spray nozzles. All components are standardized and will be easily replaceable even a few years from now. The membrane pump has two ingress filters, the coarse filter being submerged into the tank directly attached to a copper tube to stay fixed in place and a second filter included directly inside the pump.

On the egress side the 8mm hose is broken up with T shaped segments that allow attachments of 6mm hoses that distribute water to the spray nozzles.

The pump has to be noise damped though since membrane pumps are pretty loud. To accomplish this Neoprene anti vibration pads (note: Amazon affiliate link, this pages author profits from purchases) have been added in between the pump and the frame to which it has been screwed. Additionally acoustic foam has been used to enclose the pump - note that this has to be taken into consideration when planning the system since the foam of course limits cooling of the pumps. Since operation time of the pumps is below two minutes each with multiple hours in between each watering session this wasn’t a limit.

The pump itself is powered again by a 12V power supply. This supply can be switched on the primary side in case the pump is the only load that required 12V (in case no instrumentation and other pumping equipment for fertilization or solenoid valves for filling are required). Since the solenoid valves are also running of 12V and are only required during an active pump primary side switching is totally feasible in case no fertilizer mixing or aeration is required or in case they’re powered of different voltage (5V pumps) or power supplies. This of course decreases PSU lifetime but significantly lowers power consumption. In my case the first system has been switched with a Sonoff Basic (note: Amazon affiliate link, this pages author profits from qualified purchases) again since I’ve had a bunch of them lying around. The firmware used in this case offers the option to enable or disable using MQTT and an REST API as well as the local button - and allows the submissions of operation period using MQTT. The operation period excluding the constant startup time of the pump is directly proportional to the amount of water - so it’s possible to regulate the water amount in liters. This setting is available inside a Node-Red dashboard. To circumvent outages due to a failing node-red instances the Sonoff switch is programmed to perform periodic irrigation in case of missing remote commands. Running duration is also limited to avoid flooding by malformed command messages or malicious users.

Additionally a water volume sensor has been added for error detection. In case the counted volume doesn’t match the expected volume (at least doesn’t match it inside some given error margin) the whole system will be disabled until manually controlled maintenance.

Water tank

The water tank used can take up to 25 liters a day (and thus can weight in theory up to 25kg). To better suite the frame it has been put horizontally and the wastewater pipe used for circulation has been attached through a hole in it’s cap. Because of this about 1/5 of the tank volume cannot be flooded without risking overflow (even though all screw couplings and pipe feeds seem to be watertight I wont risk this since there are no proper seals in place and the system runs unattended most of the time).

The feedwater pipe is attached via a copper tube - the filter is applied to the bottom. The pipe has been used to ensure the filter and ingress tube stays at the lowest possible position.

Water tank

Feedwater filter

The level inside the water tank is monitored using a simple ultrasonic distance sensor. This has been chosen over a conductive probe since conductive probes as well as capacity probes only measure electric conductivity or polarizability, not water level. As plants consume nutrients or as they are washed out of the earth (depending on the state of the dirt used) the density of dissolved solids varies and as such the conductivity and polarizability. So EC can be used as a measure of available nutrients as long as one knows the water level inside the tank. Data is read out using an ESP32 development board, although this will soon be replaced using a custom ESP32 board that includes an Ethernet PHY to allow ethernet attachment instead of WiFi connectivity.

Water circulation

Since the system operates indoors overflow handling was important. To allow excess water to overflow the plant pots standardized 32mm wastewater pipe has been used. These pipes are fitted with proper seals to avoid any leakage, are pretty easy to assemble and are cost efficient. They are connecting using T shaped elements for every story. The end of the pipe network passes through the cap of the water tank and reaches into the water tank. Don’t try to substitute these pipes with 6mm or 8mm inner diameter PVC or silicone hoses - the adhesion of water will prevent draining in case you’ve got longer horizontal or near horizontal sections. Using such hoses might only work in case they go strictly vertical - but in case they move and are bent at an narrow angle they’ll get blocked and the area would be flooded. Going with standard wastewater pipes is really easy and they don’t look that bad anyways - way better than a bunch of hoses hanging around.

For every flowerpot there is an drip mat below that got drilled through. Then there is 8mm PVC hose attached to the holes and sealed with polysiloxane (silicone). To have some kind of protection against clogging of the drains by falling leafs there are at least two drains per drip mat.

Membrane pump

Of course water circulation also means that wastewater that might carry disease or fungi would distribute these pathogens to all plants inside the system. One might of course instead decide to drain the water into some external wastewater treatment or into the garden. This of course also heavily depends on the availability of wastewater sinks as well as the general desire to limit water loss.

As it turns out having some kind of overflow drainage is really required for an indoor watering system to prevent overflow into the room as well as not having to radically tune the volume - and possibly delivering not enough water volume

Typical water volume inside the tank during irrigation including backflow


Will be described soon

Instrumentation (Sensors) and monitoring

Will be described soon

Water level monitoring (Ultrasonic)

The water level inside the water tank is monitored using a simple ultrasonic distance sensor connected to an ESP8266/ESP32 (I’ve tried both - the main difference beeing Ethernet support on the ESP32 which i totally prefer over WiFi connectivity of the ESP8266). Since I didn’t want to do any major redesign I simply used HC-SR04 breakout boards (note: Amazon affilate link). Using these sensors I’m doing one measurement every 125 milliseconds (i.e. 4 times a second). These measurements are then published as raw data and as calculated water height using MQTT. The payload is encoded as JSON object as usual.

As one can see the raw values of the ultrasonic sensor are somewhat noise with large outliers occuring. I’ve simply solved this by applying a moving median filter to the raw calculated height as well as clamping the measured height to the valid output range. Using the moving median filter of course introduces some delay - but since the whole system is sluggish by nature - and because of the used pumps and pipe diameters - this is of course not a problem.

Data collected and watering optimization using a closed control loop

Will be described soon

This article is tagged: DIY, Tutorial, Sonoff, Home automation

Data protection policy

Dipl.-Ing. Thomas Spielauer, Wien (

This webpage is also available via TOR at http://jugujbrirx3irwyx.onion/

Valid HTML 4.01 Strict Powered by FreeBSD IPv6 support