Philips Hue Remote using ESP8266

Dillon Nichols
My Life as a Tinkerer
5 min readNov 26, 2017

I have a custom-designed home automation system that controls the lights in my bedroom, but there was one pain point — I couldn’t control only the lamps from the doorway. In the dark winter mornings, it would be nice to only turn on the lamps and in the summer, it would be nice to leave the ceiling fan on, but turn off the lamps. In the past, I would have to turn on the Switchmate at the entrance to the room which would switch on the overhead light and fan and the two separate lamps on the nightstands. Next, I could pull the cord to turn off the overhead light, and then I’d have to go to the nightstand and individually turn the lamps off. Although a new input complicates the setup, it allows for more flexibility for which lights I want to switch.

Overall, this is a great project for the hardware or software novice. Most of the resources that went into this project already exist; it was just a matter of merging all of the pieces.

The electrical hardware consists of a Wi-Fi enabled-microcontroller, a button, and an optional LED. The microcontroller is the popular and cheap ESP8266 NodeMCU Development Board. I chose a momentary push button that had a nice feel to it, but anything will do. The only requirement is that it fits in the enclosure you plan to make. I also added a diffused RGB LED and a LED holder so I could display the status using a colored light. There are other LED types available and you can even omit it entirely for a super simple build.

I used a spare USB charger I had to power the circuit. I’ve had great luck at finding high-quality USB chargers for cheap at Goodwill if you don’t have an extra one laying around. I bought a 6' white micro USB cable so it would reach the available outlet and the color would blend into the cream walls. You may have an extra USB cable that you can use.

Enclosure before it was fully assembled

I designed the enclosure in Autodesk Fusion 360 so I could print it on my 3D printer. I wanted to keep the same shape as the Switchmate so it wouldn’t look out of place when they are mounted next to each other. My design has the same rounded corners and is the same width. It also has the same depth as the Switchmate mounted onto the light switch. I reduced the height because I didn’t need the extra room. You can find the source files on Thingiverse.

There are some channels inside the case to hold the NodeMCU by its pin headers. This friction fit worked surprisingly well and I didn’t need any additional hardware to hold it in place. There’s a hole in the bottom of the case to snugly fit the USB cable that I chose. The lid has a snug fit for the button and the LED mount. Everything holds together without fasteners, but I did glue the pieces together for a stronger seal.

Soldered the resistors to the LEDs | Color-coded heat shrink for the RGB LEDs | Attach the button and LEDs to the NodeMCU

As for the input and output, the button doesn’t require any additional resistors. Just wire one leg to pin D1 and the other pin to GND. The LED requires a resistor on each leg. I used a 100 ohm resistor on the green and blue LEDs and a 190 ohm resistor on the red LED. A red LED appears brighter at the same current, so I used a larger-valued resistor to reduce the current so it does not overpower the other colors. The red LED goes to pin D2, green to D3, and blue to D4. These pins were chosen for a reason. When uploading code from Arduino, pin D4 goes high and the blue LED lights. Also when the device is booting up, the blue and green LEDs temporarily come on together. It’s nice to have this LED to quickly check the status.

I had to remove the blue LED from the NodeMCU board because it would light up the whole case

You can build the code yourself by following the instructions in the project’s README. The basic functionality of the software is:

  1. Connects to WiFi and displays a red LED until connected
  2. Loops waiting for the button press
  3. Turns the green LED on to signify that the button has been pressed
  4. Checks the status of the lights (using a custom function that checks if any of the lights are on)
  5. If any lights are on, it turns them all off. If they’re all off, it turns them on and sets them to full brightness.
  6. Slowly fades out the green LED to signify that the operation is complete
  7. Also continuously checks if WiFi has been disconnected and attempts to reconnect if it has. A constant WiFi connection makes the button-press-to-light-switching action very quick.
Compact, simple, and just works

A nice improvement to this project would be to make it battery-powered and thus portable. My enclosure could be modified to allow for extra room for the battery and supporting circuitry. The sketch could be modified so the button wakes the microcontroller from a deep sleep, switches the lights, and goes into back into the deep sleep mode to minimize current draw. I personally didn’t need a portable version, but I’d love if someone remixed this design to support it.

All files are available so you can build your own! Reach out to me on Twitter if you need any assistance.

--

--

Dillon Nichols
My Life as a Tinkerer

Electrical engineer: hardware/firmware; tinkerer; hobbyist; amateur fabricator;