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.
you want a pulldown resistor on the gate and a series resistor from the logic out to the gate. 150ohms for the series, 10k for the pulldown (typ values).
And a freewheeling diode across the relay coil wouldn’t hurt, either.
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.
Make the series-resistor something like 1-10k though. It’s just a MOSFET, and even a BJT would be happy with those values ;)
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 ;)
The diode should go across the relay, not the mosfet
No, you do need that that diode in the mosfet is not where it is needed for the relay to quash that collapsing spike.
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.
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.
Yeah, that bugged me, too. It is simpler in a way and it’s a good placeholder while you consider how to best sense the soil moisture.
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.
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.
With a web service you might have to deal with it at some point. With a moisture sensor you WILL have to deal with it every year or so.
I would suggest detecting the rain. Soil probes piss me off.
I hate people who complain about “it could have been simpler” here. But yeah, this is pretty much the opposite of KISS.
That said, there are other potential uses for a weather-aware iot device.
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. :-)
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.
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).
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.
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.
Is there any soap in that sand box? ????
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.
Isn’t a moisture sensor just two pieces of metal stuck in the ground that will only work a little while before oxidation makes them useless?
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.
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.
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.