Tag Archives: hardware

How to build a Smart Lightbulb in a Weekend

After years of building random unfinished prototypes and never documenting them, we decided to do a proper blog post to share the love.  We have lots of love to share.

For a few weeks now we’ve been dabbling around with Bluetooth 4.0, otherwise known as Bluetooth Low Energy (BLE).  During that process we thought of a few cool applications and decided to go out and build one of those.

The basic idea is this:  You take a lightbulb, and you stuff it with a bluetooth antenna, an arduino and a bunch of RGB LEDs.  Then control dimming, color, and anything else you can think of with your (BLE enabled) phone.  Good stuff.

Hardware

Since we are making a lightbulb, we have to start somewhere, so we bought a bunch of different light bulbs at Home Depot and ended up picking the biggest one. There are a crap-ton of components so we gonna need the space.  Once we had the lightbulb, we emptied out the boring old fluorescent bulb to make space for the imminent awesomeness.

IMAG0518 IMAG0514

First off, we need a way to power our circuit.  Being the badass engineer that you are, we know what you’re thinking, “I should build a transformer circuit that converts mains power to 5V”.  Good idea!  Except that would take up way too much space, think about it, have you seen the size of those things?  Using the power of laziness, we decided to use one of those teeny iPhone chargers.  Now we have 5V to power everything, next step.

IMAG0529

With 5V we can power the Arduino and the LED’s, but not the Bluetooth module, which runs at 3.3V.  Again, we know what you’re thinking: “Hey, you have an Arduino Pro Mini, and that has an internal regulator that we could use to power the BT module!”.  Well, that’s actually a really good idea, but we are not as crafty as you are so we bought the 5V version of the Pro Mini, instead of the 3.3V.  That means we had to make a 5V to 3.3V regulator.  Not bad, now we’re even.

IMAG0524

Awesome, now we can power the whole project.  Wait, no we can’t, because the Arduino pins are a bunch of wussies who can only drive 40mA. (Someday I’ll design a microcontroller that can drive 1000A per pin.  It’ll be the size of a refrigerator, but I’ll be happy.)  Now that may sound like a lot but it’s not enough for what we want.  RGB LED’s are technically three LED’s all packed inside of one (red,green, and blue).  Each of these LED’s has maximum forward current of 20mA, easily managed by the Arduino pins.  So what’s the problem?  We are planning on putting as many LED’s inside the bulb as we can (We ended up just using 3, don’t judge).  So we would need one pin per color per LED.  That’s a lot of pins, so we used a transistor to drive each color.  That’s 3 pins, for any number of LED’s that we want (if the transistor can drive the current, that is).

Let’s not forget the resistors on those LED’s.  We didn’t have a whole lot of resistors lying around so we couldn’t make all the LED’s run with exactly the same forward current.  Still, it was close enough.

Red = 17mA     Green = 16mA     Blue = 18mA

IMAG0533

Now it’s just a matter of connecting everything together.  And this is how everything looks together,  in all it’s hot-glued glory.

IMAG0532IMAG0537IMAG0547IMAG0536 IMAG0540IMAG0550

Software

Great, all the hardware’s done.  Now for the brains of the operation, which is divided in two parts.  The Arduino firmware, and the iPhone application.  The firmware is pretty straightforward.

Right now,  the Arduino isn’t reading serial data from the BLE module, it’s pretty much working as a pass-through for whatever the BLE module says.  It reads the value of three of the BLE’s GPIO’s to control each color of the LEDs.  In the future, it should read serial commands from the UART and have a big list of awesome things that it’ll do.  Naturally.

And as you can see, it looks gorgeous.

IMAG0555IMAG0554

For the iPhone application, you’ll have to wait for a future post, by our very own Ramón González.

Parts List

Finally, if you want to build your own, here’s a rough list of all the parts, and their prices.

Lightbulb: $10 for two.
This bulb is great for this because it’s pretty big, and easy to open up.

Charger: $5
We used a cheap knockoff sold at a local hardware store.  You can use any, as long as it fits inside the lightbulb.

BLE Antenna: $44

Arduino Pro Micro: $10
We used the 5V version, but you’re better off buying the 3.3V one.

LED’s + Miscellany: ~$10

For a grand total of about $80 for the whole thing.