This article mainly focused on explaining how to sync the IR signal with the virtual pins. I will also give you the component used, the schematic used and changes made from the original v2 circuit.

Here is the latest video showing the IR implementation of the ESP8266 lamp:

Background

About a year ago, I have decided that I wanted to make an electronics project to train my skills. I wanted to make a project that I will be able to use on a daily basis. I then decided to make a LED Lamp and have it controlled via WiFi, mainly for the reason of:

I wanted a Lamp with 2 color temperature (Warm and Neutral)

Interested in making a project using an ESP8266 chip and Blynk API

Be able to control the lamp from my bed 😉

By June, I have made the LED Panel and a NodeMCU based controller. (Link to the first post on Imgur, and Reddit).

But about that time, I have realized that to make the controller more compact by using a smaller buck converter and a generic ESP8266 module (ESP-12E) to reduce the size and allows the NodeMCU to be used in other projects.

Reddit discussion of the video.

I also wanted to add an IR receiver as a backup control and a PIR. But until now, I am only able to implement the IR Reciever.

Hardware

I feel that I should give a little bit more detail regarding the hardware before giving the code

The component chosen are:

ESP-12E module

Mini 360 Buck Converter module

5 x 10K resistor 5%

3 x 1K resistor 5%

2 x 68 Ohm resistor 5% (0.5 W)

330 Ohm resistor 5%

1K trimmer

100nF Film Capacitor

2 x 47uF 25V Electrolytic Capacitor

1000uF 6.3V Electrolytic Capacitor

220uF 10V Electrolytic Capacitor

3mm Green LED

6-Pin Female Header

2 X 3-Pin Female Header

2 X IRFZ44N N-MOSFET

2 X BC337 Bipolar transistor

2.5mm Power Jack

And here is the schematic of the Lamp Controller (EasyEDA link here)

When using the new controller, I found some problem with the initial design.

Originally, the IR Reciever is connected to GPIO16. However, It appears that the pin can only be used for a simple digital input or output, not a series of pulses. Hence, I changed it to GPIO 5.

IRFZ44N has VGS of 4V. While the transistor can be turned on with the 3.3V signal from the ESP-12E module, it is not fully saturated. I have decided to use a BJT to drive the MOSFET. However, I have decided to use a 68-ohm resistor, which resulted in a lot of heat when the LED is off. I have reduced the heat by lowering the buck converter output to 5V. But, a better solution might be using a MOSFET driver, using IRLZ44N, or just using a slightly higher resistance value.

Otherwise, the controller still functions as expected despite the changes and different component used.

Arduino Code

Here below is the code I use. Github link to the .ino file here.

(20 October 2018 Update)

This is just a short update after using this new board for almost 3 months. During that time, the lamp controller is only switched off about 3 times.

The first was to tune the buck converter, as mentioned before.

The second one is to test the PIR sensor to automatically switch it on when I woke up in the middle of the night. I, unfortunately, has taken out the PIR sensor due to an unreliable algorithm I wrote for motion detection

The third is by accident when I was cleaning my room.

I am currently working on integrating Google Assitant to control the lamp. I am able to find a way to make it work using HTTP request and IFTTT. However, I do need some time to refine it.

(22 December 2018 Update)

After the exam period, I have made some modification to the code (GitHub Link). This basically replaces the array list for brightness level with a function and adds a time delay function that allows the lamp brightness to be changed slowly, simulating a slowly dimmed lamp depending on the delay chosen. I have a range of 25 to 200 microsecond by default. I also finally can replicate the sunrise/sunset function by changing the delay to 40000 microseconds via the “Eventor” widget in Blynk.

If you want more detail, you can ask me at the Reddit discussion here

I am hoping to be able to update every time I add some feature to the lamp.

Thank you for reading.