Update (mar 23, 2017)
Update (dec 3, 2016)
Pushed the sources to GitHub, available here
In my previous posts I described how I was able to connect a Mesh Bee with cloned firmware to a Philips Hue and how the cloned firmware provided me with the key to connecting custom firmware to my Philips Hue. For the past few weeks I have been doing just that, creating custom firmware that connects to a Philips Hue. Using the NXP Light Link demo project as starting point, I managed to created two custom binaries, one for a monochrome dimmable light and one for a dimmable color light. Both binaries use the PWM output of the JN5168 for controlling the levels, which makes them suitable for driving led’s directly or through an external driver.
In this post I describe the hardware, software and process to run the custom binaries (download here) yourself. I will open source the entire project with a future post.
Since the Mesh Bee’s do not expose all pins of the JN5168, and I was having some trouble loading firmware (turned out to be a bad UartSBee). I decided to order some JN5168 modules and breakout boards, which also turned out to be a bit cheaper. I ordered the breakouts here , and soldered them according to the guide here. The first board was killed in action after accidentally powering it with 5v instead of 3.3v. To the next board I made two small changes. I changed the header for connecting with the FTDI to be male, this way I can plug the FTDI connector directly to the module without additional wiring. Also, there is a bug in this board, the TX and RX are reversed. Now, this is something I will forget at some point and it will cost me valuable time before I will realise this was indeed the case. So, I modded the board by breaking the TX and RC traces and soldered wires to the correct pins en solve the bug.
UPDATE: I moved all the downloads and connection info to a new page: ZLL – tl;dr
I created two binaries, both of them use the JN5168 on board timers to generate PWM signals required to drive the LED’s. The binaries are available in zipped format: Download:
Light_DimmableLight_JN5168.zip This is zip contains the binary for the monochrome dimmable light. To drive the LED timer_03/PWM3 is used. By default, this timer is activated on DIO13. PWM : timer_03/PWM3 – DIO13 – PIN 21 Breakout – PIN: 21 Mesh Bee – PIN: D13 Download:
Light_ColorLight_JN5168.zip This zip contains the color light binary, three timers are used (red, green and blue). At the time I only had a common anode LED available, so I had to invert the PWM signals, which means, this binary only works with a common anode LED, or a driver that requires an inverted signal. Red : timer_01/PWM1 – DIO11 – PIN 19 Breakout – PIN: 19 Mesh Bee – PIN: D11 Green : timer_02/PWM2 – DIO12 – PIN 20 Breakout – PIN: 20 Mesh Bee – PIN: D12 Blue : timer_03/PWM3 – DIO13 – PIN 21 Breakout – PIN: 21 Mesh Bee – PIN: D13 That’s it, that’s all there is to know about the hardware.
Loading the software
With the hardware in place it is time to load the firmware. For this the JN5168 needs to be in programming mode. To put the JN5168 in programming mode, pin 22, SPIMISO has to be low while booting the device. With the breakout boards this is easy, while holding the program button you reboot the chip by pressing the reset button, after the reset you can release the program button. For the Mesh Bee you can do this by connecting SPIMISO to ground while powering the device.
Download the NXP programmer (here) and the binary you want to load. If you want to create a fresh device, or change the light type, I recommend to erase the eeprom before programming it. This removes the saved device settings such as the network it belongs to. To erase the eeprom execute the command below, where COM3 should represent the port you are using.
JN51xxProgrammer.exe -s COM3 --eraseeeprom=full
After executing the command the eeprom should be erased and you should see a screen similar to the one below.
With the eeprom clean we can program it with one of the binaries. Again, boot the device in programming mode as described above and execute the command below, where COM3 should represent the port you are using, and binary.bin the binary of your choice.
JN51xxProgrammer.exe -s COM3 -f binary.bin
After executing the eeprom should be programmed and you should see a screen similar to the one below.
Connecting to Hue
At this point the programmed device is a Zigbee Light Link endpoint. To register it with the Philips Hue, you have to start scanning for new lights in the Hue app. After you start the scanning you have to reset the device to be picked up by the Hue. I don’t know yet why this is, but for now this is how it works. A few moments later your device should be recognized and depending on the binary you loaded, You should see a Dimmable – and/or Color light.
Thats it, you can now control your custom lights with your Hue! I added some pictures of my setup below. I use the Mesh Bee to drive a cheap LED strip, I simply broke the PWM trace and inserted the signal from the Mesh Bee.
That’s it for now! Please leave a comment.