In today’s post, we will design an IoT light bulb that can be remotely controlled from anywhere in the world. This project would convert an electrical A.C. light bulb to a smart bulb step by step using the ESP32 CAM, Arduino and Blynk app. After reading this tutorial post, you will learn how to control an AC light bulb via the Internet of Things (IoT) using the Blynk app and ESP32-CAM WiFi Development Board. Make sure you read all the way through to the end to fully comprehend it.
For this project we are going to be needing the following modules/components:
The circuit diagram shown above used the TIP41C NPN transistor to form a common emitter follower configuration. The 5V solid state relay is turned on and off without a based transistor since the ESP32-CAM dev board has a maximum out put voltage of 3.3V.
Two LEDs were connected in the circuit to show a blink without delay and also to visualize when the 5V relay is turned on and off from the Blynk app. These were tested without no current limiting resistors and they worked just fine. The PCB socket was used to connected the electrical wire plug. All Neutral lines were connected together. While the live line was controlled by the 5V solid state relay output. This is shown in the second breadboard schematic below.
The circuit diagram above works but we recommend using a method to control the 5V solid state relay to be in a two stable states, either ON or OFF; a transistor logic level inverter be created. This comprised of two 220kΩ resistor and a 10kΩ resistor configured around an NPN transistor. The setup of this logic level shifter is to convert the 3.3V HIGH on the ESP32 CAM GPIO pin to 0V and the 0V LOW to 5V.
This was noticed practically that when switching DC voltage using the 5V solid state relay, the HIGH voltage won’t be enough when using boards like ESP32, ESP32 CAM, ESP8266, Raspberry pi etc. To know more about the calculations used for this simple logic level shifter follow this link.
The ESP32-CAM development (dev) board was placed on the breadboard so that it can control the TIP41C NPN transistor through the base resistor 10kΩ. We attached the dev board to the breadboard and used the preformed jumper wires to finish off the rest of the connection between the transistor and the 5V solid state relay.
The 5V power needed for this bread setup was drawn from the programming CH340 adapter. The 5V of the ESP32-CAM is connected to the Vcc pin on the CH340 adapter; this is how the ESP32 Cam is connected. The emitter of the Transistor must have a common ground (GND) with the ESP32 Cam.
When working with alternating current (AC) voltages, care must be taken to avoid electric shocks. The best way to control the flow of AC voltage through the socket outlet is to use the PCB socket header and terminate the wires carefully.
Strip off/Peel off the insulation AC wire terminals to expose the Live and Neutral wires to source the AC voltage to the PCB header. Screw and terminate these AC cables to the PCB header socket and ensure they are tight and firm.
Open the lamp holder cover and safely attach the Live and Neutral cable. Ensure they are tight and firm.
Use the 5V solid state relay to interrupt the AC Live (L) wire. This is shown in the schematic and breadboard diagram above. The remote control would talk to the ESP32-CAM development board and it will talk to the 5V solid state relay and tell it when it should turn on the AC bulb.
Connect the rest of the wires to the 5V solid state relay as shown in the circuit diagram above, ensuring that all the Neutral lines (wires) are connected together.
Use insulation tape to insulate and isolate all exposed AC voltage wires joined together. This will reduce the electric shock when the system is powered.
Open the respective app store for your device and find Blynk legacy. Please get the Blynk legacy version because that was used for this project. If you are unable to use this version, please leave a comment in the section below so that we can tell you how to use the most recent version of the Blynk IoT app for this IoT light bulb – Remote Control Light Bulb Blynk App project.
We installed the app on our android or iPhone device as shown in the picture above.
After successful installation, we signed up or signed since we already have an account and click on New Project as shown below.
After setting the name of the project, we selected our device type, and clicked create.
We went to our mailbox or alternatively our Blynk dashboard to copy the token. This would be used in the Arduino code later.
We clicked on the add button on the upper right side and add the button widget. Configure this button widget by clicking on it and selecting where the virtual pin is selected.
This was saved and it was done.
We removed the ESP32-CAM from the breadboard and placed it onto the ESP32-Cam programmer adapter. We connected the USB flex to the port of the programmer. The programmer used a type B USB flex to its USB programmer as shown here below. This was connected this cable to our PC, the power LED on the programmer came on. We opened the Arduino IDE and copied the code below and compiled it successfully.
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
//int led_gpio = 13;
#define Authorization_key "CjMXMZ3xjcbpG7gtnSPTFisJFkJ3WxF9" //EExmWR-3B8jC7H0ttOzr9qmtAciGW8DR
#define SSID "AncII" // replace with your SSID
#define Password "eureka26" //replace with your password
void setup() {
//pinMode(led_gpio, OUTPUT);
Serial.begin(115200);
delay(10);
WiFi.begin(SSID, Password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Blynk.begin(Authorization_key,SSID,Password);
}
void loop(){
Blynk.run();
}
The Arduino sketch given above began with including the various libraries from Blynk and WiFi connectivity; The Authentication Key was inserted from the email sent by Blynk after creating the project; so was the Internet WiFi USSID and Password too from an existing network with good internet access.
Once these are all set, we select our port number, select AI thinker ESP32-Cam as the development board then upload code.
With the complete setup done, we have the following testing results as shown here.
The button on the phone would allow us to turn the AC light bulb into a smart AC light bulb. We can turn it on and off remotely from anywhere around the globe.
Once we are connected to the internet, the setup works nicely; as expected!
The project was aimed at using IoT to control an AC light bulb via a mobile app. We have successfully shown that we can convert the traditional AC light bulb to smart light bulb with ESP32 CAM, Arduino, and the Blynk app. Do you think you can do the same or even more than this? Kindly let us know by commenting below. Also, if you have any questions, leave us a message in the comment section or on our WhatsApp handle or telegram group.
Don’t forget to share this post if you like it. You can read the next post on:
See you on the next post.
Thank You.
In the ever-evolving landscape of modern agriculture, artificial intelligence (AI) is emerging as a game-changing…
The Internet of Things (IoT) is reshaping the way we live, work, and produce goods.…
Introduction Have you ever wondered how some manufacturing industries consistently deliver high-quality products while minimizing…
In the ever-evolving landscape of modern agriculture, the integration of Internet of Things (IoT) technology…
Introduction Have you ever imagined diagnosing equipment issues without even being on-site? Welcome to the…
In the ever-evolving world of manufacturing, staying competitive means adopting innovative solutions to optimize every…
This website uses cookies.