In March 2020, I made an On Air Light for Microsoft Teams to indicate whether or not my camera was on for all of my newfound remote meetings. Oh, those were the days. At the time, it was a fun project. I didn’t expect it to be something I still use daily after three years. And, my project was complicated. I called it a DIY project, but you had to have two specialized parts: the light housing and some LEDs from an upcycled light. I literally just used what I had in my parts storage area. I get an email almost daily from folks building their own, getting stuck, or asking for clarification. I decided to redo the project using things from Amazon, reduce some of the DIY aspects, and simplify the code.
I want a light that turns on when my webcam turns on. I want the light to turn off when my camera turns off. The idea is that my camera is on when I am in an online meeting. The light is a good indicator to everyone including myself that I am in a meeting.
In order to turn a light on and off, I need a script that monitors my webcam for activity. This script will then send the status of my webcam to ThingSpeak, a cloud IoT platform that allows you to save and retrieve sensor data. Then, the on-air light controller will read the data from ThingSpeak and turn the light on if my camera is on.
I was able to find everything you need on Amazon to build this project.
Here are some notes about these parts.
- You can use any sign that you want to light up. I chose this one since it was $15US and looks great. It also includes a Micro USB cable that you can use for the ESP32 device.
- Screw terminals make this project a solder-free project. Some people who wrote me said that soldering was a barrier to getting started. I want this to be accessible to as many makers as possible. Screw terminals offer a quick way to break out the pins of the ESP32 board and easily connect wires.
- Only certain styles of the ESP32 board work with the screw terminals. The terminals are for the 38-pin version of the HiLetgo ESP-WROOM-32 ESP32 dev board. The two parts that I linked to on Amazon will fit together perfectly. Other ESP32 boards might not work with the screw terminal expansion board.
ThingSpeak is an IoT service hosted by MathWorks. It is focused on being easy to collect data and then retrieve that data. We are going to leverage that core functionality for this project. ThingSpeak stores data in a channel and each channel has eight fields.
Visit ThingSpeak.com and Sign Up for an account. This will just take a minute and user accounts are free. Once you have a user account, you need to create a channel. ThingSpeak channels are where data gets stored. Create a new channel by selecting Channels, My Channels, and then New Channel. Name the channel, “On Air Light” and name Field 1, “Webcam State”. Click “Save Channel” at the bottom to finish the process.
Click API Keys and note your write API key and read API key. The write API key will be used by the code to track your webcam state. The read API key will be used to turn on or off the light based on the webcam state.
Track Webcam State
I wrote a Python script that uses OpenCV to detect if the camera is in use or not. It sends a “1” to field1 of the ThingSpeak Channel if the camera is in use. It sends a 0 if the camera is not in use. Just run this code on a periodic basis to track the state of your webcam.
The code to track my webcam state and upload the state to ThingSpeak is available on GitHub. Update the code with your ThingSpeak Channel’s write API key.
Most of the magic is here:
def returnWebcamStatus(webcamIndex): webcam = cv2.VideoCapture(webcamIndex, cv2.CAP_DSHOW) if webcam.isOpened(): webcam.release() return True #Webcam not in use else: return False #Webcam in use
Get your parts together and get ready to put everything together. Take your time and step through. There is no soldering, just some connections to be made on a set of screw terminals. You will need cutters, a small screwdriver, and some tape to complete the assembly.
Connect the ESP32 board to the SCrew Terminal Board
Make sure to get the right orientation of the boards together. The 5V pins should line up and the USB part should be pointing down.
Cut Off the Out Connector from the LED Strip
We can use the connector on the out side of the LED strip. Cut this off and strip back some of the insulation. We will use this connector for the screw terminals.
Connect the Connector to the Screw Terminal Board
Connect the red wire to the 5v terminal. Connect the green wire to P13. Connect the white wire to GND.
Connect the LED Strip to the Connector
Program the ESP32
Using the Micro USB cable that comes with the On Air Light, connect the ESP32 to your computer.
The code that the Arduino IDE uses is called a “sketch” – this is just a short program that the device runs over and over. In this project, we are going to have the code that checks the ThingSpeak channel for the webcam status and sets the LED strip to either on or off. Copy the example code to your Arduino IDE and change some of the defaults to match your Wi-Fi network and ThingSpeak settings.
Once everything is set, click Sketch and then Upload. This will take the code and program the ESP32 with it. It takes a minute so be patient. If anything goes wrong, make sure that you have the right board settings and that your “Port” matches what your laptop thinks the port is.
Open the On Air Light
The housing of the On Air light is held together by several tabs. Take your screwdriver and gently twist in each opening. It will come apart without damage. Just take your time and open each tab.
Remove the Existing LED Board
Remove the existing board on the inside of the light. Trim the wires off close to the circuit board so you have some length to work with.
Connect the USB Wires to the Board
Connect the red wire to the 5v screw terminal. Connect the black wire to the GND screw terminal. You will have two wires in each. I used some tape to make sure that the screw terminal board doesn’t move around.
Snap It All Back Together
Carefully snap the two halves back together.
Enjoy your On Air light. Maybe this will remind you or someone in your family that you actually work when you are home.
My goal was to show you the steps as clearly as possible and share the code. I hope that you can reproduce this as easily as possible. If you need help leave a comment or join me on my new Discord server.
This is a great project that inspired me to make a different version with the same effect. I wrote about it here:
That’s awesome! Thanks for sharing your project.