Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Automated Garden Sprinkler System

Wed Apr 15, 2020 3:17 pm

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?

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Automated Garden Sprinkler System

Wed Apr 15, 2020 4:00 pm

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.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Thu Apr 16, 2020 4:21 pm

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?

User avatar
rpdom
Posts: 17029
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Automated Garden Sprinkler System

Thu Apr 16, 2020 4:35 pm

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.
Unreadable squiggle

windy54
Posts: 86
Joined: Sat Dec 29, 2012 3:37 pm

Re: Automated Garden Sprinkler System

Thu Apr 16, 2020 6:52 pm

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

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Thu Apr 16, 2020 7:16 pm

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Thu Apr 16, 2020 10:34 pm

Would any of these work? (Pictures attached)
Attachments
IMG-20200416-WA0006.jpg
IMG-20200416-WA0006.jpg (196.4 KiB) Viewed 1011 times
IMG-20200416-WA0004.jpg
IMG-20200416-WA0004.jpg (123.06 KiB) Viewed 1011 times
IMG-20200416-WA0003.jpg
IMG-20200416-WA0003.jpg (162.62 KiB) Viewed 1011 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Fri Apr 17, 2020 8:48 am

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Fri Apr 17, 2020 2:05 pm

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?
Attachments
IMG-20200417-WA0001.jpg
IMG-20200417-WA0001.jpg (40.41 KiB) Viewed 973 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Fri Apr 17, 2020 2:29 pm

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 ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Sun Apr 19, 2020 5:41 pm

For now just 1 valve to make a proof of concept. This is the valve I got. Runs on 12v dc
Attachments
IMG-20200419-WA0001.jpg
IMG-20200419-WA0001.jpg (58.21 KiB) Viewed 884 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Sun Apr 19, 2020 6:08 pm

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Sun Apr 19, 2020 8:41 pm

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.
Attachments
IMG-20200419-WA0003.jpg
IMG-20200419-WA0003.jpg (25.85 KiB) Viewed 861 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Sun Apr 19, 2020 8:54 pm

Do you actually have this valve in your hands ?

If so what does the label on the top of the coil say.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Mon Apr 20, 2020 12:47 am

Not yet it should be arriving in a couple days. I will post a photo when it gets here. Btw tyvm for your help.

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Wed Apr 29, 2020 5:25 pm

Sorry for being MIA the parts took a while to get here. This is the valve.
Attachments
20200429_132103_compress81.jpg
20200429_132103_compress81.jpg (151.54 KiB) Viewed 771 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Wed Apr 29, 2020 6:54 pm

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Wed Apr 29, 2020 9:24 pm

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.
Attachments
20200429_171839_compress67.jpg
Will this work?
20200429_171839_compress67.jpg (116.29 KiB) Viewed 749 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Wed Apr 29, 2020 9:28 pm

I would be supprised if 6.7V would activate a 12V solenoid valve.

I would do your own tests on the valve you have.
Last edited by pcmanbob on Sat May 02, 2020 5:29 pm, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Sat May 02, 2020 4:40 pm

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.
Attachments
20200502_122329_compress83.jpg
20200502_122329_compress83.jpg (122.75 KiB) Viewed 576 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Sat May 02, 2020 6:15 pm

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
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Sat May 02, 2020 7:08 pm

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.

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Sat May 02, 2020 7:33 pm

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Robbieduke16
Posts: 32
Joined: Wed Apr 15, 2020 3:05 pm

Re: Automated Garden Sprinkler System

Sat May 02, 2020 10:20 pm

I have these 2 relays on hand
Attachments
20200502_181852_compress5.jpg
20200502_181852_compress5.jpg (99.56 KiB) Viewed 521 times

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Automated Garden Sprinkler System

Sun May 03, 2020 6:39 am

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Automation, sensing and robotics”