Introduction: Connected Studio Warning Light
In this Instructable, we're going to build a very modern take on an iconic piece of studio equipment: a smart on-air warning light that responds to the Robin room reservation system.
This project started life as a practical solution to our occasional need for quiet in a busy office of creatives while recording Uncorked Studio's podcast, With Intent. To read the whole back-story, and find out more about Uncorked Studios, take a look at our blog post.
Bits and Pieces
- Sandies 343-110 3-sided studio warning light
- Raspberry Pi 2B
- USB A to micro B cable and USB power supply
- 8GB+ SD card
- USB keyboard
- HDMI cable and monitor
- USB Mini WiFi Adapter based on Realtek 8188CU
- 12V power supply that can deliver at least 1.25A. We recycled an old laptop power brick that can deliver 12V/5A.
- Pimoroni ExplorerHat Pro expander board
- 12V G4 26 LED lamp assembly
- Murata 78SRH-5/2-C DC-DC converter
- 2x 2N2222A/PN2222A NPN Transistors, TO-92 package
- 2x 10K resistors (leaded)
- Assorted breadboard wire
- 4x Delrin screws, nuts and standoffs
- Plug the ExplorerHat expander board into the RaspberryPi
- Plug a USB keyboard into any of the USB ports
- Plug the HDMI cable into the RPi and connect a monitor
- Insert the USB WiFi dongle into any available USB port
At this point, don’t power the board up. For the first couple steps in this Instructable, we’ll power the RaspberryPi from the USB power supply and cable, connected to J1 (marked “PWR IN”). After the board is booting and configured, we’ll mod it to run off the 12V power brick.
Step 1: Raspbian Installation and Configuration
Raspbian is a Debian Wheezy variant built for the RaspberryPi. For this project, we installed the stock Raspbian build, configured it for command-line only access, and added a few packages to support the additional hardware we installed.
To get the RPi booting a fresh copy of Raspbian, follow the instructions for NOOBS Setup, stopping at “FIRST BOOT” step 5 (raspi-config). Since this application requires the RPi to understand our current time and time zone, we’ll make a few modifications to the standard config before exiting the utility.
Get some more room
From the main menu, select “1 Expand Filesystem” and follow the prompts to make some more space on the SD card.
By default, Raspbian is configured for the UK, including time zone and keyboard layout. If you happen to live elsewhere, a little reconfiguration is required. Clayton Smith wrote a very concise guide to Making the Raspberry Pi a little less British. (His instructions assume you’re starting from the command prompt; to get there, exit out of raspi-config and log in to a shell.)
- From the raspi-config main menu, select “4 Internationalisation Options”
- Select “I1 Change Locale”
- Deselect en_GB.UTF-8 and select the locale appropriate to your location. We chose en_US.UTF-8.
- Select OK to return to the main menu
- Once again select “4 Internationalisation Options” and then “I2 Change Timezone”. Walk through the screens to select your time zone, and save to return to the main menu.
- Once again, select “4 Internationalisation Options” and then “I3 Change Keyboard Layout”. Select the correct keyboard layout for your system. Save, and return to the main menu.
- It’s probably a good idea to change the default password on your RPi at this point. Select “2 Change User Password” and follow the prompts.
- Save, and then exit raspi-config by selecting “Finish”.
Log in to the RaspberryPi using the password you set in step 7 above. (Default user is ‘pi’, password is ‘raspberry’.)
Update Raspbian and install a few essentials
It’s a good idea to update Raspbian to the latest build, and then install a few essential tools we’ll need later. Given all that may have been installed, a reboot is a good idea.
sudo apt-get update -y && sudo apt-get upgrade -y sudo apt-get install -y git build-essential vim tmux curl sudo reboot
Step 2: Set Up WiFi
Install the USB WiFi adapter
By default, Raspbian comes with the drivers required to support the USB mini WiFi adapter. The driver should have loaded automatically on boot. To confirm, run the lsusb utility.
pi@localhost ~$ lsusb | grep WLAN Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Configure the WiFi interface for your network
Now, we just need to configure the WiFi interface to access your WiFi network. (Oliver Marriott provides a very complete set of instructions for setting up WiFi on the RPi. The abbreviated version appears below.)
Edit /etc/network/interfaces with your favorite editor, and add the following block at the end, changing the parameters for wpa-ssid and wpa-psk to match your network configuration.
iface wlan0 inet dhcp wpa-ssid “YourSSIDHere” wpa-psk “YourPasswordHere” iface default inet dhcp
Now, bring up the wlan0 adapter to get the changes and request a new DHCP address
pi@localhost ~$ sudo ifup wlan0 pi@raspberrypi ~ $ ip addr ... 3: wlan0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff inet 192.168.1.100/24 brd 192.168.255.255 scope global wlan0
Set up the host name (optional)
Depending on your network configuration, this may be an optional step. This will enable your RPi to broadcast its hostname so that you may ssh into it by name rather than IP address. To do this, we’ll install avahi-daemon, and configure it to broadcast as onairlight.local.
sudo apt-get install avahi && sudo apt-get install avahi-daemon
Open /etc/avahi/avahi-daemon.conf, and modify the [server] section to broadcast the correct host name and domain. Modify as required to match your network configuration and requirements.
[server] host-name=onairlight domain-name=local
Then restart the avahi-daemon service
sudo service avahi-daemon restart
Step 3: Install NTPD
Since we’re going to be consuming a calendar service to control when the light is on, we’ll need to make sure the RPi always has the correct time. Simply install ntpd and you’re good to go.
sudo apt-get install ntpd
Step 4: Install the ExplorerHAT Python Libraries
Pimoroni’s instructions on Github are complete and very good.
curl get.pimoroni.com/i2c | bash sudo apt-get install python-smbus sudo apt-get install python-pip sudo pip install explorerhat
You can then confirm the card is working.
pi@onairlight ~ $ sudo python Python 2.7.3 (default, Mar 18 2014, 05:13:23) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import explorerhat Explorer HAT Pro detected... >>> explorerhat.light blue, green, red, yellow
Step 5: Power Delivery
Our system requires 2 power supplies: 12V for the LED bulb assembly, and 5V for the RaspberryPi+ExplorerHat. We'll bring the 12V onto the ExplorerHat breadboard, then step it down for the RaspberryPi.
Initially, we used a 7805 fixed-output LDO regulator to supply the required 5V. The system would work fine for a few minutes, but the LDO was delivering its maximum 1.5A and running pretty hot. Eventually, it drifted far enough out of spec to cause the RaspberryPi to reboot. Even with a heatsink, we could only get an hour or two once the cover went on the enclosure.
There are several switching regulators on the market that are drop-in replacements for the 7805. We went with the Murata 78SR, which delivers 2A at 5V.
Wiring to the RaspberryPi
- Insert the regulator into the ExplorerHat breadboard near the edge. Take note of the pin numbering.
- Strip the supply wires on cable from the 12V supply brick, and connect on the breadboard to pin 1 (+12V) and pin 2 (GND) of the 78SR.
- Connect pin 2 of the 78SR to the mezzanine header on the top of the ExplorerHat in the positions marked GND with a breadboard wire.
- Connect pin 3 (5V) with another breadboard wire to the back of the RaspberryPi, under the mini-USB header, by soldering to the test points marked PP1 and PP2. (See image above)
Note that the board can not be powered with the USB brick. Take care to only use the 12V power brick.
Plug the 12V supply in, and the RaspberryPi should power on and boot. Power off and unplug the board before the next step...
Step 6: Light Control Circuit
The RaspberryPi turns the LED bulb on and off by means of a transistor network attached to the "low side" (GND pin) of the LED bulb.
In this diagram, we've used a standard LED in place of our LED bulb assembly for diagram readability. In actual implementation, insert the bulb assembly so that the '+' is oriented to the right of this layout.
To complete the LED control circuit, follow the breadboard diagram above to build out the ExplorerHat board. To test the circuit, move the RPi side of the wire connected to Output 1 to one of the pins marked GND and power on the board. The LED bulb should light.
Step 7: Robin API Integration
Uncorked Studios uses the Robin meeting room reservation system for all of our conference rooms. Through the system, we can schedule rooms and detect if the room is occupied. Robin provides a RESTful API for developers to both read room state and complete room bookings. For this application, we use the API's 'current_event' field to determine whether the on air warning light should be on.
Get the source code
To start, run out to this project's Github repo and grab a fresh copy of the scripts.
Generate a Robin Access Token
To access the Robin API, you'll need to generate a unique API token.
Find your Robin space ID
- Log in to your Robin dashboard and select "View Space" for the room you'd like to associate with the On Air Light
- The space ID is the last string in the URL for the Space details page. In our case, the URL for Echo Chamber ends in spaces/902, so it's 902.
The main Python script
Our script requests the current room's state (in this case, SPACEID 902) and checks to see if the current_event field is present. If so, it sets Output 1 "on". Otherwise, it's set to "off".
In addition, we use the explorerhat.light.blue.pulse() call to fade the blue LED once per second for a visual "heartbeat".
Edit on-air-light.py, and change the following lines to match your token and space ID
# configuration constants # Robin access token _ACCESSTOKEN = <YOUR_ROBIN_ACCESS_TOKEN>
# Space ID from Robin
_SPACEID = <YOUR_SPACE_ID>
Make the script executable:
chmod a+x on-air-light.py
Next, we'll use 'upstart' to automatically start on-air-light.py on boot, and give us control of the service at run-time.
sudo apt-get install upstart
The system will issue some warnings about replacing the traditional init.d (that's the point!), but you can safely dismiss them.
If on-air-light.py is in another location than your user directory, edit the following lines in on-air-light.conf to match, replacing /home/pi/on-air-light.py:
/home/pi/on-air-light.py > /var/log/onairlight.log 2>&1 end script
Next, copy on-air-light.conf into /etc/init. The script will start the on-air-light service after networking has finished loading, and will keep trying to connect with Robin every minute until it's successful, logging any connection errors to /var/log/onairlight.log.
sudo cp on-air-light.conf /etc/init
Reboot when the process is complete, and log back in to the shell. At this point, the on-air-light service should be running:
sudo service on-air-light status on-air-light start/running, process <process_id>
You should see the blue LED gently fading on-and-off. To test the API connection, create an immediate room reservation for your room in Robin, and the light should come on within 60 seconds. If not, take a look at the service log in /var/log/onairlight.log for errors.
Step 8: Mount It in the Enclosure
After all that, the easy part!
- Remove the top cover and front plastic, and remove all the "analog" parts of the On Air Light enclosure - plug/cord and bulb
- Power off the RaspberryPi board, and remove the power cord from the breadboard
- Using the RaspberryPi as a template, mark the back wall of the enclosure for the positions of the 4 RPi mounting holes. Position the board so that the USB end is "up".
- Drill the 4 holes with a bit large enough to accommodate the delrin screws that will mount the board to the box.
- Fish the power cord through the largest hole in the back of the board and secure with a zip tie to prevent strain on the board assembly.
- Mount the board to the chassis, ExplorerHat side "out", with the 4 screws and standoffs.
- Re-connect the power cord to the RaspberryPi board.
- If you're going to wall-mount the unit, this is the time to do it. Pass 2 screws through the mounting holes just above the RPi board in the back plate and mount to the wall.
- Test it out to make sure it's all working, then reinstall the plastic cover and metal lid. Plug it in.
Congrats, you're done!
We have a be nice policy.
Please be positive and constructive.