Rewind a few months. I bought an AWS IoT button. I followed Amazon’s getting started guide. I manually set up things, certificates, policies, and roles. After an hour, I was stuck. I could not “press the button, and get a SMS”. I had a friend help. We solved it together. Phew! Two hours for “hello world”? It dampened my IoT button enthusiasm.
Fast forward to now. I make another attempt at the button. I visit AWS IoT Getting Started. Hmm… this is different. What’s that? A new AWS IoT Button mobile app?! I download the app. 10 minutes later, I press my button and get a text through IFTTT Maker. I pat myself on the back. 10 minutes more, and I’m spamming Slack with the press of a button. Awesome!
The new app, and IFTTT, take a ton of frustration out of the original setup.
Pre Setup — Computer
- Buy an AWS IoT Button. 2nd generation buttons are out!
- Create an AWS account. You need a credit card. There’s a free tier.
- Have your button handy for setup. Keep the box. The serial number barcode is helpful. Plus, it’s hard to read the serial when you stick your button onto something with the adhesive.
IoT Button App — Phone
- Download the AWS IoT Button app for Android or iOS
- Launch the app
- Set up AWS IoT button
- Follow the directions. The app nicely guides you.
- Scan your button barcode. Did you keep the box? If not, enter it.
- 6-second-press your button to connect and configure wifi
- Choose what happens when your button is pressed
- Select Trigger IFTTT Maker (nodejs) for your button action. The other options are nice, but IFTTT opens a ton of possibilities, with so many other connected services, beyond email or SMS.
- The app prompts you for a Maker API key… that’s coming up next.
- Set the phone aside. Switch to IFTTT on your computer.
IFTTT Applet — Computer
- Sign in to IFTTT, or create an account
- Create a new applet. (IFTTT used to call these recipes.)
- Select Maker. This service makes and receives web requests. Neat!
- Select Receive a web request
- Enter an Event Name. You’ll use this later. Something like buttonPress.
- Choose the SMS action. This action happens when Maker recognizes you pressed your button. Later, I mention how to change to another action.
- Writer yourself a clever SMS message
- Well played! You created your applet (recipe).
- Now get the Maker API key. This is tricky to find on IFTTT. It’s in the Maker settings. The key is that big string of junk in the URL.
IoT Button App —Back to your phone
- Get the Maker API key on your phone. I email it to myself for easy copy-and-paste. Or manually type it in … good luck.
- Tap OK
- Set Action
- The app does its magic: setups up Lambda, certificates, policies, etc.
- The button is now setup in AWS with all it’s parts. Lambda knows to reference IFTTT. Great! A few more steps to connect the final pieces.
AWS Console — Computer
- Sign into to the AWS console
- Navigate to Lambda. You’re about to tell Lambda about the event you made in IFTTT. Remember buttonPress?
- Click the Lambda function to edit it. The phone setup created this. You just need to make a quick edit. Easy!
- Look on line 29 and 30. Make sure buttonPress is the makerEvent. This bit of code now says: when you press the button, Lambda requests the buttonPress event. That event initiates your IFTTT Maker applet, which sends a SMS.
- Save. If you Save and test, you should get a SMS since Lambda fires off the IFTTT SMS event.
- Take hold of your button
- Deep breath…
- Push the button! (single press)
- Moment of truth…
- Did you get a SMS message?
- Great success!
- If you’re like me, you’ll cheer if it worked. (Or you’ll scowl, if it didn’t. Double check your Maker API key, event name, AWS regions, Lambda code on lines 29 and 30.)
Now, your button is setup in AWS. And connected to IFTTT. You have the full range of IFTTT actions to choose from. Email, phone, social, todo lists, home appliances, etc. Create a new applet with the same Maker settings and choose another action.
I created an IFTTT applet to post in Slack, to show off my renewed IoT button skills.
Need ideas? What repetitive tasks do you have? Could they be a single button press?
Tell coworkers when the coffee is fresh. Have it order pizza. Or totally nerd out with a button and algorithm that texts where to eat, based on weather, and bank balance.
Add a line to a spreadsheet every time you eat a healthy meal. Give a button to your kid, or elderly parent, to press when they need something. Keep a button to work, to trigger your house lights, alarm, surveillance camera, thermostat, ice maker, or cat food dispenser.
If you’re really clever, you can use the SINGLE, DOUBLE, or LONG press options too. That gives 3 potential button functions. You could have it SMS, email, and add a card to Trello. All from one button. Radical!
Check out the IFTTT Maker internal api. You can test events and pass JSON options. Fancy!
See your button in AWS IoT Console
Go back to the IoT AWS Console (also in version 2, thanks again Amazon). You can see a bunch of gory details about your button (things), certificates, policies, settings, etc.
If you want to start over, here are the items to remove. Cleanup used to be hard, but the AWS IoT Button mobile app makes that easier too. You remove the IoT device, certificates, policies, etc., in a single step. But you still have to clean up a few other things in AWS like IAM and Lambda.
- In the mobile app, delete your device
- In Lambda, delete the IoT device function
- In IAM, delete your IoT button role
- In IFTTT, remove your Maker IFTTT applet
I’d like to read your interesting button uses and IFTTTs, in the comments!