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.
Your kids look very excited to see the rat. Did you end up having a new pet? 🐀