Skip to content

An offline-first IoT on-air light for video meetings, using ESP32 & JS

License

Notifications You must be signed in to change notification settings

HipsterBrown/on-air-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

On-Air Light

An offline-first IoT project on-air light for video meetings, using ESP32 & JavaScript with Moddable XS.

While the materials demonstrate using an ESP32 development board, it is possible using an ESP8266 with the same code (updated pins probably required) since Moddable runs on both platforms.

Materials

Wiring Diagram

breadboard wiring

Setup

The dev environment was bootstrapped and managed using xs-dev; however, that is not required if you want to go through the Moddable set up instructions manually or has been done previously.

After cloning this project repo, the ssid and password config fields in the manifest.json to match your WiFi details. The project does not require any Internet access (i.e. "offline-first"), just a shared network for local Web UI and HTTP API control.

After wiring the hardware materials together to match the documented diagram, the code can be uploaded to the board.

Using xs-dev:

xs-dev run --device esp32

Using mcconfig:

mcconfig -d -m -p esp32

Once the LEDs are green for 3 seconds, the web UI should be available at http://on-air.local/.

web interface

There are some HTTP API endpoints for checking and controlling the light outside of the web UI:

  • GET /api/state: returns the current color if the light is on, otherwise returns [1023, 1023, 1023] as "off"
  • POST /api/toggle: toggles the state of the light, using the last used color if the light is off
  • POST /api/color: expects a color field in the body to set the color of the light, returns 204 status code if successful

Deployed Project

External box: external box

Internal layout: internal box

Breadboard wiring: close up of breadboard wiring

Computer Camera event daemon

Run using pm2 to control long running process:

pm2 start daemon/index.mjs --name on-air

The script (daemon/index.mjs) watches the standard output stream from log stream on MacOS for Camera events that include "turn off" and "turn off" messages. When it sees one of those messages, it will make a POST request to the /api/toggle endpoint at the http://on-air.local host. If it cannot reach on-air.local, it will log the error and continue watching the log output.

About

An offline-first IoT on-air light for video meetings, using ESP32 & JS

Topics

Resources

License

Stars

Watchers

Forks