After having the Wifi RGB Controller from my previous blog post for a few months, I’ve wanted to control a new LED strip as kitchen lighting. This time I did not used the H801, but decided to order the parts and build myself a Wifi LED Dimmer using the ESP8266.
This dimmer uses a Mosfet to control a warm white LED Strip using PWM (Pulse Width Modulation). To use it via wifi I’ve copied most of the source code from the RGB Controller.
For this dimmer I’ve ordered the following parts:
We start off with the ESP8266. This wifi enabled microcontroller will be having the software to control the LED’s. It has to be powered with 3.3V, and I wanted to use the 12V supply from the LED strip, so I’ve used a step-down converter (don’t forget to set it to 3.3V before connecting). On the GPIO pin of the ESP8266, I connected a MOSFET to create the PWM signal. It is capable of switching quite a lot of Amperes and it is fast. I found out it get’s quite hot while doing this. So I will be ordering some heatsinks to cool it down and extend the lifetime.
The following circuit describes how I’ve connected the parts:
As a first test, and to be able to program and debug the software, I’ve connected the parts on a breadboard. I’ve used a single parts of the LED strip to be able to see the results directly.
To program the ESP8266, I use the same USB FTDI programmer that I use for my Arduino projects. I also use the Arduino IDE, as explained in the blog post about the RGB Controller. The TX, RX and Ground of the FTDI are connected to the ESP8266. When I’m ready to write some code to the ESP8266, I connect the GPIO0 port to Ground, and reset the device manually right before the Arduino IDE writes the code, by connecting the Reset pin of the ESP8266 to Ground for a second and releasing it.
As mentioned earlier in this post, I’ve based the software on the ESP8622 RGB Controller I’ve created earlier. So the usage of this dimmer is in the same way, the ESP8266 acts as a webserver. At the bottom of this post you can find the software I wrote for this device. The code connects the device to the specified wifi network, and start a webserver on the IP it gets from the DHCP server (this IP is printed to the serial upon boot). Using a simple http call to the device on http://192.168.0.xx/led/0 it is possible to send a 0-100 number and let the leds dim to this value. The code also uses some logic to include a nice fade effect between changes.
I’ve included a video below to show the result. In this video I’ve used a script on my PC to make a call to the LED Dimmer’s webserver every 2 seconds, and change it to a different value (0,40,70,100).
I’m planning to include this into my home automation controller and will post an update on how I did it once it’s finished.
Update: A new post is available to control this LED Dimmer using OpenHAB.
eryk February 12, 2016
Posted In: ESP8266