K.I.S.S. Pi Sprinkler – Just Keep The Plants Alive

A good first step in a project is knowing what you want to do. [Ben Fino] made it clear that his Raspberry Pi Sprinkler control system for his wife’s garden had one goal: keep the plants alive. The resulting project is doing just that and no more.

The circuitry, and plumbing, is straightforward and explained well in the Instructable. All the electronics consists of is the Pi and a MOSFET to take the 3.3v GPIO to 5v to control a relay. The valve controlling the water requires 28v AC which necessitated the relay to control it. There are also three LEDs: one is for power, one to indicate when the valve is opened, and one is an extra for some future purpose.

The intriguing part is the use of weather data from the web to determine if it’s rained recently. Python scripts provided by [Ben’s] friend [Mark Veillette] use a weather site API to get the rainfall data. The main script is set to run once every 24 hours. [Ben] set his system to water unless the previous day had sufficient rain. How much rain and the number of look-back days is programmable.

What a great application of the KISS principle: keep it simple, stupid – except for that third LED without a purpose.

27 thoughts on “K.I.S.S. Pi Sprinkler – Just Keep The Plants Alive

      1. The MOSFET he’s using has a built-in diode, so no need for that.
        Regarding the resistors, while not strictly necessary it probably would be a good idea. The pull-down would prevent accidental turn on (i.e. due to a loose wire), and the series-resistor would prevent the Pi from bricking itself in case of shorts.

          1. I’m used to seeing logic mosfets used here and with a small but still present series gate R. you want the mosfet to fully ‘slam’ and so I’d go closer to the 100ohms level than 1k.

            for a 2n2222 npn, its not the same thing and a 1k is the standard series base resistor.

            ymmv, of course ;)

        1. Still need the diode across the relay coil.

          When the FET opens, the relay coil end near the mosfet will reverse its voltage in order to keep the current going in the same direction. The current can’t go through the diode of the MOSFET.

          The series resistor for the gate of a MOSFET is to limit the current into the gate capacitance of the MOSFET, in this case.

  1. The very notion that downloading weather data from somewhere on the web is in keeping with the “KISS” principle baffles me. Especially where you have immediate and direct access to just sensing the moisture in the ground. If the site hosting the information you want changes its data format, you have to reprogram. If the site changes its name, you have to reprogram. If the site simply disappears, you have to redesign. If your Internet connection becomes unavailable or anything prevents your getting the information, you have to have a fallback position. This is designed with many ways to break.

      1. A good point. For someone whose training and experience are mostly in software, it’s a piece of cake to get the weather history information online, while putting together a reliable moisture sensor could be a challenge. Simple isn’t necessarily easy.

        1. but we all know how ‘stable’ (cough cough) web services are these days.

          whereas, sensing moisture in the ground is something YOU control and some webserver that suddenly changes on you won’t ruin your approach.

          if possible, have both; but I would never want to rely on a net connection or some screen scraped data, even if I was paying for the service. web stuff just does not have long term staying power; we all have seen services go away, so its not really a dependable thing.

    1. When it comes to weather, your choices are to build your own weather detector, or use someone else’s. Commercial rain sensors are available for sprinkler systems, but you pay more than the RasPi for those. You can build your own soil moisture sensors out of a couple bits of wire, but tuning and maintaining them could be a problem. You could buy a weather station, which will cost far more than a couple of RasPis. Or you can use the existing network connection and the WeatherUnderground API, which has been stable for many years, and is freely available. It’s not the worst decision he made on this project (forgetting the flyback diode was the worst. :-)

      1. In addition to the flyback diode, I’ve received conflicting advice about whether I need an RC snubber in parallel with the solenoid valve. I’m a mech E by training and don’t have a formal electronics background. If anyone here wants to cast a vote either way on the RC snubber, feedback is appreciated.

    2. Hi Jim – as I said in the Instructable, most of what I’ve read about soil moisture sensors made it sound like ultimately they’re more work because they corrode over time and require re-calibration. I’ve never actually used one though, so I could be wrong. I guess it’s a matter of choice as to whether you consider that more of a pain than making sure your weather API is still working.

      (Note that I didn’t make any claims about this following the “KISS” model in the Instructable, so I’ll leave that argument between you and Rud).

      1. The sensor reliability is dependent on soil chemistry, and the V and I applied to the sensor.Designed a green house monitor/control system for a large California grower. For some sites, the sensors get flakey after 6 to 10 months; most sites seem to be on an 18-20 month replacement schedule.Cost amortized via volume – had 2100 sensor assemblies made.

      2. KISS is in the eye of the beholder. I dubbed in KISS because it does what you wanted it to do and no more. No function creep. It is a project that got done, not delayed to add just one more feature or function.

        Another point, getting on a sandbox, is to present here some projects that are simple so someone just starting out can mimic the project to accomplish something. A small first step to encourage them on the long journey of being a hacker.

        1. No soapbox necessary – especially with no real Linux experience, I’m all about beginner-friendly RPi tutorials.

          For the record the idea with that third LED – to BrightBlueJim’s point – was to use it as some sort of status indicator that either the weather API or the cron scheduler are still working. Basically, I wanted to be able to glance at the RPi from indoors at any time of day and know “Is this thing still running?”, without having to ssh/VNC into the Pi to check the log rile or test-run the Python script, or wait until the right time of day to see if I hear the relay click. But, speaking of feature creep…we didn’t get around to it.

      1. I haven’t used one myself so I don’t know how long they last, but from what I’ve seen, they use stainless steel probes to reduce the corrosion problem.

  2. Soil moisture monitoring only tells a fraction of the information. He wants to know, if if the ground is dry but it’s going to rain 2″ starting in a couple hours he could probably hold off watering the plants.

    1. I thought of that but I think the Weather Underground API only gives rainfall *history* and not rainfall *forecast*. I could be wrong on that though – even if it doesn’t give rainfall forecast in inches, if it does “chance of precipitation” as a percentage then it would be easy to just skip watering if the chance is over 70% or whatever.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.