experiment 5
experiment 5
Aim: To demonstrate how to remotely switch lights on and off using the NodeMCU
(ESP8266) and control it via cloud platform.
Components Required:
1. NodeMCU (ESP8266)
4. Jumper wires
5. Breadboard (optional)
8. WiFi connection
Theory:
Procedure:
1. Hardware Setup:
- Power for Light Bulb/LED: Connect a separate power supply through the relay.
- Go to `File -> Preferences`, and in the "Additional Boards Manager URLs", paste
this URL: `http://arduino.esp8266.com/stable/package_esp8266com_index.json`.
- In the Arduino IDE, go to `Sketch -> Include Library -> Manage Libraries` and
search for Blynk. Install the library.
- You can either use Blynk (cloud platform) or set up a local web server for remote
control.
Code:
#include <BlynkSimpleEsp8266.h>
void setup() {
Serial.begin(115200);
pinMode(relayPin, OUTPUT);
// Connect to Blynk
void loop() {
BLYNK_WRITE(V1) {
} else {
5. Upload Code:
- In the Arduino IDE, select the NodeMCU 1.0 (ESP-12E Module) under `Tools ->
Board`.
- For Blynk: Open the Blynk app on your smartphone, create a project, add a button
widget linked to Virtual Pin V1, and test the control.
- For Web Server: Connect your phone or computer to the same network and open
the NodeMCU's IP address in a web browser (check the IP address printed in the Serial
Monitor).
Results: In the Blynk app, pressing the button widget will turn the relay (and hence
the light) on and off. The output of the system will be the successful toggling of a light
or LED, demonstrating the ability to switch a light on/off remotely using NodeMCU.