loading

Ralph Waldo Emerson once said "build a better mousetrap, and the world will beat a path to your door." Perhaps that’s what motivated Tom to keep trying to catch Jerry using ever more elaborate Rube Goldberg-esq traps that ultimately failed. Few things can be said to be inspired by both Ralph Waldo Emerson and the Tom & Jerry cartoon, but the better mousetrap is one of them. With a smattering of technology and peanut butter, we can make that better mousetrap a reality.






With winter fast upon us, I’ve already been victim to the annual rodent indoor migration. I happened across one of them in the basement while looking for something. Scared the crap out of me. Instead of waiting for signs of mice, I thought it might be a good idea to set up a semi-permanent trap.


Just because we don’t like having Mrs. Frisby in our house doesn’t mean we have to use a death trap. I wanted to build a trap that doesn’t kill. Imagine a semi-permanent trap that’s set out in basement, garage, or attic. I don’t want to have to go to the basement or attic to check the trap everyday. And I don’t want the little critters to die of starvation while they’re detained. So I need the trap to notify me via email the moment a mouse is captured. Since the traps are also located in dark places, I also want an LED as an easy line-of-sight indicator.


Interesting thing about mice is that they’re territorial. If you have a couple of mice in close quarters with no where to go, things might deteriorate into a battle royale. Could get pretty nasty, and defeats the goal of a humane trap. The best solution for catching multiple mice is to have more than one trap, and make each trap only let in a single mouse.


With those things in mind, these are my design goals for making a real smart mousetrap.

1) Easy to build, escape proof, live and let live
2) Notifies me the moment a mouse is caught, via email and audible notification
3) Trap only lets in one mouse at a time
4) Simple LED indicator to tell you if there's a mouse in the trap



First the video demo, then the steps for the build.


See next step for parts list.

Step 1: Parts List & Wiring

Parts List:

1. Spark Core ($39) or the Photon shipping in 2015 ($19)

2. Bucket ($5)

3. Large piece of cardboard

4. PIR Motion Sensor ($3, cheaper on ebay)

5. DHT11 Tempearture/Humidity Sensor ($2, cheaper on ebay)

6. Hobby Servo ($3)

7. Pieces of plastic or sheet metal, whatever you have laying around.

8. Resistors, 220 Ohm and 10k Ohm

9. Dupont male-female cables



Wire up the Spark Core breadboard circuit following this wiring diagram. Click to enlarge.



Your circuit should look something like this.

I included a temperature sensor in the circuit because they're so inexpensive.

any ideas? am I doing something wrong in the idea with pasting the code?
<p>this is what the IDE is saying. </p><pre>In file included from ../hal/src/stm32f2xx/platform_headers.h:19:0,<br> from ./inc/application.h:32,<br> from mousetrap.cpp:2:<br>../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:80: warning: 'externally_visible' attribute ignored [-Wattributes]<br> #define retained __attribute__((externally_visible, section(&quot;.retained_user&quot;)))<br> ^<br>mousetrap.cpp:312:86: note: in expansion of macro 'retained'<br> }<br> ^<br></pre><pre>../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:80: error: section attribute not allowed for '&lt;anonymous&gt;'<br> #define retained __attribute__((externally_visible, section(&quot;.retained_user&quot;)))<br> ^</pre><pre>mousetrap.cpp:312:86: note: in expansion of macro 'retained'<br> }<br> ^<br>mousetrap.cpp: In member function 'bool PubSubClient::publish(char*, uint8_t*, unsigned int, bool)':<br></pre><pre>../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:19: error: expected primary-expression before '__attribute__'<br> #define retained __attribute__((externally_visible, section(&quot;.retained_user&quot;)))<br> ^</pre><pre>mousetrap.cpp:322:11: note: in expansion of macro 'retained'<br> length = writeString(topic,buffer,length);<br> ^<br></pre><pre>../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:19: error: expected ')' before '__attribute__'<br> #define retained __attribute__((externally_visible, section(&quot;.retained_user&quot;)))<br> ^</pre><pre>mousetrap.cpp:322:11: note: in expansion of macro 'retained'<br> length = writeString(topic,buffer,length);<br> ^<br>mousetrap.cpp: In function 'void callback(char*, byte*, unsigned int)':<br>mousetrap.cpp:476:10: warning: unused variable 'buff_topic' [-Wunused-variable]<br> DHT mydht(2, DHT11);<br> ^<br>mousetrap.cpp:477:10: warning: unused variable 'buff_message' [-Wunused-variable]<br> <br> ^<br>mousetrap.cpp:484:10: warning: unused variable 'msg' [-Wunused-variable]<br> <br> ^<br>mousetrap.cpp: In function 'void loop()':<br>mousetrap.cpp:612:11: warning: unused variable 'h' [-Wunused-variable]<br> <br> ^<br>mousetrap.cpp:614:10: warning: unused variable 'debug_value' [-Wunused-variable]<br> //send temperature regularly<br> ^<br>make[1]: *** [../build/target/user/platform-6mousetrap.o] Error 1<br>make: *** [user] Error 2<br></pre><p>Ready.</p>
<p>thanks so much for this post. </p><p>I am trying to get it to work. </p><p>could you please help me out. I am new to particle ide. </p><p>I get this error when I try to load your sketch to the proton </p><p>../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:80: error: section attribute not allowed for ''<br> #define retained __attribute__((externally_visible, section(&quot;.retained_user&quot;)))</p><p>thanks so much for you help. I know this must be simple. </p><p><br></p>
<p>I'm not familiar with that error. What's the line in your code throwing that error?</p>
<p>We are making good progress on our project (which is derived from this project). One issue we have is with the SPARK Core power on self-test. It seems to test the pins during startup. We have a relay connected to the pins and the startup fires the relay. This is not good since the relay actually does stuff in the real world we want to only do under program control. Can we tell the SPARK not to do some of the self-test diagnostics it regularly does?</p>
<p>A friend and I are trying to build this. We are having trouble getting OPENHAB to see the messages sent (published) to MQTT by the SPARC. So we think it may be something in the OPENHAB config. OPENHAB does see MQTT. But does not seem to see the SPARC messages. We added the SITEMAP keyword to the SITEMAP file, we the website now works. When we move the switches on the website, stuff shows up in the OPENHAB log. MQTT log is going to syslog and we can see it running. Is the only thing in the OPENHAB config, the email info?</p><p>thanks in advance,</p><p>Kriss</p>
<p>It's probably your openhab configuration. Check out this wiki:</p><p><a href="https://github.com/openhab/openhab/wiki/MQTT-Binding" rel="nofollow">https://github.com/openhab/openhab/wiki/MQTT-Bindi...</a></p>
I did not have the MQTT and other bundles I needed. Also, the IMPORTs were missing from the RULES file. I saw them in the DEMO file and added them to your RULES example Working much better now.<br><br>thanks.
<p>I hope that was a hard boiled egg! Brilliant stuff on this. I'm just starting to work through this. Just ordering parts and stuff, I'm pretty new to all this and just learning really so thanks very much for sharing your work!</p>
<p>Hi, Eric Tsai!</p><p>It's Amazing and quirky!!!</p>
<p>I forgot the mention, the egg is a little warm from cooking. I think that helps to set off the motion sensor.</p>

About This Instructable

13,285views

48favorites

License:

Bio: I love home automation. I hate home automation.
More by electronichamsters:Gingerbread Home Automation Tweeting Pregnancy Test Physical Home Automation Interface 
Add instructable to: