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