Wednesday, December 30, 2015

On Air Light for Streamers

For streamers everywhere, whether you are trying to prevent parental humiliation
or roommate intrusion, there needs to be some way to let your cohabitators know that you are on the air.

My kids, like many others dream of becoming the next top Twitch streamer or YouTuber.  After reading the Forbes article about the World's Highest Paid YouTube Stars who wouldn't!?  So of course we built something really cool and geeky to solve this problem.
My young son's deepest grief in the world is when his recording or stream is interrupted by mom or dad shouting up the stairs to tell him to take out the trash or practice the piano.  So UNCOOL! I bet MrMoon or The Diamond Minecart never had to deal with such indignities.

Enter the On Air light project.  The idea is to put a sign somewhere that allows you to send out the message that you are on the air.  I wanted to put the sign downstairs from the "studio." But running up and down the stairs to turn the light on and off just seems like silliness to a geek like me (and my son). So it needed to be remote controllable. I've been dying to play with the esp8266 WiFi chip so this is my perfect excuse.

At the heart of the sign is Adafruit's Huzaah breakout board for the esp8266. For those that aren't paging through and memorizing spec sheets for fun, the esp8266 is an inexpensive WiFi chip married to a micro-controller. Adafruit bundled it up with a breakout board and some excellent instructions on how to write code for it just like an Arduino board with a WiFi shield. But this is MUCH cheaper and smaller.

Here's the theory of operation:

  • Use Adafruit's IoT service to set and store the state of the light
  • The Huzzah uses the REST API to request the latest state of the light's feed on boot
  • The Huzzah subscribes to the light's IoT feed as an MQTT client and waits for state changes
  • When it gets an "On" message it brings 4 pins attached to red LEDs high
  • When it gets an "Off" message it brings 4 pins low
To control the light, the budding Internet celebrity simply logs into the dashboard for the light feed.  From here, the streamer can observe and control the state of the light.

Now on to the build

The build uses the following parts (Adafruit wishlist):
I won't write a play-by-play of the build, but here are the high points that should get an Arduino hobbiest going.

Prepare your Internet of Things account

  1. Setup an Adafruit account and then sign into to setup your IO account.
  2. Create a feed called "onair" following this tutorial
  3. Create a dashboard with a toggle switch widget that switches from "On" to "Off".  Try this out a few times and learn how the dashboard works and the feed updates.

Assemble the hardware

  1. I used right angle headers for my build as it keeps the Huzzah board flat against the back of the case.  It's a little trickier soldering, but I'd recommend it.
  2. Attach the Huzzah to your computer following the instructions from Adafruit.
    1. Try out the LUA commands in the tutorial to ensure it can connect to your WiFi.
    2. Follow the instructions further to configure it to work with the Arduino IDE
  3. Install the Adafruit IO MQTT and IO REST API libraries into the Arduino IDE per the instructions from Adafruit.  The sketch uses the REST API to fetch the state of the feed when the Huzzzah first boots up or if it loses connection and the MQTT library to listen for updates.
  4. Get the code I used from github.  You can see that I borrowed heavily from the Adafruit examples included with the libraries. 
  5. Set your SSID and password in the code
  6. Set you IO username and AIO key in the code. 
  7. Compile and upload the code to the board (press and hold the GPIO button while pressing the reset button once, then release the GPIO button to put it in bootloader mode before uploading)
  8. Watch the serial console (CTR+SHIFT+M) to see it boot up, connect to WiFi, connect the the MQTT stream, and fetch the last state of the light.
  9. Test switching the light mode with the dashboard.  The on board LED of the Huzzah should turn on/off with the state of the feed.  You can't see it yet, but the pins 5,12,13,&14 also are turning high/low so LEDs attached to them will turn on.
  10. Assemble the electronics.  You can use the Fritzing diagram below as a guide.  We'll be using the 9v power supply rather than the battery, but you get the idea. I recommend breadboarding it before assembling it into the display case.
For my build, I twisted the ends of all four resistors together and soldered them into a female jumper. This allowed me to wire all the LEDs into ground easily.  I used female jumpers to go from the IO pins to the LEDs.  It made a nice fit, was solderless, and was flexible to allow me to hot glue the assembly into the display box.  I also avoided using the pins (TX,RX,V+,GND on the right) that hook up to the console cable in case debugging or programming is needed later.

Assemble the Display Box

  1. Discard the white foam in the display box
  2. Cut a piece of parchment to fit over the back of the glass and tape it into place.  This will diffuse the LEDs and hide the electronics
  3. Draw a circle on the back of the display box inside the nut from the panel mount power jack.  Cut out this circle and mount the jack in the lower back of the box.
  4. Place "ON AIR" letters on the front of the glass
  5. Using hot glue, mount the Huzzah and LEDs inside the back of the case.  You can adjust the angle of the LEDs to get the right level of light and diffusion.
I got a little carried away with the hot glue
Find a visible place for your new indicator lamp and plug it in!

Because I miss the html blink tags, I'm going to leave this right here.

I'd love to hear from anyone that gives this a go. Happy Streaming!

No comments:

Post a Comment