Introduction: IFTTT Smart Button

I created this smart button with the following goals in mind:

  • It had to run off standard alkaline batteries for a decent amount of time
  • It had to be able to interact with IFTTT
  • It had to be small, and because of this it had to be simple

Supplies

  • ESP-01 (You can find these all over the place, I get mine on AliExpress)
  • Push Button (I used these since they are nice and big)
  • 1.5K Resistor (Again, you can find these anywhere)
  • LED Push Button Light (I got mine here)
  • Prototype Board

Step 1: DIY IFTTT Smart Button

I ended up selecting a LED push button light as a case. I got that idea from this guide. This is also where I found out I could power the ESP with just two alkaline batteries. I actually used a lot from this but there was a few problems. Firstly, it was overly complicated. I didn't need nearly as much functionality. Secondly the code is for NodeMCU, and I can't remember why but I wanted to use Arduino IDE. But the project did serve as a great starting point.

The first problem I ran into was figuring out how to make one button do two things. This was tricky because the button is also used to wake the module from deep sleep, so a long press couldn't be detected without adding more circuitry. After much research I finally listened to some advice that I had seen reported a few times but for some reason kept glossing over. The ESP can detect what state it started from. So if it is woken up from deep sleep it will report that, if it was woken up from a reset, it will report that. I used this feature to distinguish between a single tap, which would wake it from deep sleep, and a double tap, which would reset it before it got to deep sleep and thus give a different response. This greatly simplified the circuitry.

Now all I needed was one switch, connecting the RST to the ground with a 1.5K resister. That's it. And of course the power from the batteries. But that it's. The wiring is super simple. There is soldering involved though, so be prepared for that.

Step 2: Making the Case and Board

First you need to modify the case to fit the module. I'll add pictures and detailed steps later but for now; I pretty much just followed the applicable steps from this guide again.

Once the case had been modified you need to solder some wires to the battery terminals. I used jumper wires so I could connect/disconnect the module for easy flashing.

Next you need to make the prototype board with the switch and resistor. Measure what size the proto-board needs to be to go across the two remaining battery compartments. Then simply solder the button into the middle of the board with one lead going to the RST button, and the other connecting to the GND with a 1.5K resistor.

Then I used hot glue to secure the board to the case. The only thing left to do is to plug the wires into the module and put it all together. But before that it'd be good to have some code on there first. Let's flash it!

Step 3: Code!

And here's the code!

Just replace [SSID], [password], [trigger], and [key] with the appropriate information.

You'll actually need to create the trigger and get the key from IFTTT first. So lets go do that then come back, because I like to do things backwards.

Step 4: IFTTT Setup

You need to set up an IFTTT webhook that gets triggered by hitting a specific URL. If you don't have an account on IFTTT, what are you waiting for? It's awesome, go sign up.

If you already have an account and are familiar with creating applets, this should be too hard. But if you aren't here's a concise little guide on setting up a webhook.

Now you have your info, the trigger name and your key, for the code!

Now you can finally flash the code.

Note: Since these buttons can be used to do whatever you want, and you may change the function later on, I recommend going with generic trigger names, like button1 or bluebutton, so if you change it's function later the trigger name isn't something related to what you originally used the button for, which could be confusing.

Step 5: DONE!

And your done. I hope you found this guide useful. If you have any questions or suggestions please feel free to comment.

If you are a decent programmer, which I am not, feel free to fix my code. I have it's deficiencies clearly commented but I don't have the skill to fix them without a huge headache, I really am not a programmer at all.