Create your own iPhone controlled and motion activated water gun with pan tilt aiming, video feed and fast burst camera!
This guide will illustrate how to build it, where to buy the parts and the code is provided. The Super Squirter can be used with the optional iPhone App (low low price of 99B) where it can be sighted, aimed, adjusted and triggered all while receiving the video feed to the screen. Whats more the App can connect to the Super Squirter from anywhere in the world.
The App is optional, the Super Squirter still works without it, when motion is detected the Super Squirter will fire and the Camera will save a series of fast burst shots to the SD Card. Also the SD card can be accessed using a browser so you can view, download or delete the images online.
These are the highlights
- An ESPino is used to control the pan tilt arm, detect motion via a PIR Motion Sensor, turn the pump on using a transistor as a switch and trigger the camera on the Arducam UNO.
- An ESP8266 ESP-12F UNO Board for ArduCAM Mini Camera and the Arducam Mini module Camera Shield w/ 2 MP OV2640 is used for the video feed to the iPhone App and as a fast burst camera to save images to the SD Card.
- A HC-SR501 PIR Motion Detector is used to trigger the pump, pan tilt action and the camera burst to SD Card.Communication between the ESPino and Arducam UNO and the iPhone App is done using HTTP.
- An SD Card in the Arducam UNO is used to save images and to serve a htm file so that the saved images can be accessed via browser.
- A home made Vacuum Relief Valve is used to prevent water siphoning from the reservoir through the pump when not on.
- A 12v 3A Windscreen Washer Pump is used.Two 6v 7Ah Sealed Lead Acid Batteries are connected in series to provide 12v for the pump.
- Router configuration including LAN Static IP's and NAT Port Forwarding along with a DDNS or a Static IP is required.
- A TIP120 NPN Transistor is used to switch the pump on and off and the calculation is covered briefly, a 1N4001 Diode is used for flyback protection .
All the code is provided, most of it comes directly from the Arducam and ESP8266 Github repositories.
Next steps and improvements
- Night Vision with IR LED's and no cut out filter.
- Adjust movement parameters through iPhone App.
Step 1: Action
Motion detector testing and App screenshots.
Step 2: Components List
1. I used an ESPino because it is available locally and is ready to plug into a breadboard and comes with a micro USB (comms and power). You could just buy the ESP8266 module but you would have to mount it on a breakout board and use an FTDI for comms and power or use another equivalent.
2. I used the ESP8266 ESP-12F UNO Board for ArduCAM Mini Camera and the Arducam Mini module Camera Shield w/ 2 MP OV2640 because I had them but if you need to buy one I would go for the Arducam 2MP V2 Mini Camera Shield with ESP8266 Nano instead, it's way smaller and you don't have to mount the Uno board or worry about the extra wires. It also fits in the pan tilt arm, just a lot neater.
The major components came from UCTronics and Thai Easy Elec
Other bits and pieces
- M3 PCB Standoffs
- Clear Acrylic Case
- Two 6v 7Ah SLA Batteries
- TIP120 NPN
- Water Bottle
- Assortment of jumpers and wires etc
- Diode 1N4001
- 12v to 5v DC-DC Convertor
- 12v Windscreen Washer Pump
- Vacuum relief valve if your nozzle sits lower than the water level
- Two Micro USB Cables (power form convertor to boards)
Step 3: Network
If you would like to access the Super Squirter from the internet or WAN side of your router, either using the iPhone App or otherwise take control of it (you could write a Python script or otherwise construct the URL's to mimic the App) you will need to do configure your router.
Typically Internet Service Providers (ISP's) have a pool of public IP addresses that are cycled through so you could find that your public IP changes every couple of days. If you are willing to lookup your public IP and update it in the App then you don't have to worry about a DDNS or Static IP. But if you just want to set and forget you can setup of DDNS service or a static public IP.
Then internally it needs to be set up so that any traffic from the internet is routed to the correct device, that is, assign static internal/private IP's to both the Arducam Uno and Espino (the LAN part) and direct traffic on the assigned ports to the assigned IP's (the NAT part).
For example in your router you set the IP address of the Arducam Uno to 192.168.1.21 and then in the .ino file you set the webserver on port 82 (ESP8266WebServer server(82)), you then setup NAT to forward any traffic on port 82 to 192.168.1.21.
1. I have used https://www.dynu.com and they are great for a free DDNS service. Or contact your ISP and request a static public IP, they normally charge for that. If you just want to set it up to work with the PIR Motion Detector and have it save images to the SD Card when activated then skip this step.
2. Get the MAC address from both the Espino and Arducam Uno. You can set the SSID and Password in the .ino's, let them connect and then through your routers advanced settings pages you can find the MACs
3. Configure your router to assign static IP's to the Espino and Arducam Uno, use the MAC addresses to create Static IP entries in the LAN setup page.
4. Configure your router to NAT port forward to your Arducam Uno and Espino so they can be accessed from the internet using your router's ISP assigned public IP address. The Arducam Uno and Espino connected to your private network will have internal IP addresses that are not visible from the internet. As above, the Arducam Uno is listening on port 82 and the Espino on port 81 (see this line in the respective ino files - ESP8266WebServer server(##). On the NAT setup page create entries so that traffic on the assigned ports is routed to the correct static IP's
If you only want to run it using the motion detector or just use the App when your phone is connected to your home network then just skip the DDNS / Static Public IP steps above.
Step 4: Assembly
This is what my case looks like, this is just the first pass and all so lets call it Revision 0. The next build will be smaller and neater but anyways I mounted the boards and regulator to the lid to allow easy access and drilled a few holes for wiring. If using the Arducam Mini module the case could be half the size and there wouldn't be all the wires feeding up to the camera.
I used a soldering iron to make the hole in the water bottle for the pump grommet hence the mess of glue, next time I'll go and buy a drill bit to suit. As indicated above if the outlet or nozzle is positioned higher than the water bottle you don't have to worry about water siphoning through the pump when it's not running so no need for the vacuum relief valve.
It's also worth noting that when using the SD Card slot there are no spare GPIO pins on the Arducam Uno which is why you don't see any connections to it. So we use a HTTP_GET in the espino.ino to message the Arducam Uno to start taking images when motion is detected.
This is one way to layout the breadboard, if you spin the Espino 180 degrees you can layout the board with no crossed wires. The size of the case, the fact I used the Arducam Uno and the length and stiffness of the micro usb cable I had kind of dictated this layout.
I used micro USB cables to connect the 5V from the convertor to the boards, so only the black (GND) and red (+5V) are used and I just cut the green and white wires back.
Step 5: Electronic Switch (Transistor)
The pump runs at 12v and when under load (pumping water) and it draws 3A.
Looking at the TIP120 data sheet the max collector current (Ic) is 5 amps and the max collector-emitter voltage is 60v. So far so good.
Looking at figure 2 on the datasheet the base current (Ib) is given by Ic=250* Ib or Ib=Ic/250 so a collector current of 3.0 amps requires Ib=3.0/250 which equals 0.012A. From the ESPino-Datasheet-EN-2 the max current per I/O pin is about 12mA.
You could add a small resistor to make sure the Espino doens't try to output more than the 12mA, so looking at figure 2 we can see that when the collector current is 3A then Vbe(sat) is 1.8V. So when the Espino is high at ~3.3V the resistor should have a voltage drop of 3.3-1.8 = 1.5V accross it;
So you could add a 100 or 150 ohm resistor if you like.
Step 6: Code
espino.ino and arducam_uno.ino
The .htm file for the Arducam Uno SD Card is from here https://github.com/esp8266/Arduino/tree/master/li...
Step 7: Notes and References
I made a vacuum relief valve to prevent siphoning through the pump when it's not running or alternatively place the nozzle above the water bottle.
Here is a link to a video which demonstrates how to make a vacuum relief valve, no English but easy enough to follow.