4 Steps to build DIY Hue Dimmer Switch

If you have been following my previous post about the DIY Hue, you will like this addition to the DIY Hue family. It is the DIY Hue Dimmer Switch.

You can either follow the instruction from the DIY Hue located in the following link. I have made small modification to the circuit because I stumble across some difficulties when trying it out.

So here is my final circuit:

Step 1. Build the prototype of the above circuit.

Because I am recycling most of my components from what I have lying around, I need to test that all works before I make it permanent. I picked S8550 for the PNP transistor and S8050 for the NPN transistor, simply because I have them lying around. Here is the pin out for both.

The rest of the circuit is pretty standard passive components. In the prototype I only use two buttons just as on off to make sure they works.

Step 2. Upload the code

Once the prototype is build, it is time to upload the code. You can download the code from the following link. Or if you choose to download from the DIY Hue website, make sure you make modification to the circuit or make adjustment to the code to match the button configuration.

Pay attention to the following section of the code:

#define button1_pin 4
#define button2_pin 12
#define button3_pin 13
#define button4_pin 14

Make sure it matches the connection in the circuit above. Otherwise you should make the necessary adjustment.

You will also need to hardcode your WiFi configuration (SSID and password), along with your DIY Hue IP address. For details on DIY Hue build you can check my previous post.

// replace with your wifi name
const char* ssid = "YourWifiSSID"; 
// replace with your wifi password
const char* password = "yourWifiPassword"; 
//replace with the hue emulator device ip
const char* bridgeIp = "192.168.8.20"; 
//static ip configuration is necessary to minimize bootup time from deep sleep
// choose an unique IP Address
IPAddress strip_ip ( 192, 168, 8, 95); 
IPAddress gateway_ip ( 192, 168, 8, 1); // Router IP
IPAddress subnet_mask(255, 255, 255, 0);

The code above shows the configuration that needs to be modified. Once you have modified the above configuration, compile and upload the code.

If all goes well, the dimmer switch should be connected to the Diy Hue bridge. Here is the part to get it to work, you will need to press the button a few times, monitor the output of the serial monitor. You should see that the switch is behaving as expected, i.e.: when you press button 1. You should see some “1000” being sent to the DIY Hue. If you press button 2, it should send “2000” and if you hold button 2 longer, you should see “2001” being sent. Button 3 will send “3000” and if you press it longer it will send “3001”. This is because button 2 and 3 can be used as dimmer. Finally when button 4 is pressed the message “4000” should be sent successfully.

Now it is time to assign some action to the buttons.

Step 3. Assign Action to the button.

To assign the action, you will need to use the “Hue Essentials” App. So open the “Hue Essentials” app and click on “Devices” Icon at the bottom. You should see the following screen:

You should see your Dimmer Switch under the “Smart controls”, so select it and you should be presented with the following screen:

You will notice that you can select each of the 4 buttons and configure it however you see fit. In this example I select the top (I) button and I program it to switch on my Hue RGB light. Then I select the bottom (O) button and I program it to Switch off my Hue RGB light. These are also the button that I wired for the prototype.

Once this is done, you can go ahead and press the button, you should see it working turning the light ON and OFF as shown in the following video:

Step 4. Build the Circuit.

Now that you have a working prototype, you can build the circuit up using a PCB to make the circuit permanent.

Now you can brag to your friends that you have an IoT Light Dimmer Switch that you build your own. The cool part about the switch is you can power it using the battery so it can act like a remote control. You can check out my final build below:

You can see the final build and how it works in the following video. I have assign the button 1 to turn the light on, button 2 to switch colour to blue, button 3 to switch colour to purple and finally button 4 to turn it off.

I hope you have enjoy this build as much as I do. And please subscribe if you would like to be notified when I posted similar build.

Leave a Reply

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