Big Red IoT Button


Big Red Button

Taking root from an impulse buy of a 10 cm large red arcade button during a clearance sale, this project is a simple Electric Imp-powered IoT button that posts to popular messaging platforms like Slack and GroupMe. The first iteration was thrown together during HackPrinceton Fall 2016, and posted messages to the "random" channel of the HackPrinceton Slack group. After the hackathon, the button was repurposed to serve as a kind of IoT dinner bell for the Brown Co-op at Princeton University, sending a message to the co-op GroupMe when dinner was ready.

Hardware

The hardware for the button centered around an Electric Imp April development board and a 10 cm illuminated red arcade button from Adafruit. The setup was powered from a single 9V battery, with a NPN transistor used to control the button's light.

Taking a conservative estimate of 50mA at 3.3V for the imp001's power usage, the majority of the power consumed by the device comes from the LED in the button, which draws about 10mA at 9V. Thus, with a 600mAh 9V battery, the button could run continuously for well over 20 hours on a single 9V battery. In practice, code was added to place the imp in sleep mode after a certain run time, and the button is unlikely to be used for more than a few seconds every day. If we assume the device is run for a minute per day every day, the battery would need to be changed about once every 1200 days or 3 and a quarter years.

Slack


Slack Message

The most basic form of the device code used during the hackathon simply sent a message to the server-side agent whenever the imp detected a transition on the pin connected to the button's microswitch. Then the agent would make a HTTP POST request to Slack's Incomming Webhook API with a predefinied message.

In practice, the code is exceedingly simple, just 10 lines including comments! Here's the complete agent code:

Here's the first revision of the device code, which had a basic timeout functionality built in to prevent people from spamming the list by mashing the button.

GroupMe


Slack Message

After the Hackathon the button was adapted to work with GroupMe's Bot API. Creating a bot with the online form gives a Bot ID and Group ID which can then be used to post messages using HTTP POST requests. The same device code can be used, and the agent is practically identical.

Deployment


HackPrinceton Deployment

The button was remarkably succesful, and attracted a lot of attention wherever it went. The Electric Imp platform and chat services' APIs worked very quickly, such that someone could press the button and get a push notification on their phone without perceptible delay.
HackPrinceton Reactions

The best part of this project was watching people's reactions. The physicality of pressing the button combined with the quick response and complete lack of wires made for a really compelling experience. Furthermore, the public visibility of the messages really helped to draw attention to the button and served as a subtle form of advertising for the Electric Imp platform. I think it played no small part in ensuring my Electric Imp workshop later that night was well attended.