Raspberry Pi–powered bonsai watering system

Bonsai trees are the most glorious of miniature shrubbery. But caring for them takes seriously green fingers. Luckily, this Raspberry Pi–powered bonsai watering system doesn’t require much to get started. Also, the Reddit user who shared the project is named Lord-of-the-Pis, so, we love.

You will need:

  • Raspberry Pi
  • Submersible water pump
  • Jumper wires

The Pimoroni Explorer HAT Pro isn’t essential to make this project work, it just makes things a whole lot easier by removing the need for a relay. It also comes with a Python library for interfacing with Raspberry Pi. The project uses an I2C connection, so it would also be possible to not use the HAT and instead plug a moisture sensor into an analogue-to-digital converter and then into Raspberry Pi’s GPIO pins.

How was it done?

Lord-of-the-Pis explains: “I used the Pimoroni Explorer HAT Pro in order to make the entire system on a small breadboard on top of  Raspberry Pi. The Explorer HAT has inbuilt analogue inputs over I2C, which I used for the input of the moisture sensor (two wires pushed into the soil as probes). Furthermore, the output GPIO pins on this HAT sink all current to ground when activated so they can be used as a transistor to power the small 5V motor (which was also attached to the 5V power pins on Raspberry Pi).”

Using the HAT also allowed this maker to simply hook the pump up to the GPIO pins and turn these on and off, so there’s no need for an on/off switch.

How does it work?

This project’s code is in Python 3, and you can find it all on GitHub.

The main watering program (plantWater.py) takes input from the moisture sensor, and if the soil moisture level is below a set amount, the bonsai gets watered.

Lord-of-the-Pis built a simple web interface for the project on a  localhost site that’s hosted using Apache. Apache SSI is used to execute the Python scripts. Due to the use of SSI, the index page is called index.shtml.

An image of the website. The Dip and then steadiness of the graph is due to the faulty moisture sensor. The maker has ordered another!

A lot more detail about the hardware and software involved is available in this second reddit post about the project.

Lord-of-the-Pis is now working on a dashboard that plots the soil moisture over time, as well as tracking other things like light intensity, temperature, and humidity.

May no other plant perish due to overwatering on our watch ever again!

10 comments

Médéric Bellemare avatar

Have a question for you. i work on something similar and i want to know what do you use for getting humidity data ? and do you use mutlithreading for getting data at any moments ? or only a single loop and stop the thread for watering the plant.

thanks you !

Vaseef avatar

Try DHT11 or DHT22 sensor for Humidity.

Anton avatar

I bet he is using soil humidity sensor like this https://www.makerfabs.com/soil-humidity-sensor-capacitive.html or this https://m.aliexpress.com/item/33032034387.html . There are videos on how to use them and how to choose right one like https://m.youtube.com/watch?v=udmJyncDvw0

Harry avatar

Hi, I’m the reddit user from the post, the first iteration of the design that you can see in the picture uses a pretty terrible soil moisture sensor (like this one https://www.amazon.co.uk/AZDelivery-Hygrometer-Moisture-Module-Arduino/dp/B07CNRJN8W/ref=sr_1_9?dchild=1&keywords=Soil+Moisture+Sensor&qid=1592301737&sr=8-9) However I have since swapped to a capacitive one (Like the one linked in the comment above). This project was programmed a while ago so I apologise for the state of the code on Github, if I have a spare couple of hours I would probably go over and clean it all up. If anyone has any questions, feel free to message me through Reddit or Github.

Panic avatar

An ESP32 would have been a much more effective controller. You could then use the Pi as a NodeRed/MQTT broker for lots of other ESP/Arduino IoT projects.

Jeffrey B Gordon avatar

Those moisture sensors wear out over time, essentially welding themselves together. It’s best to poll them as infrequently as possible.

Pond life avatar

Would this sensor work for water level in a pond and allow a top up?

Mitoz avatar

It’s nice to have it for my bonsai

Download Teatv avatar

It works really on my bonsai

Teatv apk avatar

It works really on my bonsai

Comments are closed