How To Make Your Very Own Wireless, Extra-Magic Smart Bulb

Discover the secrets of smart bulb-magic technology!

As you may remember, I broke my smart bulb. Seeing an opportunity in this unfortunate (okay, mostly just annoying) event, I decided to take on that opportunity to reverse engineer it. And of course, after reverse engineering comes the part where I improve it!

I liked the original bulb design, but it had one annoying constraint, as most light bulbs too: it must be plugged to wall power to work! While I realize I might be a special case, this does limit my ability to do “magic tricks” with the bulb, such as this, where the bulb magically lights up “all on its own”:

So how did I overcome the constraint?

When I first presented the bulb to some friends, their initial reaction to the bulb suddenly being powered out of the thin air was shock — though, most of them guessed the trick just a few seconds after.

Magic can be, of course, sometimes hard to grasp.

Have you guessed it yet? If you guessed, a battery, well, you’re right!

If you recall, when I cracked the bulb open, I discovered that it comprised three different circuit boards — one for the power supply, one for logic (+Bluetooth radio), and another one for the actual LEDs. The power supply board had only three connections to the logic board: 3.3V, power, and a third, higher voltage line, which I guessed was around 12V, after connecting it to my power supply and experimenting with different voltages.

So my game plan was to fit some battery in there, ad some circuity to convert the battery voltage to 3.3V and to 12V, and play that everything fit back into the bulb.

After trying a bunch of different kinds of batteries — 500mAh and 350mAh LiPo batteries, as well as a pair of AAA NimH batteries — I figured out that none of them would fit! I remembered I had a tiny 130mAh LiPo battery lying around, and decided to see if that might work as a last-ditch solution, and it worked!

This is how you disassemble the bulb

So now for the “magic ingredients”:

  • Small LiPo battery — 100mAh will do
  • 12V Step Up Voltage Regulator — I used this one
  • 3.3V Voltage Regulator — You can use this one

The next step is super easy: simply connect the inputs of the 3.3V and 12V regulators to the positive side of the battery, their grounds to the negative side of the battery, and then connect the 12V, 3.3V output and the ground to the logic board of the bulb:

Easy as pie!

The most challenging step by far, though, is figuring out how to fit everything in!

It can be done, just make sure you don’t squeeze the LiPo battery or short circuit anything (I recommend using Kapton tape or similar for isolation). LiPo batteries react really bad if you puncture them… and so please be careful.

Just put everything together…
…and voila!

Finally, make sure you isolate the bulb base from the electronics — just to make sure it won’t blow up if you do plug it to mains. As a side note, the bulb should be considered “battery operated only” now, as doing any more might be problematic: for example, messing with the mains of a lightbulb is illegal in some countries, including Israel (unless you are a certified electrician).

Bonus — adding a switch and a charging circuit

After packing everything in and re-assembling the bulb, I quickly realized it would be tedious to disassemble the entire bulb each time I wanted to disconnect or recharge the battery. The battery lasts between 30 minutes and a few hours (depending on usage), so I would have to do this before and after each demo.

Luckily, I had a small circuit that I created for another project which housed a Switch and a LiPo charging circuit with a Micro USB port (and as a bonus, 3.3v regulator on board). I quickly trimmed just the part I needed from that circuit and connected it to the battery and the logic board:

Trimming off the parts you don’t need is a lot of fun!

I managed to pack everything back into the bulb, with the switch / USB port facing towards the base screw of the bulb, so I could switch it on/off and recharge it by simply removing the base screw, which pops out really easily.

Putting everything together…
Power on!

I designed a smaller version of the charging circuit, with a spot to connect the 12V voltage regulator board I mentioned above, which you can find on github. Hopefully this will help you to build your own in-bulb charging circuit!

The new bulb-battery charging circuit, with the 12V regulator board mounted on top

If you want to buy it assembled, or better — a package with all the parts and assemble it yourself — just ping me on Twitter, and I will try to get one for you (I have a few spare boards).

Now for Some Magic: ng-beacon and Battery SmartBulb!

When combined with the power of ng-beacon and the LiPo battery, the Smart Bulb all of a sudden becomes and excellent tool for magic tricks (and pranks, if you’re so inclined ;). You can tape the beacon to the bottom of the center of the table during your séances, keep it in your backpack to light up your “bright ideas,” or put it in your pocket and casually cause all the smart bulbs lying on your friends’ coffee tables to light up different colors every time you enter the room!

So long as you can get the ng-beacon and the bulb in proximity, you can use any of these strategies to treat your friends to some family-friendly magic. Here is the code to do so:

All you need to do is change the threshold value to control the distance. We monitor the RSSI (Received Signal Strength Indication — that is, how strong the signal received from the bulb is), and change the red intensity accordingly. The code also does some basic filtering — it averages the last 10 samples to filter any noise that would cause flickering (RSSI is really noisy in real world).

SmartBulbs, Web Audio, and Sneezes!

l

How does this work? I hacked my web-lightbulb project from the Web Bluetooth Post to use the Web Audio and recognize loud sounds, toggling the bulb power. In fact, this is all the code I had to add to the project in order to make it work:

Basically, I call getUserMedia() to get microphone access, and then create an analyserNode object which lets me access the raw audio stream coming from the microphone. Then, I set up a timer that run every 20 milliseconds or so and detects peaks by calculating the average sound power over the last few milliseconds. If the average sound power is greater than SNEEZE_THRESHOLD, it will toggle the bulb (switch on/off). There is also a timeout mechanism that makes sure we wait at least for SNEEZE_TIMEOUT milliseconds before toggling the bulb, just to make sure we don’t interpret the same peak twice.

Let There Be Light!

I showed off many of these “magic tricks” during my talk at Jazoon Tech Days, and some people even came up afterwards and told me that it reminded them of a real magic show! I even tried to use the Web Speech API to get voice control to power on the bulb on stage when I said a “Magic word.” It didn’t quite work during the demo, but the audience seemed to enjoy it all the same. For some reason, Web Speech was not able to pick up my commands during the talk.

There are clearly loads of “magic” possibilities for the smart bulb, and maybe even other IoT/Bluetooth LTE connected devices we could do tricks with! I’d love to hear any great ideas you have in the comments — a part of me is thinking I might build some more tricks and take this magic show on the road!