For my project of building a real world warning light for application monitors, I needed a way to control 12 V beacon light with my Raspberry Pi 3. Details about the project can be found in here:
Real world alerts for application monitors with Android Things
We’re using application monitoring at work for making sure any issues with our services won’t go unnoticed…
While I understand there are already many different relay boards for Raspberry Pi, but I had my reasons for building it from scratch:
- To fit it inside an official Raspberry Pi 3 case
- To power it directly from Raspberry Pi 3
- To be able to drive 5 V, 12 V and 24 V devices
- To build it myself ☺
The main goal was to keep the device as small and simple as possible, hence I didn’t want a second device with an external power in addition to the Raspberry Pi. There are also a lot of different types of beacon lights out here and I wanted to be able to use most of them regardless of the their supply voltage.
Raspberry Pi is powered from USB, where the voltage isn’t sufficient for driving many of the devices. To overcome this, I used a simple step-up switching regulator to boost up the voltage.
The regulator is LT1172 from Linear Technology with an adjustable output voltage. Instead of using fixed resistors for adjusting the output voltage of the regulator, I decided to add a DIP switch to make it possible to set the desired voltage manually. This allows me to set the output voltage according to the device I have at the time. With four position DIP switch, you can get 16 different output voltages, including the most common ones: 5 V, 6 V, 12 V, 24 V and 28 V. The output voltages with different switch selections (positions 1–4) are listed below.
One of Raspberry Pi’s general purpose IO (GPIO) is connected to regulator’s Vc pin through a transistor. Therefore, turning the GPIO pin on (=pulling it up), makes the current flow through the transistor, connecting the Vc pin to ground and turning the regulator off. This allows to switch the voltage fast enough for my purposes, since I only need to do it a few times per day. If you would need to control LED brightness with PWM or something similar, you would probably need to use MOSFETs that enables faster switching speeds.
The selected passive components are somewhat a compromise due to the limited space. The max height of the components can be only 6 mm, since I wanted to fit everything in an official Raspberry Pi enclosure. Especially good (and cheap) electrolytic capacitors that are low enough, are hard to find.
Otherwise the board is quite simple. There are 40 pin header for the Raspberry Pi 3 and a terminal block for connecting the controlled device. Since there was enough space left on the board, I added two regulators, so the board can drive up to two devices at the same time.
After a looooong wait, I finally got the PCBs. Since this is just a hobby project with a limited budget, I ordered the PCBs from one Chinese PCB manufacturer. Their prices are always really competitive, but it often takes weeks for them to deliver the boards. Especially at this time when Chinese New Year caused extra delays.
Here’s a picture of the board after I had soldered the components:
The board could be shrunk even further by selecting smaller components and using a multi-layer PCB. Bigger component cases were selected especially for the passive components, because I needed to solder the components by hand. But the board still fits inside an official Raspberry Pi 3 case as planned:
The board is quite versatile as it can be used to control any devices with a supply voltage between 5V and 28V. You should be able to get up to 1A (@ 5V) from it, assuming the PSU for the Raspberry Pi 3 is powerful enough.