Page 1 of 3

Automated Garden Sprinkler System

Posted: Wed Apr 15, 2020 3:17 pm
by Robbieduke16
Hello. I want to make a sprinkler system that detects an animal(cat/dog) on a camera feed, and when its caught on camera for a certain time window, lets say 5 seconds, the PI will send a signal to a solenoid valve to turn on the sprinklers. This is to hopefully make the animal evacuate the area without harming it. I am very unfamiliar with RPI but completely willing to learn.

My ideas so far:
Use openCV for analysis of camera feed and detection of animals.
Solenoid valve connected to water hose and sprinkler for water needs and battery bank for operation(maybe).

My questions:
Is this possible?
What kind interfaces would I need to use to connect the camera, Pi and solenoid valve?
What voltage should my solenoid valve be so it can be turned on by the pi?

Re: Automated Garden Sprinkler System

Posted: Wed Apr 15, 2020 4:00 pm
by scotty101
Definitely possible

MotionEyeOS can turn on a GPIO pin when motion is detected. (isn't clever enough to detect an animal rather than a human though)

https://github.com/ccrisan/motioneyeos/issues/1697

Regarding soleniods etc. 12v is common. This can be interfaced to a Pi but will require some circuitry to protect the Pi's GPIO pins from being exposed to voltages above 3.3v. A bipolar transistor/darlington pair or MOSFET would be a common solution. There are specifically designed relay boards that you could also use with the relay driving the voltage to the soleniod.

Re: Automated Garden Sprinkler System

Posted: Thu Apr 16, 2020 4:21 pm
by Robbieduke16
How would one go about upscaling the 3.3v coming out of the GPIO of the PI to 12v DC to switch on the valve? A 12v dc relay?

Re: Automated Garden Sprinkler System

Posted: Thu Apr 16, 2020 4:35 pm
by rpdom
The Pi can't drive a relay directly, but a relay board with a transistor driver on it would work. Or you could skip the relay part and use a suitable transistor to switch the valve directly.

Re: Automated Garden Sprinkler System

Posted: Thu Apr 16, 2020 6:52 pm
by windy54
Hi,

You can buy a 3V3 relay that the PI will control and the output will easily switch 12V look for part JQC3F-03VDC-C supplier BESTEP.

think I got them from ebay

Steve

Re: Automated Garden Sprinkler System

Posted: Thu Apr 16, 2020 7:16 pm
by pcmanbob
You can't power a relay directly from a gpio pin, even a 3V one will draw more than 16mA which is all a gpio pin can supply.

If you buy a relay with a 5V coil you can power it from the 5V gpio header pin using a transistor driver circuit to control it using a gpio pin.

Re: Automated Garden Sprinkler System

Posted: Thu Apr 16, 2020 10:34 pm
by Robbieduke16
Would any of these work? (Pictures attached)

Re: Automated Garden Sprinkler System

Posted: Fri Apr 17, 2020 8:48 am
by pcmanbob
The first one might but you would need to provide a 3V supply , as the pi on board 3.3V supply cant supply enough current to operate a relay.

All the other are 12V so you would need a separate 12V supply, to power the relay boards

Both the 12V ones would work if you used it as active low and had a transistor interface between the pi gpio and the relay control pins as you would be grounding a 12 volt control circuit.

Re: Automated Garden Sprinkler System

Posted: Fri Apr 17, 2020 2:05 pm
by Robbieduke16
This is for activating a dc motor with an arduino ehich i think cant power a 12v valve directly either. Would this work for my pi?

Re: Automated Garden Sprinkler System

Posted: Fri Apr 17, 2020 2:29 pm
by pcmanbob
To do it using a transistor you need to know what current you solenoid draws, then you can work out what transistor you need to use and what the circuit would look like.

Transistors for switching high currents will probably need heat sinks as well.

How many solenoid valves are you thinking of controlling ?

Re: Automated Garden Sprinkler System

Posted: Sun Apr 19, 2020 5:41 pm
by Robbieduke16
For now just 1 valve to make a proof of concept. This is the valve I got. Runs on 12v dc

Re: Automated Garden Sprinkler System

Posted: Sun Apr 19, 2020 6:08 pm
by pcmanbob
pcmanbob wrote:
Fri Apr 17, 2020 2:29 pm
To do it using a transistor you need to know what current you solenoid draws
Picture does not tell us the required information.

Re: Automated Garden Sprinkler System

Posted: Sun Apr 19, 2020 8:41 pm
by Robbieduke16
Oh yeah my bad. Sorry. Apparently its 33 watts. And according to the reviews doesnt work with dcv as it says. May need to buy a 12v dc or somehow use 120vac, but i dont know if that can even work. The amperage isnt stated at any point in the listing.

Re: Automated Garden Sprinkler System

Posted: Sun Apr 19, 2020 8:54 pm
by pcmanbob
Do you actually have this valve in your hands ?

If so what does the label on the top of the coil say.

Re: Automated Garden Sprinkler System

Posted: Mon Apr 20, 2020 12:47 am
by Robbieduke16
Not yet it should be arriving in a couple days. I will post a photo when it gets here. Btw tyvm for your help.

Re: Automated Garden Sprinkler System

Posted: Wed Apr 29, 2020 5:25 pm
by Robbieduke16
Sorry for being MIA the parts took a while to get here. This is the valve.

Re: Automated Garden Sprinkler System

Posted: Wed Apr 29, 2020 6:54 pm
by pcmanbob
It still does not give us a current rating so you have two options,

Power the coil and measure the current drawn

Measure the coil resistance and use ohm's law to calculate the current draw.

Once you know the current draw you can decide on which transistor to use.

Re: Automated Garden Sprinkler System

Posted: Wed Apr 29, 2020 9:24 pm
by Robbieduke16
My multimeter is busted apparently. I'll buy one tommorow at Home Depot. In the meantime i found this review which has some info on power consumption.

Re: Automated Garden Sprinkler System

Posted: Wed Apr 29, 2020 9:28 pm
by pcmanbob
I would be supprised if 6.7V would activate a 12V solenoid valve.

I would do your own tests on the valve you have.

Re: Automated Garden Sprinkler System

Posted: Sat May 02, 2020 4:40 pm
by Robbieduke16
Did the current test with this 12v wall adapter. Amperage was 2.7a, the resistance for the valve was 4.2ohms. Sorry I took so long this has been a learning experience for me. Its my first time doing anything like this.

Re: Automated Garden Sprinkler System

Posted: Sat May 02, 2020 6:15 pm
by pcmanbob
Well that power supply is under rated , you coil is drawing 2.7 -2.8A and the power supply can only supply 2.5A so it may overheat if use for any length of time and may fail rather quickly.

So you need a transistor that can carry 3A at 12V , if you choose one with those specifications you may well need a heat sink on it,

So to save that need you may be better choosing one with a higher current rating.

if you want some thing ready made that you can just connect to your pi and have screw terminals for the power supply and the valve coil wiring might I suggest this.

https://www.amazon.co.uk/DaoRier-IRF520 ... 020&sr=8-2

you will still need a heat sink on it but that's easy to add.

To @emma1997 - yes I am recommending a mosfet. :D

Re: Automated Garden Sprinkler System

Posted: Sat May 02, 2020 7:08 pm
by Robbieduke16
What if i went with a higher amp power supply? Could i use the relay that i have? I have the hiletgo 12v single relay in the picture attached a couple messages above.

Re: Automated Garden Sprinkler System

Posted: Sat May 02, 2020 7:33 pm
by pcmanbob
You need a bigger power supply anyway, it depends upon exactly which relay board you want to use.

There are three shown in other posts.

Re: Automated Garden Sprinkler System

Posted: Sat May 02, 2020 10:20 pm
by Robbieduke16
I have these 2 relays on hand

Re: Automated Garden Sprinkler System

Posted: Sun May 03, 2020 6:39 am
by pcmanbob
As nether of them appears to have an on board voltage regulator its possible that they use 12V on the control circuit as well as to power the relay coil.

So you need to test them and not with your pi, connect 12V to the DC+ and DC- terminals , set the jumpers to low, then with your meter set to volts and the 12V turned on connect the meter between IN1 and DC- , you should get a voltage reading.

this reading will determine if you can connect these relays directly to the pi gpio.