Skip to main content

And now for something completely...not plants...

After reading a neat little project by Nick Sypteras where he hacked a Staples "Easy" button to send him an alert when someone was at his cube entrance (Blog post is here), I was inspired.
I borrowed Nick's Micropython code from his Github (link is in his article) and modified it.

My goal was to create a quick notification tool for my team. I work in a fast-paced job where I will often need to leave my desk for meetings or for other urgent reasons, leaving my remote team members talking to an absent person in Slack. A person who often needs to approve their current actions.
Most of my meetings require around an hour of time, so my focus was on that duration. As such, I modified Nick's code to have three buttons:

  1. Green - I am back from wherever I've been.
  2. Yellow - I will be away for up to an hour.
  3. Red - I will be away for over an hour.
I like traffic light systems. My thinking was that green is a "go" for questions/comms; yellow is a "slow down"; red is a "stop" for now.
Creating a webhook is easy enough in Slack (assuming you have access to the tools) and the buttons are simple momentary buttons, following Nick's recommendation to pull them to ground on button press. This simplifies the wiring.
The breadboards I generally use are short and have sticky foam padding on the back, allowing me to attach it to the wall on the way out of my office. The supplies comprise:
  • NodeMCU development board
  • Three momentary buttons (mine came with removable colored caps)
  • Breadboard
  • 20-gauge wire
  • Wire cutter and stripper
  • Power source (in this case a standard mobile phone charger and USB cable)

Ugly cabling is optional


The beautiful traffic light

Side angle and close up

Some notes about my setup that differ from Nick's. I am using a NodeMCU development board. The Feather Huzzah is very similar in spec, including the WiFi chip at the core, but I can't guarantee they are the same. NodeMCU pins work as labelled when programming with the Arduino IDE, but when using the Machine module of Micropython, they do not. Machine needs the GPIO labelling - if you take a look at my code in Github, you'll see that the numbering of my pins is Red = 0, Yellow = 4, Green = 5. That's the three neighboring pins in the pictures. If you Google image search "NodeMCU GPIO pins", you'll get a nice collection of pin mappings that will help. 
Another note is that Ampy, often recommended for loading to Micropython, seems to hate me. I've never been able to get it to work. I use mpfshell which is a neat, simple python-based command line tool that just works - simple commands like open COMn and put file.py allow for easy upload of python files. I use putty for any command line checks of the repl, but apparently mpfshell can also do that task.

The end result works brilliantly. My team are happy that they know when I'm unable to respond; I'm happy that I got to use my hobby at work. 
A normal end goal for something like this would be to go to protoboard, but to be honest I don't know why I would. I think I'll tidy up the wiring, but otherwise the advantages of the adhesive back and ability to modify win out.

Github link for my version of Nick's code: Micropython three button slack alerter


Comments

Popular posts from this blog

Context in Node-Red

It's probably not news to anyone willing to read documentation, but I was able to simplify a number of Node-Red flows recently after a primer on context. In Node-Red, each function node has a self-contained context. Variables are local to that node and nothing is permanent. Unless you use a different context. It is possible to set flow-level and global-level variables that can be used to store values, provide them to multiple other nodes without links, and give the illusion of memory to Node-Red. Setting flow context uses simple syntax: flow.set( 'name of the variable' , 'value of the variable' ) This new flow-level variable can be called anywhere in the same Flow tab. This is great for recording values that don't change every time the flow runs (e.g. a maximum recorded value), or need to be used in isolation from the pathway that generates them. Calling the value is relatively simple as well: var varName = flow.get( ' name of the varia...

Return to the garden

After the mediocre performance of my vegetable garden last year (50% of the plants produced), winter is the perfect time to reflect on what went wrong. First, I started the project with a simple idea and absolutely zero experimentation. Second, the methods I chose did not work as I had hoped they would and my fall back was too simple. Third, minor tech troubles exacerbated the issues caused in the previous two steps. To address item one, I have started prepping my solution as of the end of November 2017 with an eye on March 2018. This is giving me time to test and refine as I go. On item two, I had to look at what worked and what didn't. The pump system worked well, but needs to be reconfigured to deliver water at the soil level; even a moderate drop of four inches resulted in erosion and root exposure over time. The planters were acceptable, but the height differential was tough to deal with. New planters will be needed. The right microcontroller was not available immedia...

Flask, uWSGI, and NGINX - a saga

I have been creating a web page for my wife. It is a booking site for her business and is written in a combination of jquery, HTML, CSS, CouchDB, and python. For the python side of the house I am using Flask. This micro-framework works well for me and allowed me more freedom than I saw reading about Django. It has taken some time, but the app works well. It can retrieve bookings from CouchDB, display them in a calendar, and accept new bookings from a form on the same page. Jquery handles the calendar display, as well as the AJAX call to populate it. Flask handles the data collection from Couch, the data, and the writing of new data to Couch. For cleanliness, two repositories are used for bookings: one for confirmed bookings and one for requests that have not been reviewed. Another repository provides a client list, but is not accessible from the website. Then came the fun part. To serve a website with Flask, the internal web server is insufficient. You need additional tools. In my...