05/09/2020

DIYHUE light using ESP8266

By snorlaxprime

I stumble across a post about how to turn your ESP8266 to be compatible Philip Hue device.

Step 1. Install DIY Hue

The first step is to install the DIYHUE, I choose to install this in the docker container in Raspberry Pi. You will need to make sure that there is no other service running on port 80 and 443, as this is needed for DIYHUE.

So run the following command to install and run in docker container:

docker run -d --name diyHue --restart=always --network=host -e MAC=XX:XX:XX:XX:XX:XX -v /mnt/hue-emulator/export:/opt/hue-emulator/export diyhue/core:latest

If you choose to run it in host, you can follow the official instruction from diyHue.

You will need to install nmap for ESP lights autodiscover, so you can install it from the following command

sudo apt install nmap

You will need the create your certificate file cert.pem for the ssl to work otherwise the Philip Hue app will not recognise your diyHue bridge. I have wasted countless hours trying to figure what is going on. Paste the following command to generate your certificate file.

curl "http://mariusmotea.go.ro:9002/gencert?mac=00:11:22:33:44:55"

Make sure you replace the mac address with the mac address of your Raspberry pi. Then copy the output to

/mnt/hue-emulator/export/cert.pem

make sure you stop the docker container if you are running the diyHue inside docker.

If all goes well you an check your docker container by using the following command:

sudo docker container ls -a

You should see that the diyHue is running as per the following screen shot:

You can also check by pointing your web browser to the following location:

http://{IP_ADDRESS}/hue/linkbutton

You should be presented with the login screen. The default login username is Hue and password is also Hue. Make once you logged in you will see the following link button page to pair your diyHue to the Hue App.

Make sure you change the password for security.

Step 2. LED Strip with ESP8266

In this step we are using the same circuit from my previous post about ESP8266 with LED Strip, with slight modification as described below. If you prefer to use the same pin out to control the LED, you will need to modify the source code to match the R, G, B respectively.

I added voltage regulator 7805 so that the ESP8266 can be powered from the same power source. The output of 7805 regulator is 5V which will feed into the input of Vin of ESP8266.

Step 3. Upload the Arduino code.

I don’t claim to own this source code. I am utilising what is already there in DIYHue project. The one I am using is the “Generic_RGB_Light”. For simplicity you can download the code here.

For the code to work, you will need to install the Wifimanager library. You can do so by searching from Tools->Manage Library and search for “Wifimanager” by tzapu, at the time of writing I am installing version 0.15.0 as per the following picture:

Compile the code and make sure there is no error and upload them into your ESP8266.

Step 4. Configure your ESP8266 and add lights through Hue App

If your code is uploaded without error. When ESP8266 reset, it will show the access point called “New Hue RGB light”, connect to the access point and check the setting as below:

You should be able to connect to the web interface using the following address, as per shown in the above image.

http://192.168.4.1

Click on the “Configure Wifi” button to enter your WiFi access point and password. Once it restart you can connect directly to the light by pointing to its ip address, you should be presented with something similar to the below:

Now that you have a working light, you are ready to connect the light to diyHue using the Hue App.

Open your Hue App and select add light:

If all goes well, you should be able to see your Hue RGB Light coming up , you can assign it to a location of your choice.

Now you can play around with the settings, set the lights to your heard’s content.