"Easy" Desk Alert Button

Sending Slack alerts with an Easy Button and Feather HUZZAH

July 2017

We use cubicles at my office, which can often be surprisingly focus-enhancing/cozy. One downside however is that if I have headphones in, there’s no way for a visitor to my desk to get my attention other than by waving their hand in my face, making loud noises behind me, etc. To the entertainment of those visitors, I also startle very easily.

I needed a way for desk visitors to get my attention when I had headphones in that was less annoying for them and less scary for me. So, I built the Easy Desk Alert Button™, a classic Staples Easy Button with a simple hack to send me an alert on Slack when pressed.


easy button hack gif

The hack uses the following ingredients:

The first step is to dissassemble the Easy Button via the screws on the back underneath the rubber feet.

hacked button internals

The PCB is the only non-structural part needed for the hack, so the wires, batteries and speaker can all be torn out.

In order to avoid any interference from the the PCB’s audio chip (covered by the black blob), I cut the traces at the locations circled below to disconnect it from the rest of the circuit (thanks to partsnotincluded.com for cluing me into this step). Now the silicon rubber button in the middle can be used as a simple switch between points A and B.

button pcb hack illustration

I then soldered on two wires to complete the circuit, one from point A in the diagram to the HUZZAH's GND pin and another from point B to pin 14.

feather huzzah pins

The final step is to write the code for the button logic. Since I’m familiar with Python and wanted a REPL for debugging, I used MicroPython, a lightweight python interpreter built to run on microcontrollers. The MicroPython docs list the steps for installing MicroPython on the HUZZAH board. Once installed, the serial Python REPL can be accessed using screen:

$ screen /dev/ttyUSB0 115200



>> print('Hello MicroPython!')
hello MicroPython!
>>

In my experience, the path to the HUZZAH's serial port was /dev/ttyUSB0 on Linux, /dev/tty.SLAB_USBtoUART on Mac. 115200 is the baud rate.


When the microcontroller boots up, MicroPython will run a file called main.py that contains any custom code that should be run on start up. This is where the code for the button logic will live. main.py doesn’t exist on the microcontroller by default, but can be easily loaded onto the board’s file system using ampy.

$ sudo ampy --port /dev/ttyUSB0 put /path/to/main.py
$

My main.py file does 3 things: connects to the wifi network, listens for a button press, and sends a slack alert.

For the button press logic, Pin 14 is initialized as a PULL_UP input, meaning that the when the pin is at an intermittent state (i.e. not pressed, floating between 0 and 1), an internal pull up resistor in the microcontroller will be used to pull the pin up to a high logic level, or 1. When the button is pressed, pin 14 will be connected to GND, which will pull pin 14’s value down to a low logic level, or 0. The code here simply listens for that change in state and responds by sending the slack alert.

def my_test(x):
  print(x if x < 0 else 1)
  print('and that is my test')
import time
from machine import Pin

btn_pressed = False
btn = Pin(14, Pin.IN, Pin.PULL_UP)
while True:
  if not btn.value() and not btn_pressed:
    btn_pressed = True
    send_slack_alert()
    time.sleep(.2)
  elif btn.value() and btn_pressed:
    btn_pressed = False
            

I set my incoming Slack webhook to post to a private of channel I made specifically for desk alerts. Slack's docs detail many webhook customizations that are possible, but I just went for the most basic functionality.

import urequests

def send_slack_alert():
  url = '' # slack webhook url
  payload = '{"text": "You have a visitor!"}'
  urequests.request("POST", url, data=payload)
            

As for reassembling the Easy Button, I had to make some cuts in the Easy Button’s plastic to make the board fit and to provide an opening for the board’s micro USB port. Then I mounted the board via two inverted screws that I fit through the Easy Button’s speaker holes and hot glued into place.


button hack process collage


And that's pretty much it! Ever since placing the Buttton on the cabinet next to my cubicle, those desk-shaking, hand-waving experiences have become mere glints in life's rearview. Now, I'm gently stirred by the dulcet whisper of the Slack knock-brush. 🚨 slack 😀

Speaking of rearviews, I guess I could have also just gotten a mirror...

The full main.py file can be found via the Github link below. Thanks for reading!