Broken Build Alarm Using RPi And Custom PCB

TLDR: Checkout this Github repoRPi CodeEagle BoardBOM

Anybody who knows anything about CI, knows that a great CI system is the one that really goes out of it’s way to make sure your team know when builds are broken; furthermore, the more obnoxious the alerting mechanism is, the better.  At Ship.io we were looking for a cool way to bring this nugget of wisdom home and use it as an excuse for a cool hack project.  Thus was born a project to wire up this truly annoying strobe light to the Ship.io API so the team knows when there’s a broken build that needs mending.  Here’s the general idea:

There were 3 main pieces to building this project: 1) The Ship.io API which was used to check for broken builds.  2) The Strobe light (most important part) and 3) A Raspberry Pi which was used to poll the API and trigger the strobe light.  Fortunately, we had a Raspberry Pi already sitting around the office running an analytics dashboard.  All that was necessary to integrate w/ the Ship.io API was to write a little bit of Python (super easy).

However, the real trick came when we attempted to wire up the Strobe light to the Raspberry Pi.  Turns out the RPi GPIO pins run 3V but this Strobe light requires 12V.  This completely makes sense given how bright and awfully annoying it is.  It’s hard to drive that amount of irritation on only 3V.  Furthermore, the current limitation on these pins is pretty low as well.  Another solution was needed.

Enter the N-Channel MOSFET.  If you’ve never encountered the magic that is the MOSFET, I strongly recommend reading up on these things a bit.  You’ll find that these are basically the atomic building blocks that make computers go.  In fact, if you were so inclined you could wire a bunch of these guys up and make your own logic gates.

All that tangent aside, that’s not what we were planning to use it for.  The basic function that a MOSFET performs (gross simplification here), is it let’s you switch one Voltage Source (VDS) on/off using another Voltage Source (VGS).  Also, this VDS Voltage Source can be a (much) higher voltage than VGS, the switching voltage.  At this point you can probably see where I’m going with this.  Basically we needed to introduce a MOSFET between the RPi and the Strobe light, with a 12V power source and we’d be golden.


So, that’s exactly what we did.   And damn, it was super cool when that Strobe light went off, triggered by our RPi and powered by the 12V power source!  In fact, here’s the first iteration, cobbled together using a breadboard.

Ok, so at this point we could have stopped.  However, not only were all these dangling wires ugly and potentially “dangerous”, but this was also a great opportunity to put together a nice custom PCB to clean this up.  So, to that end I used Eagle CAD to design a simple PCB to replicate the circuit from the breadboard.  The components on this board included:

  • Barrel Jack for accepting the 12V power source from a wall wart plug.
  • The MOSFET itself situated right in the middle of the board.
  • A Pull-Down resistor, necessary to keep the Gate voltage from floating
  • 6-Pin header for connecting the RPi output and the terminals from the Strobe light

If you’re not familiar with Eagle, or making PCB’s, I strongly recommend checking out Sparkfun’s online tutorials.  This is the one that got me started.  My background is software (not hardware); nevertheless, I found this whole process much more tractable than I originally thought.  Furthermore, every time you get a new PCB in the mail it’s kind of like Christmas, so long as it works.


Once I had my design ready to go, I uploaded it to OSH Park and waited for it to arrive in the mail, which took about 2 weeks.  Once it came, I soldered all the parts (from Sparkfun) and plugged it into the RPi, and… it didn’t work.  Turns out I wired the pull-down resistor wrong.  Crap, well, that’s just how it goes.  It’s all good though b/c the 2nd rev worked beautifully!

So, admittedly this was overkill to make an obnoxious Strobe light flash when a build breaks.  More to the point though, this was a great opportunity to learn about designing circuits with MOSFETs.  It was a super fun project and I strongly encourage more software folks to play with PCB design.  It’s incredibly fun and at times even useful!

Advertisements

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: