LED Controlled Lamp A step-by-step DIY helping you in automating your home.
Home Automation is a new field that is growing rapidly. You can automate anything in your house and control it remotely. This gives you statistics on usage and gives you access to your house while you are away to control your heater, coffee machine, and the lightning.
In this small project, I will be controlling an LED lamp through WiFi. This will be a small step that will help you learn the basics of home automation. After completing this project, you will be able to just remove your old filament lamps and replace them with LED lamps that can be controlled remotely from anywhere, all while saving energy.
The next step will be a guide that will help you control anything you want in your house. The theme over here is baby steps that will eventually give you the enough qualification to fully automate your home.
In this DIY, we will be controlling an LED lamp using an ESP8266 Node MCU WiFi module. We will program it using the Arduino IDE.
1- LED Lamp
2- ESP8266 NODEMCU WiFi Module
3- IRF520 Transistor
4- Step up converter
5- 5V old phone charger
You have to know how much voltage does your LED Lamp require to operate, so you would get the step up converter that is needed. Mine required somewhere around 55 V. It was a cheap Chinese lamp that had a huge variation in the voltage, but I was able to make it work with the 60 V step up converter.
You should use the phone charger to provide you with the 5V required to operate the NODEMCU. You can directly connect it to the micro USB port on the NODEMCU. At the same time, you need to take the 5V and connect them to the step up converter to provide the LED Lamp with the juice it needs.
“A boost converter (step-up converter) is a DC-to-DC power converter steps up voltage (while stepping down current) from its input (supply) to its output (load).” –Wikipedia
So what happens is that even though you get the voltage you need, you would get a not so little current drop. So before you start, make sure to choose an LED lamp that does not require a high current. I made that mistake, so the brightness of my lamp was not so high.
So back to the actual work.
Open the case of the charger, and make sure not to cut the micro usb cable, but you would still need to make it shorter. Solder a wire to the positive output and another cable to the negative output of the charger. Those cables should go directly to the step up converter.
Now Solder a wire to the positive output of the converter and another to the negative output. Now you should use the following schematics to connect them with the transistor, the Node MCU and the lamp.
You now are almost done with the hardware. We should get into the software.
First of all, you need the Arduino IDE.
You can get it from here: https://www.arduino.cc/en/Main/Software
Connect the NodeMCU to your computer.
Go to File → Preferences
Paste the following link into the Additional Boards Manager URLs
Then go to TOOLS → Boards → Boards Manager
Install your version of the Wifi Module.
Use the following Code:
(File Wifi LED Code)
This code controls 4 pins on the NodeMCU. I am not an expert in the Wifi coding, so I kept it the way I found it on:
Don’t forget to change the baud rate, that works for your module, and don’t also forget to change the SSID and the PASSWORD for the network that you are using.
Once you upload the code, it will give you an IP address in the serial Monitor screen. Open that IP address while connected to your local WiFi network, and you will be able to see the 4 buttons.
Using the following map, you will be able to connect more devices in the future to the same NodeMCU module. But for this application, I used the pin D7, which translates to pin 13 in the Arduino IDE.
You are almost done. This step varies depending on what you want your package to look like. I 3D printed an extension to my LED lamp, because the parts did not fit in the original case.
This is what my final product looked like. You should just put everything inside the package, and you are done. Just plug it in the lamp socket, and open your IP address to control it.