Havahart traps are really nice if you have pests to rid your home of but you don’t feel the need to do this through means of killing the animal.
The problem we are faced with is constant monitoring of the trap. If you forget to check back frequently (usually at least once a day), you risk having the animal dying in the cage simply due to shock or anxiety. As a result, you end up being more cruel to the animal than if you had just put it out of it’s misery to begin with.
It is this problem that spawned my “Critter Twitter Trap”. The goal is to be notified as soon as the trap is "sprung", thus we know when to check it. I'm a lazy engineer looking for creative solutions so I can do less work. ;)
I will show you how to make a simple modification to a common pest trap which will send a twitter message when the trap has been sprung. You can see what happens when the trap is sprung by viewing my Critter Trap twitter account here. Most of these posts were tests, but a few were live catches! I then setup my personal twitter account to monitor new tweets from the Critter Trap account and send me a text message if anything new is posted.
This is a very simple solution requiring minimal hardware and electronics aside from a few key components. Most of the work is in the code which I will provide in this Instructable.
Interested? Read on...
Step 1: Gather the Materials
- Havahart 1025 Two-Door 18 x 5 x 5-Inch Cage Trap or similar (Amazon)
- Arduino Yún microcontroller board (Amazon)
- Tilt Switch (See notes below)
- 9V Battery
- 9V Battery Connector (Amazon)
- Stiff scrap metal or angel bracket (for tilt switch mounting)
- LM7805 Voltage Regulator (Amazon)
- 2 10uF Capacitors (Amazon)
- 1 .01uF Capacitor (Amazon)
- As you can see from the pictures, I am using a mercury tilt switch simply because it is what I had on hand. You can find many variations of this on Amazon and from other sources.
- If your particular trap has a vertical sliding door, I would recommend a magnetic switch such as this.
- You will see that I link to "bulk pack" deals on Amazon for items such as the capacitors and voltage regulars. These are very common items for electronics projects and you're only paying about 3x the amount you would pay at RadioShack for one item. This way you can get 100 capacitors for about 3x the price as ONE.
Step 2: Attach Tilt Switch
The method in which you do this is really up to you, and depends greatly on the type of trap you have and the type of of tilt switch you get. The key is to make sure the switch is in the off position while the trap is "loaded" as seen in the pictures.
Here I used a old scrap L bracket and attached it to the trap. I then used a Dremel tool to cut an oval hole in the bracket. Then I simply used hot glue to secure the switch in place. Very simple assembly!
Step 3: Arduino Yún WiFi Configuration
These detailed step-by-step instructions are for those of you just getting started with a brand new Yún. If you already have a Yún connected to your local WiFi and running, please proceed to the next step OR reset your Yún as follows.
Reset Your Yún
If you want to follow along and reset your Yún to its default state, press the WLAN reset button (shown in picture) for at least 30 seconds (the board must have power through USB or external source). The onboard blue WAN LED should flash consistently during this process. When done, the board reverts to the original settings as if it had been re-flashed or taken out of the box. Among other things, this removes all installed files and network settings.
- Power up your Arduino Yún
- Connect your PC (or mobile device) to the WiFi that will be broadcasting from the Yún. (will look something like: Arduino Yun-90383747IUADA)
- From that PC, pull up http://arduino.local
- Default password is 'arduino'
- Scroll down to the "Timezone" drop-down and set to your appropriate zone.
- Set your Timezone
- Scroll down to "Detected Wireless Networks" and select your local WiFi network
- Enter password for your local network
- Click the large "Configure & Restart" button
- After a couple minutes, the Yún should reboot and connect to your local network. The admin interface will provide a link saying "Restarted! You'll find me here".
- You may need to wait longer than the interface tells you to connect.
- Re-connect your PC (or mobile device) back to your normal WiFi network
- Test by attempting to access http://arduino.local. You should see a screen similar to the one shown (on my mobile device, but could just as easily do from a PC).
- If you can't connect, start over again with the getting started steps.
Step 4: Make It Tweet!
Arduino has partnered with Temboo to make connecting to your favorite services as easy as possible. Temboo provides normalized access to 100+ APIs from a single point of contact allowing you to mix and match data coming from multiple platforms (for example Twitter, Facebook, Foursquare but even FedEx or PayPal).
Having done this with other microcontrollers (including other versions of Arduino such as UNO), I can confirm that this method is SUPER EASY due to the integration Arduino has with Temboo.
For this project we will be interfacing with Twitter, where we will send all of our alerts.
You'll need the following to get going:
- A Temboo account (it is free)
- A twitter account where you want to post to
- Register your application using the Twitter dev console
- A sample sketch to test it all out
Temboo provides excellent instructions for doing steps 1 - 4 above. Rather than re-write what has already been done, I will simply refer you to their page here: https://www.temboo.com/arduino/yun/tweet
After you have been able to successfully send a tweet using their sample code, proceed on with the next step.
If you have any questions or get hung up on this step, please feel free to ask for help!
Step 5: Wire It Up
As mentioned on the Arduino Yún Schematic page, you must must supply a regulated 5VDC if you are powering the board though the Vin pin. Unlike other Arduino boards, there is no on-board voltage regulator for higher voltages, which will damage the board.
No need to worry though. A very simple circuit can be made to accomplish this. The attached photo provides all the details of the entire circuit, including the tilt switch used by the trap.
The capacitors are used to provide a smooth and reliable 5VDC power source for the Arduino. This is not my circuit design, but I can confirm that it works extremely well with the Yún running on a 9V battery.
The beauty of this simple design is that the circuit is never complete until the trap is sprung. Because of this, the battery will last a VERY long time!
As you can see from the photos, I chose to make a simple DIY shield to wire everything up. This is certainly not necessary for such a simple circuit but it does make everything cleaner. I also used a simple two pin header for the connection to the trap switch. This way I can easily disconnect the Arduino as needed without having to unplug the whole shield.
It is best to start with a new 9V battery when setting your trap. If the trap is sprung and it is left more than a couple hours, you may need to replace the battery before it is set again. When there is not enough voltage, the Yún will not operate properly so always test it again after re-setting the trap.
Step 6: Code It
The code is pretty straight forward for this project. It can all be found on my GitHub account here: https://github.com/siliconghost/TwitterCritterTrap
There are two files that make up the project. One is called TwitterCritterYun.ino, and the other is TwitterCritterAcctInfo.h.
TwitterCritterAcctInfo.h is where you put all your personal account info for Temboo and Twitter. It is kept separate and added as a include file just in case you ever want to share your code and not worry about sharing all your account credentials.
TwitterCritterYun.ino does most of the work. Twitter does not allow multiple posts of the same message over and over again, so I have the message strings randomized, adding a bit of humor to the post for your followers. These sayings were taken from a popular video game that my son and I like to play. They seemed appropriate for a critter trap.
If the trap can't send a tweet on the first try, it will keep trying over and over again until it is successful.
The code is commented pretty well and should be self explanatory. I tried to add it here but the formatting was pretty bad so I left it on GitHub instead.
Please let me know if you have any questions or any trouble accessing the code.
Step 7: Set It and Forget It
Firmly attach the battery and Arduino to your cage.
Make sure your wiring is long enough to reach from the switch to the Arduino as shown in the picture. Ideally you should secure the Arduino to your trap.
Now comes the fun part. You set the trap with a decent bait that won't rot quickly and basically forget about it until you get that text message saying you caught something! I have to admit, the first time I caught a chipmunk in my garage with this I was overjoyed like a little kid in a candy store because I had proven that my little invention works and was actually quite handy!
A few words of warning:
- Make sure you test your trap in the exact location that it will be set. This helps ensure that your WiFi range will be acceptable, and you won't end up missing a notification that it tries to send but can't.
- Although I say "set it and forget it", it still might be a good idea to check the trap when you have time. You never know if something might have gone wrong with your code, the WiFi signal changed for some odd reason, etc.
- IMPORTANT - Be sure to check your local laws regarding trapping of animals. Use at your own risk.
Step 8: Making It Better
This current version requires you to be within distance of a WiFi connection in order to work. This is fine for a garage or outside near the house, but what if you need to trap somewhere that WiFi is not available?
One solution would be to use a GSM shield. This would allow your Arduino to communicate anywhere you can receive a cell signal. GSM shields can be found on Amazon here.
This application might be very handy for someone that needs to trap animals for study or testing. A trap could be left out in the woods and it would send you a text message when it is sprung! Just build a water-proof housing and you are ready to go.
The beauty of my simple design is that the same method would work for either WiFi or GSM.
Another enhancement would be to add a webcam to send a picture along with the notification. This really wouldn't be that hard and may be something I add in the near future.
Note: I entered this Instructable in the Epilog Challenge because I think it shows my skills and creativity. Sometimes the coolest ideas are not necessarily the most complex ;) If I were to win a Epilog laser my projects would only get more creative by adding nicely cut housings and materials.
First Prize in the
Outdoor Workshop Contest
Participated in the
Battery Powered Contest
Participated in the
Great Outdoors Contest
Participated in the
Epilog Challenge VI
caine2003 made it!