* Automatic plant watering with Raspberry Pi
3. December 2018, Jakub Horák. Categorized as IoT.
Who hasn’t had hers/his plants die at home while traveling for a few days? Unfortunately my plants suffered from this fate too. Since I already have my plants connected to the internet via Raspberry Pi, notifying me whenever the soil gets dry, one solution is to have that same event trigger actual plant watering. That’s what I set out to accomplish. By researching online, I stumbled upon an interesting tutorial Raspberry Pi Automated Plant Watering with Website which describes the hardware build very well, but adds a web server on top, which I find useless. I decided to run my own software stack.
Hardware parts necessary (assuming Raspberry Pi plant sensor is built already):
- mini motor water pump 3-6V
- 7-10mm aquarium hose
- container which can hold some water
- soldering iron, solder
- 5V relay
- old USB charger
After getting all the necessary parts, first step is to cut the USB charger phone part off and expose red and black wires. Next, solder the red wire sticking from the pump to the red wire exposed from the USB charger cable.
When the soldering is done, it’s time to connect everything together. See the complete wiring diagram with two moisture sensors in the figure below.
Ports (as per pinout.xyz) used for the pump are (first relay, then Raspberry Pi 3):
The next step is to fill the water container with water, tape the pump as close as possible to the container’s floor and use something (e.g. a wine bottle) to hold the outlet from the hose. I measured, that the motor can pump 23ml of water each second, thus it should be enough to pump for 1 or 2 seconds each time when the soil is dry.
As for software, get my updated scripts from the associated GitHub repo. The configuration from moisture.py can be seen below. First the moisture sensors are set-up:
# Define the GPIO pin that we have our digital output from our sensor # connected to and URL which to call on sensor state change sensors = { "peace_lily": (17, "** URL 1 **"), "parsley": (23, "** URL 2 **") } |
then the water pumps:
# Define the GPIO pin that we have our digital input to the # respective relay connected to and number of seconds to pump # each time pumps = { "parsley": (27, 1) } |
When I get my second water pump, after wiring, I will just add a new entry under “pumps” with the corresponding pin.
That’s all folks, happy farming!
2 Responses to “Automatic plant watering with Raspberry Pi”
Leave comment
Archives
- March 2024
- October 2023
- May 2020
- December 2018
- October 2018
- July 2017
- April 2017
- March 2017
- November 2016
- April 2016
- March 2016
- November 2014
- September 2014
- May 2014
- March 2014
- February 2014
- August 2013
- June 2013
- April 2012
- August 2011
- May 2011
- October 2010
- September 2010
- August 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- April 2009
- January 2009
- December 2008
- October 2008
- September 2008
12. January 2019 at 22:57
I like what you’re doing here. Only problem I’ve had so far is Ansible installation. Does it matter which directory all the python scripts and yml files are located?
Best regards
Rob
13. January 2019 at 18:51
Hi Rob,
no, it shouldn’t matter, which directory you have the scripts. You just need to run the ansible command from that location. E.g. if you have checked out the GitHub project into rpi-moisture directory, you need to run the command inside rpi-moisture.