“Spaghetti” IP Cam / Arduino Motion Detect Sprinkler

arduino motion detect sprinkler

After a neighbourhood dog decided my front lawn was a fantastic place to poop on and his owners decided that they don’t care for bylaws I set upon finding a solution. Sure you could try cayenne pepper, mothballs, ammonia or even marking your own territory (take that!) but I already had an IP camera monitoring my front yard for security purposes, so I figured I’d just hook up an Arduino and a sprinkler valve. This yard defense solution has two added benefits, it keeps my lawn healthy (I can set up timed watering through this system) and it sends offending dogs home stinkin’ wet. From me having to shovel dookie off my lawn to negligent owners having to deal with wet dog — perfect.

When the IP camera detects motion in configured regions of its video stream (the rectangles in the screenshot) it triggers one of its General Purpose Input/Output ports (GPIO). The Arduino is listening for this GPIO signal and once its received the Arduino triggers a relay which connects a 24v power supply to the sprinkler solenoid valve. The valve opens when 24v is applied to it and “sprinkles” whatever was responsible for the motion.

The TRENDnet IP camera I employed works great as it already records video of events to network or attached storage, sends email alerts with snapshots and allows manual triggering of its GPIO.

The TRENDnet monitoring plugin only works in IE but after some reverse engineering and C# coding I had an easy to use web interface for all browsers and mobile devices.

If there’s enough interest I’ll post circuit and wiring diagrams. Ensure the valves you get are non-latching 24v solenoids, some 9v valves seem tempting but are magnetic and require a more complex circuit.

Why Spaghetti? Watch more ATHF.


Update: Some folks have asked why not just trigger the valve relay directly from the GPIO on the camera. This could’ve been done, but then I wouldn’t have gotten as much control as I wanted. This way I can configure timing to prevent the sprinkler itself from setting off the motion detector, set up timed watering as well as trigger other devices at various timings (DSLR for reaction shots). Another addition may be an XBee based remote control or hardwired buttons for various functions.

Update: I’ve added a quick circuit diagram and simple Arduino code.

Arduino Code

int gpioPin = 1;       			// GPIO input
int val = 0;           			// value read from GPIO input
int trigPin = 13;      			// solenoid relay output

void setup()
	pinMode(trigPin, OUTPUT);

void loop()
  val = analogRead(gpioPin);		// read the GPIO input pin
  if (val > 500)
	// GPIO triggered, open the valve
	digitalWrite(trigPin, HIGH);
	// GPIO off, close the valve
	digitalWrite(trigPin, LOW);
Leave a comment ?


  1. Motion sprinkler chases away defecating dogs - Hack a Day - pingback on June 18, 2012 at 6:02 pm
  2. MAKE | Motion-Activated Sprinkler - pingback on June 18, 2012 at 8:01 pm
  3. Motion-Activated Sprinkler | vis a vis | visual mind - pingback on June 18, 2012 at 8:19 pm
  4. Motion sprinkler chases away defecating dogs | Hacking Academy - pingback on June 18, 2012 at 10:49 pm
  5. Motion-Activated Sprinkler | Price Gadget Reviews - pingback on June 19, 2012 at 4:16 am
  6. Motion-Activated Sprinkler - pingback on June 19, 2012 at 4:25 am
  7. Great work! Would it be possible getting circuit/wiring diagrams?
    Cheers and good luck with your future projects!

  8. Arduino motion detect sprinkler | Arduino Passion - pingback on June 19, 2012 at 12:59 pm
  9. INTERESTING STUFF | Pearltrees - pingback on June 19, 2012 at 1:36 pm
  10. Second request for the diagrams here! Just getting started with home projects and this would be the perfect thing to work towards. My goal is to stop the neighbourhood cats from leaving ‘gifts’ in the veg garden.

  11. » Arduino powered auto sprinkler Fuzzy Hypothesis Online - pingback on June 20, 2012 at 12:35 pm
  12. check me - trackback on June 21, 2012 at 1:23 pm
  13. Motion-Activated Sprinkler | Indoor Digital Billboards - pingback on June 25, 2012 at 5:36 pm
  14. Arduino motion detect sprinkler -- Arduino Passion - pingback on July 9, 2012 at 2:38 am
  15. Which model of Trendnet camera did you use?

  16. Cool idea and good effort! I was wondering if you would share the “reverse engineering” work you’ve done to get the IP cam to work on other browsers (other than IE).. Thnks in advance!!

  17. Motion sprinkler chases away defecating dogs » Geko Geek - pingback on September 12, 2012 at 11:30 am
  18. Where did you get that vintage intercom, and did you build the enclosure yourself?

    • I got the intercom from a well known electronic/junk/misc store called Active Surplus in Toronto.

      • Did you buy it that way with the wood enclosure?

        • I added the LEDs, a switch and some power adapter jacks, other than that the intercom is as I purchased it. It’s not real wood, it’s a fake veneer over chipboard I believe.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks and Pingbacks: