I am making my mother an automated watering system for her garden with my Raspberry Pi. I would like the system to be able to detect soil moisture, as well as predict temperature and humidity to determine when it is best to water.

There are several different locations in our yard where I could deploy the Pi, most of which present a challenge as far as powering the device. If I am going to have the Pi do the watering itself (instead of just notifying me when it's time to water), it needs to be connected to a relay which triggers a solenoid valve that allows water to flow for a certain amount of time.

If I want to run such a system in a part of my yard which is difficult to power (expect by running an extension cord the length of my lawn), are there feasible and relatively inexpensive solar panel solutions that would power a Pi Zero W performing such an application indefinitely? From my testing, there is a decent 2.4GHz wifi signal in all of the garden locations that I would like watered, so internet connection is not a problem.

Regardless of if solar power is feasible (I could limit my efforts to the locations for which wired power is doable), does using a relay to send power to a solenoid valve sound like the best way to do the actual watering?

Note: I currently have a Pi 4B which could be used as a central controller device, and I was imagining several Pi Zero W's, one for each area I would like to be watered.

  • 2
    The Pi is irrelevant to the question. It could be any device which requires power.
    – joan
    Jun 19, 2021 at 16:19
  • 1
    I asked this on the Raspberry Pi community because I would think that there are solar power methods which are particularly suited to the form factor and power consumption of the Pi Zero W. Jun 19, 2021 at 16:35
  • 1
    this may help ... opensprinkler.com
    – jsotola
    Jun 19, 2021 at 16:47

1 Answer 1


I've done something similar & offer a few comments below. As far as your question is concerned, the only question I actually see in your post is:

Q: does using a relay to send power to a solenoid valve sound like the best way to do the actual watering?

A: "Best" depends on a number of things, but a relay is certainly a reasonable way to switch power to drive your solenoid valve(s). Most solenoid valves will operate from either 12 VDC or 24 VDC, so you'll need either a relay or a transistor. Following are some considerations:

  1. A small (20W) solar panel and re-chargeable battery(ies) are feasible for a power source, but you they won't provide enough power to run your RPi 24x7. You'll need to either manually power down your system, or use a real-time-clock to turn it on and off.

  2. Most relays use a fair amount of power. If run times are extensive, you should consider using a latching relay.

  3. Solenoid valves vs motor-driven valves: Solenoid valves also use a fair amount of power. As an alternative, consider a motor-driven valve. There are some valves that are said to have clever design features and more efficient than traditional solenoid valves.

  4. Detection of soil moisture: There are a variety of wireless soil moisture sensors. I've opted out of these in favor of a fixed watering schedule that I can adjust manually when abnormal weather patterns persist.

Hope this helps - and good luck!

  • 1
    Thank you for sharing your experience. I will look into motor-driven valves and a RTC to turn on and off at desired times. Jun 20, 2021 at 19:02
  • 1
    @MaxChristman: I try to maintain a few "recipes" in this GitHub repo. I will eventually get around to posting some details on what I've done - actually a work in progress.
    – Seamus
    Jun 20, 2021 at 19:53
  • Ah, you don't use a motor to switch on/off a valve; you use a solenoid! (1) Solenoid Valve How To: raspberrypi.org/forums/…. Cheers.
    – tlfong01
    Jun 21, 2021 at 1:17
  • And you use a relay to control the solenoid valve: raspberrypi.org/forums/…
    – tlfong01
    Jun 21, 2021 at 1:22
  • And you might also need a water pump: raspberrypi.org/forums/…
    – tlfong01
    Jun 21, 2021 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.