Introduction: Light, Fan, and Dimmer Control With ESP8266 and Cayenne
The previous owner of my house installed remote controlled ceiling lights in all the bedrooms. This was really cool for a couple weeks, but now I’m realizing that it can be really annoying when I misplace the remote. Each room has a separate remote that only works for that room. Extra remotes are both expensive and hard to come by. Making my own rf remote is impractical as they run in the 400mhz range and there is generally very little documentation about the radio codes for this fan model.
To circumvent this, I disassembled one remote and soldered transistors directly to the physical button contacts. An esp8266 is used to control the transistors, allowing me to switch them using the cayenne dashboard or via other wifi connected microcontrollers. The old remote had functions for fan speed, light on/off and dimmer. The built in buttons and sliders in the cayenne dashboard allow me to use all functionality of the old remote, plus I can set the dimmer level to a specific value right away, rather than having to look at the light while I adjust it. Furthermore, this all fits inside the old remote housing! I opted to add a barrel connector to the bottom for power, so when “docked” it works as either a physical remote or wifi-connected remote, and when unplugged the physical remote still works due to the internal 9v battery.
Step 1: Hardware Assembly
Taking a look at the guts of the remote, when the buttons are pressed they close a connection between +6v and ground. A transistor can do the same thing, but controlled from a low voltage source such as the esp8266 microcontroller. Soldering to the buttons is very easy since they all have open contacts. There is enough room in the back of the remote that I decided to be lazy and just insulate everything and squish it together. Some sort of primitive circuit board would have looked much better, but since this is completely sealed I'm not worrying about it too much. Everything was wired right on the first try- a huge relief because I'm on a rushed schedule to finish this before the end of October deadline of the Cayenne project prizes. The 9V female barrel connector supplies power to the ESP8266 and almost looks like it was meant to be there.
Step 2: Software - Cayenne and Arduino
Cayenne makes it really easy to connect arduino GPIO to the internet through a nice visual interface they call the dashboard. For this project I used two sliders to control fan speed and dimmer settings, and a button to control light on/off. One complaint is that the sliders do not have the correct range on the mobile app.
The arduino sketch is very simple and just deals with the inputs from the cayenne dashboard. For the light on/off and fan control, I am just controlling the HIGH/LOW behaviour of the GPIO pins. The dimmer is a bit more complicated because it is normally adjusted by long-pressing the on/off button on the remote. Cayenne does not have this functionality so instead the arduino has to keep track of the current dimmer level and calculate how long the pin should be pulled HIGH to reach the next desired brightness. As usual with the ESP8266 boards, I am using the OTA method to upload to them as it allows me to modify the code even once it's installed in the remote.
Step 3: Final Product
Everything fits back in the old case, and we are done. I had a good time building this and didn't run into any hiccups. The next step is to add physical esp8266 clients that can work as remotes without the need for a phone nearby.
Thanks for reading and check out my other projects on instructables or https://hackaday.io/dpeters
We have a be nice policy.
Please be positive and constructive.