Hue – tl;dr + downloads

This page contains all relevant info on the custom, Hue compatible, Light Link firmware for the JN5168.

Currently up to 5 (monochrome) lights per JN5168 are supported, this is limited by the amount of PWM ports available. I am thinking about driving the leds through a separate PWM driver like this one. For this I need to figure out how to communicate with this driver. The use of an external driver would open up the possibility of multiple RGB, RGBW and Color Temperature lights. Theoretically the limit is 240 endpoints per JN5168, although available memory on the JN5168 will not allow this. With 5 lights I have seen no performance issues whatsoever, so there certainly is room to increase this number..

Sources for the multi Endpoint RGB LED’s can be found here.

I am in no way an expert on the matter so please do not take any of the information on this site for fact. Building your own lights is not something I would recommend, electricity is dangerous, and it gets people killed. So please, think and be careful!

For those still interested, these are the steps I took to build my own lights.

  1. Got me a JN5186 module
  2. Connected the hardware
  3. Downloaded a flash tool and a binary
  4. Flashed the JN5168 module
  5. Hue App -> Add lights -> Search
  6. Reset JN5168
  7. Enjoyed my lights ๐Ÿ˜‰


JN5168

Any JN5168 module will probably do. My experience is with the JN5168-001-M00 module. All info on this page is based on this model.


 Connecting

  • Endpoint 1 => PWM : timer_00/PWM  โ€“ DIO10 โ€“ PIN 16
  • Endpoint 2 => PWM : timer_01/PWM1 โ€“ DIO11 โ€“ PIN 19
  • Endpoint 3 => PWM : timer_02/PWM2 โ€“ DIO12 โ€“ PIN 20
  • Endpoint 4 => PWM : timer_03/PWM3 โ€“ DIO13 โ€“ PIN 21
  • Endpoint 5 => PWM : timer_04/PWM4 โ€“ DIO17 โ€“ PIN 26


Downloads

Multi Endpoint Dimmable Lights

 

RGB (single) endpoint

This endpoint uses an inverted PWM signal, which means, it only works with a common anode LED, or a driver that requires an inverted signal.

Red : timer_01/PWM1 โ€“ DIO11 โ€“ PIN 19

Green : timer_02/PWM2 โ€“ DIO12 โ€“ PIN 20

Blue : timer_03/PWM3 โ€“ DIO13 โ€“ PIN 21

Multi Endpoint RGB Lights

The following downloads require an additional Adafruit PCA9685. The image below shows all the parts connected, in this case the RGB’s are inverted (Common Anode). Uninverted LED’s (Common cathode) would connect the cathode to ground.


Programmers

Both will work, I use the command line tool.

  • Command line, registration required: here
  • Gui, no registration required: here


Erasing and Flashing

Put the JN5168 in programming mode by connecting SPIMISO (3) to ground while powering the module.

It’s a good idea to clear the eeprom before flashing it with a new binary.

Erase:

JN51xxProgrammer.exe -s COM3 --eraseeeprom=full

Flash binary:

JN51xxProgrammer.exe -s COM3 -f binary.bin

 

Comments

  1. thanks for your amazing work!

    i just installed your rgb firmware flawlessly on my MeshBees via UartsBee v5 – working out of the box!

    but one other question, are you able to also act as a switch/sensor for the hue network? i.E. make some extra buttons as light switches/dimmer/color changer and include sensors like brightness, humidity etc?

    If you are not able to read interrupts on the IO pins, maybe make it a simple router which gets commands via i2c or spi from an arduino and sends them as “switch” inputs to the hue bridge?

    thank you!

    best regards
    basti

    1. What you want is all possible, I’ve been experimenting with I2C and it works just fine. Check out the NXP demo project, this contains an example controller and should get you started.

        1. Hey Basti or Peter,
          I know this is a reply on an old post, but have any of you had any succes with letting a JN5168/MeshBee act as a switch? Or do you have any pointers I can look into?
          Thanks in advance!
          Zohan

        2. Hey Peter or Basti,
          I know this is a reply on an old post, but have any of you had any luck letting a JN5168/MeshBee act as a switch for an Hue bulb?
          Or can anyone point me in the right direction?
          Thanks!
          Arend

  2. Do you know in theory what the maximum number of endpoints could be on a single JN5168?
    I have a bank for 16 relays currently enabling on/off control of most of the ceiling lighting across my home. Via raspberry PI as REST API
    I’m really interested in replacing the PI with a couple of JN5168s allowing me to control the ceiling lights via the Hue Hub and Google Assistant so I have a single place to control all the lighting.

    1. The theoretical (Zigbee) limit is 255, but the hardware configuration of a JN5168 (32kb memory) limits this to a way lower number. While working on the multi endpoint lights, the max number of endpoints seems be 5 for monochrome and 4 for RGB lights. Maybe a simple on/off light will allow for 6 endpoints. These numbers are based on my implementation and there may be room for some optimization, allowing a higher number of endpoints.

  3. Hi,

    I just tried your binaries, they work flawlessly. Thank you very much. Are you planning to add more “bulbs”. Maybe something like white ambience? I think a switch/scene selector would also be cool.

    I am planning to develop some devices myself. But on the NXP site the download for the SDK and IDE is missing. They are having some issues with their servers, bummer.

  4. I would be very much interested in the sources for the binaries you are providing above. I’d like to modify the RGB binaries to have a non-inverted PWM signal and I’m currently thinking about using WS2812 LEDs.

    Thank you very much for your work you’ve done so far!

  5. Hi,

    I have flashed your firmware and built a circuit using MOFSETs to control the channels on a common LED strip, but it looks like the inverted PWM is wrong for the LED strip so although I can change colour, it doesn’t match the hue app. Is there a way this can be changed? I made this project so I could run some LED strips on my hue network without paying their stupid prices for their strips. It’s so close but need to solve this last issue.

    Thanks!

  6. I have now set up the dev environment and can compile the demo without any issues. However when I import your project and try to build I can the error:

    c:/NXP/bstudio_nxp/workspace/JN-AN-1171-ZigBee-LightLink-Demo/Light_ColorLight/Source/zps_gen.c:799:5: error: ‘zps_msgMcpsDcfm’ undeclared here (not in a function)
    make: *** [/c/NXP/bstudio_nxp/workspace/JN-AN-1171-ZigBee-LightLink-Demo/Light_ColorLight/Build/zps_gen.o] Error 1

    If I can get your source to build then hopefully I can work out how to reverse the PWM so my strips work. Anyone got any ideas what is causing this error?

    1. Hi Matthew,

      I cannot debug specific situations. Using the demo projects and custom builds requires some persistence and a lot of trial and error. Since you are able to build the demo, you should be able to figure this out. Maybe you are using a different version of the SDK? Are you using these sources: https://github.com/peeveeone/ZLL_Lights

      Others have managed to get it to work, so it’s probably a local issue.

      1. Hi Ottelo, did you figure out how to get around the zps_gen error?
        zps_gen.c:799:5: error: ‘zps_msgMcpsDcfm’

        regards

    1. Yeah this works on my setup, too. Peter’s setup is missing one module in “App_ZLL_Light_JN516x.oscfgdiag”. You can add it manually or change the whole file.

  7. Hi there. My Demo project almost works. I can compile, flash and see debug output via UART0. My device wants to connect to my hue bridge but this seems not to work. I changed the master key “tsReg128 sMasterKey” in “app_light_commission_task” to the correct one like you + “sScanRsp.u16KeyMask” to “(ZLL_TEST_KEY_MASK | ZLL_MASTER_KEY_MASK | ZLL_CERTIFICATION_KEY_MASK )”.

    Discover on ch[0] 11
    disc status 00
    NWK_DISCOVERY_COMPLETE st 0 c 1 sel 255
    Pan b058198fc8ff1030 Ch 11 RCap 3 PJoin 0 Sfpl 2 ZBVer 2
    Succ and full – vTryNwkJoin()
    No more nwks to try – vPickChannel()

    any idea?

  8. Discover on ch[0] 11
    disc status 00
    NWK_DISCOVERY_COMPLETE st 0 c 1 sel 0
    Pan b058198fc8ff1030 Ch 11 RCap 3 PJoin 3 Sfpl 2 ZBVer 2
    Succ and full – vTryNwkJoin()
    Try To join b058198fc8ff1030 on Ch 11
    Try join status 00
    APP_DiscoveryTimerTask
    APP_DiscoveryTimerTask

    1. I see that I can connect to my OSRAM Lightify Bridge as a “Light On/Off Light”. But why that not works with Philips Hue Bridge with the NXP demo project.

    2. Ok I made it. I just forgot to change they Key in โ€žzpr_light_node.cโ€œ ๐Ÿ™‚ Now my lights can connect to hue.

      Now I want to connect my “JN5168” as a button/controller. I just changed the keys and comment out the touch button function (otherwise the system will hang because I have no touch dev board attached to my JN5168 module). But I cannot pair the controller with the Hue Bridge. My debug output counts down 30 -> 0s and then goes into sleep mode. How can I connect controller/buttons with HueApp to my Hue Bridge?

  9. Awesome!! work with hue
    Hi, May I know can I buy from you the zigbee module ready work with hue?
    This module for long term to use .

  10. Hi Peter, great work !

    I wonder if there is a non-inverted ready made binary (single RGB) available – I might have overseen it o.O

    Inspired by your efforts, I attempted to get the firmware out of a CC2530 based Living Colors Iris Gen2 – the “Smartlink” one. But so far no luck as the chip is locked. Any suggestions there ?
    The goal was to update an older version of the Living Colors Lamp (Gen2, but no Smartlink), as the hardware is identical but the software lacks the support to bind it to the bridge.

    Kind Regards, Jan

    1. Hi Jan,

      The RGB PCA9685 binaries support all configurations, including single RGB. I have no experience with the CC2530 chip, so I can’t be of any help there.

      1. Hi Peter,

        but this would require a PCA9685. I’d rather keep it simple and drive the LEDs with a MOSFET directly off the JN5168.

        Thanks again for your work !

  11. For RGB (single) endpoint could you please also add the un-inverted PWM signal version?
    Thank you for the extraordinary work that you are doing, it helps tremendously.

    1. This would be awesome! Tried to get the software from NXP but they never answered my request, so this is my only option now.

  12. Thanks to Peter for a very inspiring range of articles on programming the NXP JN516X modules.

    I just flashed the “JN5169 -> 1 Endpoint: Light_DimmableLight_JN5169_ME_1” binary to an Innr CR 110 Remote Control with a JN5169 module on board.

    The Hue App did not find the Light using the regular “search light” in the Philips Hue App, but it was found OK when I used Touchlink in the iOS App “Hue Light”, and I can control the light in this App.

    The Light is also visible in the Philips Hue App, but is reported “unreachable”.

    So, some remaining challenges, but I’m pleased that flashing the module results in a “working” solution.

  13. Hello,

    I managed to flash the firmware onto a mesh bee. It is detected by my hue bridge, and will blink the LED as a test when I select it. However, a few seconds later it becomes unreachable, and I’m no longer able to control it. I can reproduce this issue by resetting the EEPROM on the bee, re-flashing it, deleting the light from the hue app, and cycling power to the bridge. After it detects it again, it will only work for about 10 seconds. This doesn’t sound quite like a hardware issue. Is it possibly because of a hue update? Any help or advice would be greatly appreciated. Thank you.

    1. Hi,

      Had this exact same problem too, last week. Tried resetting the Hue bridge and the JN5168 bur eacht time tlhe lamp turned unreachable within a minute.

      I managed to get the Dimmable Light binary working with the following procedure. I know it sounds weird, but it works every time.
      – flash the binary
      – use the App to search for new lights. light appear in App, but gets unreachable almost immediately
      – flash the binary again
      – use the Hue to App to search for new light, BUT DO NOT DELETE THE UNREACHABLE LIGHTS
      – the lights are now Working OK and do not get unreachable anaymore.

      Sounds weird, but has worked many times for me.

    2. @kuu did @Gerardwr ‘s tip work for your problem? I’m havin the same issue and don’t know how to fix it ๐Ÿ™

      1. …and there is some other strange thing…I was used to, when the JN5168 is flashed and you plug it in, the lights turn white at first powerup.
        Now the turn blue. One every JN5168 and every board…

        Can anybody explain that?

      2. and this got fixed too! the trick is that both times the EEPROM has to be erased…than it works ๐Ÿ™‚

  14. Hello,

    i just ordered 3 jn5169 chips and i would like to write my own piece of code to make a dimmer for a 200w halogen light with a thyristor. But i have no idea on how to build the zigbee stack so it communicates with hue. Can you share the source code of the jn5169 build you made so i can alter it to make my project work?

    Thanks in advance!
    Bas

    1. Hi Bas,

      I managed the make a traditional dimmer with the Light_DimmableLight_JN5168_ME_1-1 binary Peter made (as a replacement for the Philips Livings Whites Plug).
      Just use the PWM output on DIO13 to drive a Triac, Thyristor or, in my case two mosfet’s (i needed a trailing edge dimmer).
      In your case you can use the Light_DimmableLight_JN5169_ME_1 binary.

      Hope this helps.

      Regards,
      Jacco

  15. Hi Eric,

    Did you order and tried the E75-2G4M20S modules?

    I did, programming no problem but the reception is poor. A few meters away from the bridge and they become not reachable.
    With my Mesh Bee’s no problem but they are much more expensive.

    Regards, Jacco

    1. I’m trying to use it but without success.
      Do you have resolved your problem?
      Which kind of firmware have you loaded?

  16. Hi,

    Can someone point me in the wright direction on how to enable console logging?
    I unremarked the following in the makefile under Common_Light\Build and rebuild.
    CFLAGS += -DDEBUG_APP
    CFLAGS += -DDEBUG_START_UP
    CFLAGS += -DDEBUG_LIGHT_NODE
    CFLAGS += -DDEBUG_LIGHT_TASK
    CFLAGS += -DDEBUG_JOIN
    CFLAGS += -DDEBUG_COMMISSION
    CFLAGS += -DDEBUG_CLASSIC_JOIN
    CFLAGS += -DDEBUG_EXCEPTIONS
    CFLAGS += -DDEBUG_TEMPERATURE

    CFLAGS += -DDEBUG_CLD_IDENTIFY
    CFLAGS += -DDEBUG_CLD_LEVEL_CONTROL
    CFLAGS += -DDEBUG_CLD_ONOFF
    CFLAGS += -DDEBUG_LAMP

    But i don’t see any console messages.
    Btw, what is the speed of the UART?

    Thanks in advance.

    Regards,
    Jacco

  17. Hi!

    I have followed the project and orderd my own JN5168. The binary flashed using beyond studio for NXP. The dimmable light 1 end point is shown in the hue app, but it does not stay connected. Did you have the same problem and is there somthing I should do?

    Could you also provide the source code for the binary’s?

  18. Thanks so much for this; I used the 2 dimmable endpoints binary with no problems.

    I’d like to make some edits to peeveeone/ZLL_Multi_Endpoint_Dimmable_Light and the commit from 14 Oct 2017 all compiles but I’m having trouble figuring out what’s needed to compile for different numbers of endpoints. If it’s a short explanation, could you let me know?

    Best,

    Dan

    1. Ephraim Ben Moshe,
      Which kind of firmware have you loaded?
      Can you give the part number, mine is E75-2G4M20s

  19. Hi, great Project
    Are you working on a firmware for tunable lights?
    will the project be further developed?

    Thanks, Marcel

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.