OnAir! Home working with Style

So this week someone also called Dave gave me this idea of having an OnAir sign which comes on when you go into a video conference. Being “On Air” for me is when the camera is on. One could also look at being in a conference and or detecting the mute button and that could also be done I suppose. So I had a quick Google around looking for a cheap studio style OnAir sign and I came up with the good British product here. Cheap as chips – all it does is switch on and off and can be powered by USB or batteries.

Detecting whether Windows has an active camera I use a registry hack to establish that posted here.

So time to hack. I had a couple of Adafruit ESP32 Huzzah boards kicking about and that was my preference since I can drive it with Wi-Fi and serial. My first MVP was just serial. Wi-Fi also works very nicely with the ESP and the Arduino Wi-Fi manager. Wi-Fi with batteries probably not the best idea. So in general I’m happy with the USB to PC version so I can drive it with the serial port. Depending on a chosen location – Wi-Fi might be better. But the Serial port means it always works quite well.

Modified Interior View…

The device is very simple. When powered it has a simple push switch that has a full-on mode – a pulse mode and off. Its sequential – so a simple push cycles you thorough these modes. So my approach was to emulate the pushes with the ESP32 and an on/off using the relay. The push switch uses an opto-isolator so that I dont actually touch any of the electronics so it will still work as designed.

So in the above photo, we have an ESP32 at the left- no probs there. Rather than trying to hack up the board I too the safe approach and used a clunky relay to switch on and off the USB port. Reason being I can always guarantee state of the device. The relay is driven by a I/O port on the ESP32. The opto-isolator is on the right and that simply controls the push switch. Again using a GPIO pin on the ESP32.

The simple code for the ESP32 – done with Arduino of course just connects to the serial port and does a digital write as needed. WiFi version coming along. The serial port code listens for a single byte char – 0,1,2,or 9 and takes action and responds with a simple OK. Modem like…. In this example we switch the device off. Relay switch off – all done.

if (incomingByte == 48 ) {
   // Switch off 0
   Serial.println("OK");  
   digitalWrite(ledPin, LOW);
   digitalWrite(onPin, LOW);
   digitalWrite(switchPin, LOW);
}

Simulating in Arduino IDE – it looks like this:

Arduino Monitor app

I use Windows because I like things that work and I also like C# so its easy to create an app – System Tray app that can be used to detect the state of a webcam – on/off and then send a message to the ESP32 device.

The Wi-Fi part is simple enough as well. I use the Arduino web server and set up some routes. So if the IP address was 192.168.1.137 – then a GET rest call will switch it on.

http://192.168.1.137/setOn … setOff and so on – the routes are like this:

void setup_routing() {
  server.on("/setOn", setOn);
  server.on("/setOff", setOff);
  server.on("/setPulse", setPulse);
  server.on("/reset", handleReset);

  // start server    
  server.begin();
}

The reset will reset the whole device and clear the Wi-Fi settings bring you back to the WiFi Manager login screen where you can set you Wi-Fi SSID and password.

The full code is here with the ESP32 – not particularly elegant but you get the idea.

So when one is not in a call – this is the app – although it sits in the Windows System Tray – the Windows app looks like this:

App with off Air Status

When the Webcam is switched on

On Air activated

The detect mode will detect if the camera is in use. You can also set a manual mode where you just switch the device on and off.

The Device works quite nicely – and you can also select which app you want to use – if you have Zoom / Teams etc installed and test connection.

So when you switch on your camera in a home video conference – your light will come on which is handy for other family members that might not want to be seen etc etc. …..

I also added a system tray notification that pops up with a On Air message so that you know if your device has activated.

I am looking at developing an Electron JS version just because I like Electron and of course it could run on a non Windows device – but come on – who wants that ?

OnAir working….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s