Lab Notes: Getting Started With Amazon’s IoT Button
On the face of it, the Amazon Dash Button is easy to understand: push the button and a day or so later, a product shows up at your door. Behind the scenes there are a ton of things going on, and we wanted to find out exactly what. Being a company that wants to discover what is possible and having a great deal of development experience, we knew that Amazon was connecting many different systems together to make such a simple action result in a real-world action.
Late last year at the annual AWS re:invent conference we were lucky enough to get one of the experimental dash buttons that was a hint to what happened next. Earlier this year, we were able to order one of Amazon’s limited-edition AWS IoT Button Development Kits. For $20, we had our very own programmable Dash-like button that we could instruct to do as we please. The functionality of the button itself is limited: one of 3 different types of button press are the only interactions it can handle. Fortunately, AWS gives us tooling we can use on the back-end to make that simple button press do something more interesting.
Getting started with the AWS IoT Button was pretty simple. Following the IoT Developer Guide, we provisioned the IoT Button to talk to the AWS IoT service and using their button activation wizard we created a Lambda function.
The Lambda function in the getting started guide performs three actions:
- It ensures that there is a Simple Notification Service (SNS) queue created to handle email.
- It adds an email target to the SNS queue and triggers a subscription email to the email target. This ensures that SNS is going to send email to the right place.
- Finally, on subsequent button presses, it places an email on the SNS queue, which is then sent along to the target email address.
This was a pretty simple proof-of-concept that AWS provides to show how to interact with the button.
With the initial proof-of-concept example completed we decided to move on to the real goal of the project — a way to alert everyone that the office coffee pot is ready.
The first phase for this project was to simply let people in our Louisville office Slack channel know that a pot of coffee is brewing in our Cuisinart DGB-900BC coffee maker and, after 5 minutes, that it has finished. We’ve done a number of Lambda to Slack and Alexa integrations in the past — we also use it for AWS CloudWatch alerts while monitoring the infrastructures we’ve built for our customers.
While we would ultimately like to be able to monitor the state of the coffee machine without human intervention, the AWS IoT Button provides us with a convenient way of allowing the person starting a new pot of coffee to start a countdown. A single button press triggers a Lambda function which then sends a notification to a small Sinatra API we created to interact with Slack. Just in case we ever want to expand this service to our other offices we use the serial number of the button to determine which coffee pot was triggered. We match that up with the the appropriate Slack channel for that office location, send a message, and set a reminder in Slack for 5 minutes (the length of time it takes to brew the pot). We also store when the button was last pressed so that we can have our Slack bot answer questions as to when the last pot was brewed. It’s a simple first-pass application connecting a real-world action to a key communication path within our company.
Our ultimate goal is to remove the need for a human to signal the start of a brewing cycle. This initial project was a way of testing the integration points and start getting feedback from our coffee drinkers on the utility of this type of system. While we are gathering that user feedback we will also be expanding the current setup in two ways. First we will store the data generated by every button press and not just the last one. This data will be interesting to watch over time to see if coffee consumption changes during different times of the year. Second we are going to add the ability to handle a long press as an alert that the last of the coffee bean supply has been used and it is time to buy more. Between those two additions we may even be able to apply some machine learning, like we recently did for the Capital Bikeshare project, and predictively order more coffee beans before they ever run out.
Have a vision for an IoT product you want built? Drop us a line.
P.S. The Amazon IoT Button has just become available again.