Close
0%
0%

You got rat

An internet of things ESP8266 rat trap

Similar projects worth following
Dear rat, please send me an email when you done chewing my wires in the attic.

  Reasons

   There is so much confusing information out there on the internet. A lot of old codes that no longer work and a lot of broken code pieces that are rather confusing than helpful. So how can you send an email notification with an ESP board in 2020? I wanted an actual solution that works and it took me days to find it. So that’s why I’m writing this post from the bottom of my heart. I want to give this simple solution to you so you don’t have to struggle.

   Everything is as simple as creating a webhook using IFTTT.com -  which stands for if this than that – and uploading this piece of code (I am giving here) on your ESP8266. This is a proven solution and works with HTTPS clients. No special libraries required. Just copy and paste the code provided in the Files area.

   The most important reason for wanting to create this wifi button is because I wanted to get immediately notified when my rat traps were going off.

  OK so, short story time 

   A few months ago I used one of those traps that zaps the rat and kills it instantaneously. I live in the rural area of PNG and having rat traps is a necessity especially during the dry season. I placed the trap into the hot humid attic of my house and used peanut butter as bait. I checked the trap the second day and it was still armed with no rat inside. I checked it the 3rd and the 4th day and no rat was caught. The 5th day I got lazy and tired to take the ladder and climb into the attic expecting to find that no rat was caught. The 6th day I decided to check the attic trap again and to my unpleasant surprise, there was a dead stinking, decomposing rat inside full of large fly maggots that were devouring it. It took me hours to clean the trap and meanwhile I kept wondering how in the world the rat got so decomposed in a single day. Then I realized that sometimes during the 1st or second day, flies came and laid maggots on the soft peanut butter bait. Meanwhile they kept growing and by the 5th day when the rat was caught, they must have been pretty big. Then they moved from the bait to the rat’s corpse and started consuming it in less than minutes after it was killed. This entire process happened so fast and it gave me so muck work afterwards.

  What now?

   I gave up using the zapping trap, since it seems to be introducing this problem in the process. So instead I started using a live trap cage which I handcrafted some time ago from copper wire. I used a normal closed switch and an external battery and added an LED indicator to it. The LED was sticking out of the attic hatch and this way I could see when the trap was going off the second it was happening. This solution was a simple one and it worked very good, but the problem is that I can only set it into my attic. If I install the trap into a distant place in one of my sheds, I still have to go there and check them every day. So I needed a wireless signal to make it easier for me. That’s where the Wi-fi button comes in handy. The plan was to configure one of these ESP8266 modules to also send an email notification to my phone when the trap was going off. 

   Of course, you don’t have to use this module to make an internet of things rat trap, but once I succeeded programming the ESP module and linking it successfully to my IFTTT webhook, I immediately wanted to post the solution so you could create your own gadgets with ease. I didn’t write the code entirely. I, myself, found bits of codes on the internet and since only some of them worked partially, I compiled everything into this working solution and here it is: available for you to download and play with.

This is a recent 2020 solution.  I know the IFTTT website and the Gmail protocols changed recently so this works despite all the changes. 

ESP8266_button_that_actually_works_2.txt

copy-paste this code into your arduino window, modify the SSID, Password, Key and upload

plain - 2.45 kB - 07/21/2020 at 08:45

Download

View project log

  • 1
    Create an IFTTT account

    (Optional step) Just sign in if you have one already. 

  • 2
    Create a new applet

    I recommend creating a new applet from scratch. If you have previously created applets that you think of modifying with these new parameters, those might not work.

    On the main page click on the Create button and then on the first plus.

  • 3
    Choose a service

    Write webhooks in the search window and click on the specific service thumbnail when it appears in the list.

View all 14 instructions

Enjoy this project?

Share

Discussions

Mike Szczys wrote 08/05/2020 at 16:49 point

I love the hand-built live-trap. You should post info about the trigger mechanism you built for that!

  Are you sure? yes | no

[deleted]

[this comment has been deleted]

Marius Taciuc wrote 07/28/2020 at 23:40 point

Thank you for your kind thoughts. Of course you are allowed to recommend it. Everybody is free and encouraged to download this code and modify it as they want in order to learn and create their own applications. 

  Are you sure? yes | no

Dan Maloney wrote 07/21/2020 at 16:05 point

I've had a single field mouse stink up an entire house, so I can only imagine what a rat that size would be like in a hot and humid attic. My sympathies to you.

Does your alerting trap also, um, "dispatch" the rodent? Because the one in the trap looks a little perky.

  Are you sure? yes | no

Marius Taciuc wrote 07/22/2020 at 01:00 point

Thank you. Yes, the rats here are usually very... beefy. I don't know for sure if they belong to different species compared to the western ones. I just know that I caught rats from different families here. Some of them are having a longer snout than others, some are having no eyelids at all and some are having larger ears. I just hope I will never come across this one: 

https://insider.si.edu/2009/09/new-species-of-giant-rat-discovered-in-crater-of-volcano-in-papua-new-guinea/

:))

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates