This repo contains the code for running CircuitPython on a ESP32-S2 prototyping board, to control illuminating a NeoPixel strip and using WiFi to get time from Adafruit IO.
In our case, we want the device to poll for the Public status of a particular user (i.e. the person currently occupying the Study Room), and animate the NeoPixel strip outside. This will allow others to know if the person in the room is available or not.
View a quick demo of it in action on YouTube!
We primarily use Cisco Webex for virtual meetings, and they have a simple Bot API interface we can leverage via simple HTTP requests. In this case, we're just going to poll for the status of a person (myself). To simplify the code running on the ESP32-S2 we'll get my own details by calling the /v1/people/me endpoint.
We wanted a rustic looking pipe that could illuminate. To complete the look, we also wanted to have some frame around the pipe where the LED would illuminate. To do this, we procured the following:
- 8-ft Pine Shiplap - Frame for pipes
- 3/4-in Black Iron Floor Flange Fitting
- 1-in x 3/4-in 90-Degree Black Iron Elbow Fitting
- 3/4-in Black Iron Pipe
- 8x 5/8-in Black Screws - Secure the Floor Flange to Shiplap
- Gorilla Wood Glue - Secure the Shiplap together
- Test Tube 32 x 200 w/rim Borosilicate Glass - Outer glass "pipe"
- Test Tubes w/ Rim 25mm x 200mm - Inner glass "pipe"
- Cut the Shiplap into 1' long strips, then secured them together with Wood Glue and some staples at a pre-defined offset
- Use a Dremel with diamond bits to cut the bottom off the Test Tubes to length
- Design and 3D Print LED strip holder, 1-in Bushing, and ESP32-S2 case Files available on PrusaPrinters
- Print out and/or spray-paint a light diffuser for the smaller Test Tube
- Drill hole behind each Floor Flange to pass wires through
- Chisel out a path for the wires and ESP32-S2 case
- Assemble
Installation on ESP32-S2 doesn't have the concept of PIP, so we'll need to copy over the libraries to the device.
You can do this manually, or using the Makefile to automate many of these steps:
make stage.lib.all copy-files
from collections import namedtuple
from adafruit_led_animation.color import BLACK, GOLD, JADE, AMBER, PURPLE, AQUA
Sequence = namedtuple('Sequence', 'animation speed color')
SLEEP_INTERVAL = 5
CHECK_STATUS_EVERY_N_SEC = 15
MAX_RETRY_ATTEMPTS = 5
# WiFi
WIFI_SSID = '...'
WIFI_PASSWORD = '...'
WIFI_HOSTNAME = '...'
# NeoPixel
PIXEL_PIN = 'A1'
PIXEL_PER_STRIP = 11
PIXEL_STRIPS = 3
PIXEL_NUM = PIXEL_PER_STRIP * PIXEL_STRIPS
PIXEL_BRIGHTNESS = 0.5
# API
WEBEX_BASE_URL = "https://webexapis.com/v1"
WEBEX_BOT_TOKEN = "..."
WEBEX_USER_ID = "..."
# Datetime
TZ_OFFSET = -4
HOUR_START_OF_DAY = 6
HOUR_END_OF_DAY = 21
# Speeds
SPEED_OFF = 0.0
SPEED_SLOW = 0.07
SPEED_MED = 0.05
SPEED_FAST = 0.01
# Status Color
STATUS_ACTIVE = Sequence('Solid', SPEED_OFF, BLACK)
STATUS_CALL = Sequence('Pulse', SPEED_MED, AMBER)
STATUS_DONOTDISTURB = Sequence('Comet', SPEED_MED, GOLD)
STATUS_INACTIVE = Sequence('Solid', SPEED_OFF, BLACK)
STATUS_MEETING = STATUS_CALL
STATUS_OUTOFOFFICE = STATUS_INACTIVE
STATUS_PENDING = STATUS_MEETING
STATUS_PRESENTING = Sequence('Chase', SPEED_SLOW, PURPLE)
STATUS_UNKNOWN = STATUS_INACTIVE