Introduction: Control ANY Light With Philips Hue
I'm a big fan of Philips Hue lighting. It's easy to use, reliable and integrates really well with the Amazon Echo. I always intended to make my own home automation and lighting system but other projects tended to get in the way. I must admit that the Hue works so well and my wife is happy with it so I think it's here to stay. No point rolling my own.
Having said how good it is, it isn't perfect. What is? There is a nice range of B22, E27, and GU10 bulbs and also some other lamps. I notice an E14 (candle) bulb has recently been added. Philips have got most stuff covered. However, I was all my house working together. When I say "Alexa, all lights off" I really want that to mean all.
For instance, what do you do if you have a room with lots of downlighters? Even if they're GU10, at £25 a go that can get expensive quickly. How about floodlights, 12V track lighting, or flourescent tubes? Philips don't make these. What I wanted was to have any light I wanted controlled by Hue. What I really wanted was my own relay or SSR that fits in with the Philips ecosystem. And with a little bit of work that's now what I've got.
I'm entering this Instructable in the Lights contest. If you like it, a vote would be appreciated. I'm sure there are lots of other great projects too, so take a look and vote for whoever you think has done a great job.
Step 1: First, You Need to Make a Sacrifice
So, I decided the best way to create a stable, reliable product was to adapt an existing Hue bulb. It involves cracking open one of the cheaper B22 white bulbs (LBW010) and altering it to do your bidding. Some might call this "hacking" into the Philips Hue system. Maybe this is true, but I feel I've hacked on the right side of the moral line. I may have tampered with the hardware that I've purchased but I've not delved in the firmware. I've not broken any encryption or proprietary secrets. I've paid for this bulb - I just want it to do a little more. So, let's take it apart.
Go buy a B22 bayonet fitting white bulb (LBW010). In the UK they're only £15, so you shouldn't feel too bad about destroying it.
The first thing to do it remove the translucent plastic cover. Grip the bulb in a vice and go at it with a hacksaw. That cover can actually be prised off without cutting, but the hacksaw help encourage it to pop off. None of the externals will be needed, by the way. If you damage it, don't worry.
Next, prise out the white PCB with the LEDs. Ignore those screws you can see. They just attach the PCB to the heatsink. Just get a small flat balded screwdriver and gently prise out the PCB and heatsink together.
You then need to remove the main PCB from the bulb. One thing worth noting on the B22 bulbs is that the two main contacts for mains power are actually made of solder. Before pulling the PCB out you should melt the solder on these. I didn’t and I ripped off one of the 15Ω resistors that are used as fuses from the PCB. Easily replaced, but annoying that I was heavy handed with this.
The PCB is embedded in a sort of rubbery black resin. You need to get all this off. It's actually strangely satisfying peeling it off. It comes off in chunks or crumbles depending how you attack it. (The eagle-eyed amongst you might notice that this photo is of a slightly different E27 bulb. I played around with those too.)
Firstly, let me get the safety warning out of the way. Never play around with this board when it's powered from the mains. None of it is isolated as you're not supposed to take them apart. Anywhere on the PCB can be at a dangerous voltage. Anyway, there's a better and safer way so there's no need.
Step 2: Begin the Hacking
Now I've done a fair bit of poking around on this PCB so you don't have too, but being a curious Instructables reader, I'm sure you're interested. None of this step is necessary but I thought you might like to know how we got to the end result.
Onboard you'll find the largest IC is a SAM21R21E18A. This is a nice 32-bit ARM microcontroller with built-in Zigbee. It's the brains and communications for the device.
There are a number of test point accessible on the underside of the PCB. It took a fair bit of following traces, checking continuity with a multimeter and probing with an oscilloscope, but I managed to work out what many of these were for. This is what I found:
TP1 - Ground
TP2 - SWCLK
TP3 - SWDIO
TP4 - Serial TX
TP5 - Serial RX
TP6 - LED output (about 32V)
TP7 - Regulated 3.3V power to microcontroller
TP8 - RESET
TP11 - Ground
TP25 - power supply to LM2204 regulator
So there a number of interesting signal here. TP1 and TP11 are the signal ground for the microcontroller and logic circuitry. TP7 is the regulated supply voltage.
SWCLK (TP2), SWDIO (TP3) and RESET (TP8) are interesting. You'd need these if you want to load new firmware onto the microcontroller or debug it. Interesting stuff, but this is arguably starting to head over the ethical line of hacking. It's more complicated than we need anyway.
The serial port (TP4 and TP5) are also interesting. You see some debug output on TP4 as the device powers up. Nothing as you use the device and switch the bulb on and off so not much use to us. Once again, more complicated than we need. If you want to take a look, it's 3.3V TTL 115200 8N1.
I told you it was possible to play around with the device safely, and it is. NEVER power your device from the mains whilst poking around. If you have a clean 3.3V supply you can connect that to TP7 and power the device that way. Better still is to supply a slightly higher voltage to TP25. It's usually at about 24V but even 5V (e.g. from a USB charger) will do the job. You might not be able to light up the LED board but it will connect to you Hue hub. At this voltage but you will be able to look at signals, but most importantly you'll be able to do it safely.
Step 3: Some More Useful Signals
OK all the poking around in the previous step was nice, but how do I know if the light should be on or off? None of the signals on the test point are all that useful. What we really want would be a nice on/off signal or a brightness one. Well, you're in luck.
Everything will be controlled by the microcontroller, so I probed all those tiny GPIO pins on the device. These pins are only 0.4mm apart so it took a steady hand, a sharp probe and it was made far more easy by a microscope. It turns out that PA16 contains that nice on/off TTL signal and a PA17 contains a nice neat PWM output of the brightness. Jackpot!
Now, soldering to the pins of a QFN (Quad Flatpack No leads) IC is definitely on the tricky side. I managed to trace that PA16 output to a slightly more accessible place - one end of the diode D3. It's still small, but a whole lot easier than the IC. See the photo for the location. Unfortunately I couldn't find any easier place to access the PWM signal, but we don't need that right now anyway.
So once this is plugged in to the mains again we have ground, 24V power and a 3.3V on/off signal. Anyone feel we could do something with this and a relay? Yeah - me too.
Step 4: Make Use of These Signals
Now, driving a relay from a microcontroller is something that's been done many times. There are even boards you can find on eBay. Just search for something like "arduino relay 24V" and you're all set.
A cheap SSR like the Fotek will do the job really well too. All you need it to connect the ground to - and the 3.3V output to +. I couldn't be easier.
I had the components I needed lying around so I decided to build my own relay board anyway - a 24V relay, a NPN transistor, a flyback diode and a couple of resistors. I also added a varistor just in case I decided to switch something like a fluorescent tube or an inductive load. (Think of it as a bit like a flyback diode but for AC.)
I knocked up a schematic and a PCB layout, but then prototyped it on some stripboard for speed.
Step 5: Testing It Out Before Fitting
OK, so this should all work, but let's test it out before going to the effort of putting it inside a light fitting. Here I'm using a multimeter on the continuity setting. When the relay closes the meter beeps and flashes. Success! The slight delay when switching on is because Hue lights always fade up. The output signal doesn't go high and the relay doesn't close until the light is set to 100% on.
Step 6: Connecting It to the Light Fitting
All that was left was to connect the Hue and relay PCBs to the light fitting. Luckily there was plenty of room inside the transformer enclosure for my track lighting so they're safely and easily enclosed and out of harm's way.
You don't have to put it inside the light fitting though. Maybe yours hasn't got enough room. It could go inside a light switch back-box. If you made a suitable (i.e. safe) enclosure it could be added to the lead of a lamp.
The best thing about this hack is that you now have control. It doesn't even need to be a light that you control, although of course your Hue system will tell you that it is. And teh best thing about this hack is that all the usual Philip firmware update will go through just fine. Philips will never drop support for your custom light because it shows as one of theirs.
I hope you've found this useful. Feel free to ask any questions, and please let me know in the comments if you connect up something to your Hue system.
We have a be nice policy.
Please be positive and constructive.