Atomic Object’s blog on everything we find fascinating.

AWS IoT Help Button

We recently moved into our new building at 1034 Wealthy in Grand Rapids. The new building is much larger than our old one, and I find myself running around much more and stationing myself in different areas, depending on what I am actively doing.

To help ensure I can provide timely hands-on help—particularly for our printer (which is a common source of problems)—I procured one of the new AWS IoT buttons and programmed it to page me when pushed.

AWS IoT Button Overview

The AWS IoT Button is a simple device consisting primarily of a push button, an LED indicator, and a WiFi card. It can be configured to connect to the AWS IoT (Internet of Things) service in order to deliver data about button pushes. The data consists primarily of the type of button push (short, double, or long), but it also includes the button’s serial number and the battery voltage. This data can then be acted upon to do any number of interesting things using AWS or calling out to other services.

Connectivity

The AWS IoT Button requires Internet connectivity to communicate with the AWS IoT service. When configuring the button, you choose a WiFi SSID to connect to and provide the appropriate passphrase. The button also receives an ARN identifier, so that it can be uniquely referenced within the AWS ecosystem.

Security

When configuring the AWS IoT Button, a new PKI certificate and private key are generated and uploaded to the button. This allows the button to communicate securely with AWS, and it allows AWS to validate the identity of that button. This becomes important when writing specific policies to enable button data to trigger events.

How I Use the AWS IoT Button

When someone presses the AWS IoT button, it kicks off a process which will simultaneously e-mail me, send me an SMS message, and show me a notification on Slack. The message contains a timestamp and an identifier for the button that was pressed (in case there are more such buttons deployed in the future).

I have set the expectation that if I am available, and not in a meeting or otherwise occupied, I will respond to a button push within five minutes. This is often much faster than someone would be able to locate me and request assistance otherwise. While there have been a few instances where people have pushed the button simply to test my response time, I’ve had over a dozen instances of legitimate button pushes. As a result of these, I was able to respond to the notification and assist with a printer problem in a timely fashion.

I’m not sure how well this setup would scale, but for the moment, it is working well.

The AWS Service Flow

AWS IoT

AWS IoT is a platform to allow devices to interact with AWS cloud services.

For AWS IoT Buttons, there is a device or “thing,” rule, certificate, and policy associated with each physical button. A “device” associates a button (by serial number) with a particular HTTP REST endpoint and MQTT topic. The “certificate,” uploaded to the button during configuration, is linked to a “device” and allows the button to securely submit data, while also authenticating it to AWS. The “rule” specifies how messages from the MQTT topic are used, defining what actions to take when a query matches a message. A “policy” authorizes a specific device to take AWS IoT actions, such as publishing to an MQTT topic.

In my setup, I added the endpoint information for my “device” to the AWS IoT button, which is linked to the specific “certificate” I uploaded, along with its private key:

The function finds an SNS topic ARN by name, and then publishes a message to the topic. The event data is not actually passed along to SNS as this Lambda function is unique to the AWS IoT Button that I am using (specified in the “plan” for the “device” in AWS IoT), so I just send a custom message crafted for the purposes of the button. It would not be difficult to modify the function to send data about the button push (such as the push type), or send additional data from AWS IoT (such as the button serial number).

AWS SNS

For my purposes, I created an AWS SNS topic called “aws-iot-button-sns-topic” to which I added two subscriptions: one e-mail and one SMS. As I wanted to receive notifications from pushes to the AWS IoT button, I used my e-mail address and mobile number. When messages are published to the topic from the Lambda function, I receive them via e-mail and on my phone.

Conclusion

While certainly not a very sophisticated use of IoT, creating the IoT Help Button provided a good opportunity for me to learn about AWS’s IoT offering. I also took the chance to build a nifty device which helps make me a little bit more effective at my job. I’m excited to try out connecting other devices to AWS IoT, so I can build something larger which drives a more complex set of services.

I haven’t investigated, but it seems like it may be possible. When configuring the button initially, you can set an arbitrary endpoint for the device to communicate with. As long as the endpoint was able to correctly handle any event traffic, it should be able to operate in that environment.