Controlling Milight Lights with a Raspberry Pi and NRF24L01+

picture of bulbIntroduction

I have around 16 Milight RGBW LED lightbulbs and strips (sold under various brands, limitlessled, easybulb etc). These were being controlled using four Milight Wifi bridges. However, the reliability was not great – some transmissions were missed, lights did not always work and careful positioning was required to ensure the signal could reach outlying lights.

Following a google search, solutions were found based around the ESP8266 and the Raspberry Pi. As I’m already using a number of Raspberry Pi units around the house this seemed like the obvious solution and simply required the connection of an NRF24L01+ module and some software running on the Pi.

Most of the work had already been completed by Torsten Tränkner (http://torsten-traenkner.de/wissen/smarthome/openmilight.php).

Connecting the NRF24L01+ Module

nrf24l01+ connection diagramConnect the NRF24L01+ module as shown in the diagram on the left (See https://pinout.xyz/ for an easy to use pin reference for the Pi).

 

 

 

 

 

 

The Software

Taking the code provided by Torsten (https://github.com/bakkerr/openmilight_pi) I modified and enhanced it to support emulation of up to four bridges from a single Pi – this means I can reduce the number of hardware devices and also the number of radio collisions.

As the Milight protocol is a send-only protocol there is no guarantee that the bulb received the message and you have to send the message multiple times.  However, if multiple bridges are sending at the same time these messages are likely to be lost.  By emulating four virtual bridges in the same software we can track and send the messages one at a time.  This reduces the possibility of collisions and shows a noticeable increase in reliability.

Clone this github repository and follow instructions in the README.md to compile and install the software.

The repository also includes an init script and a monit script to keep it running.  If you wish to use these copy them to the relevant locations and the executable to /opt.  The init script comes pre-configured with sample remote IDs so change these to suit your environment.

cp ./openmilight /opt/
cp ./openmilight.init.d /etc/init.d/openmilight
cp ./openmilight.conf.monit /etc/monit/conf.d/openmilight.conf

 

6 thoughts on “Controlling Milight Lights with a Raspberry Pi and NRF24L01+”

  1. Thanks for this interesting post and your code. Is this software supposed to work with the following bulbs?

    https://www.amazon.de/gp/product/B00YMRQFX8/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1

    https://www.amazon.de/gp/product/B00KYYL9BG/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1

    I tried it with the NRF24L01+ module as described by Torsten Tränkner, but starting openmilight in listening mode and pressing any key on the remote control, there is no output (I guess there should be).

  2. Just a quick question, could the code be converted to support more than 4 bridges ?
    Or maybe even be changed so that you can select your own ports so that the amount of bridges would be limitless 😉

    1. Yes, easily. It just requires a little coding effort and you have to think about how to configure it. One thing to note is that you should only ever run one instance of openmilight because there is only one radio hardware! It internally queues the messages from each bridge and sends them sequentially.

  3. Hello,
    I got the following lamp:
    http://www.ebay.de/itm/24-W30W-40W-56W-RGB-LED-Dimmbar-Deckenleuchte-Panel-Deckenlampe-Fernbedienung-DE-/332067741978?var=&hash=item4d50c7a11a:m:mZg89sN2YCrhC8-2_yTdXsQ
    1) Is it possible to use ur code for it? I tried henryk’s one, but it’s not receiving anything (tried with arduino, serial monitor)
    Only the following code works somehow:
    http://arduino-projects4u.com/milight-rf-control/ there on the bottom under software, while receiving, it tells me I’d have a “CW / WW remote”, but I am sure I have a RGBW one (I can change colors with mine).

    2) I get the following error while compiling your code:
    PL1167_nRF24.cpp:39:20: error: could not convert ‘(&((PL1167_nRF24*)this)->PL1167_nRF24::_radio)->RF24::begin()’ from ‘void’ to ‘bool’
    if(!_radio.begin())
    Do you know why? Just checked, begin() returns a int, not a void.

    1. Only way to know is to test it 🙂 The code compiles fine for me, but I do accept pull requests if you’d like to improve it.

Leave a Reply

Your email address will not be published. Required fields are marked *