You are on page 1of 6

25/11/2021 14:10 WiFi controlled Light using ESP32 - openlabpro.

com

Products Learning Center My Account 

WiFi controlled Light using ESP32


ESP32 is a low power WiFi enabled microcontroller created and developed by Espressif
Systems. The ESP32 is an advanced IoT microcontroller board possessing WiFi and
Bluetooth Low Energy capabilities, as well as limited compatibility with the Arduino
Core.

This project demonstrating how to control light in our room remotely. So here we
controlling led with WiFi via Blynk. Blynk is a Platform with iOS and Android apps to
control Arduino, Raspberry Pi, and the likes over the Internet. It’s a digital dashboard
where you can build a graphic interface for your project by simply dragging and
dropping widgets.

The ‘Light controlling of ESP32 by WiFi ‘ project uses the ESP32 Development Board
will be used to blink an LED at a specific timed interval, continuously. It is the required
basic tutorial for any microcontroller board. And connect an LED to any of GPIO pin of
ESP32

https://openlabpro.com/guide/wifi-controlled-light-using-esp32/ 1/6
25/11/2021 14:10 WiFi controlled Light using ESP32 - openlabpro.com

Products Learning Center My Account 

Components Required
ESP32 development board
5mm LED
1KΩ Resistor
3 pieces of jumper wires
Breadboard
Smartphone

Circuit Diagram

https://openlabpro.com/guide/wifi-controlled-light-using-esp32/ 2/6
25/11/2021 14:10 WiFi controlled Light using ESP32 - openlabpro.com

Products Learning Center My Account 

Connect the positive pin (anode) of the LED, that indicated as the rounded edge of the
LED to pin IO2 on the ESP32.
Connect the negative pin (cathode) of the LED, indicated as the flat edge of the LED to a
1KΩ resistor.
And Connect the free end of the resistor to Ground

Blynk setup

Blynk is a Platform with iOS and Android apps to control Arduino, Raspberry Pi and
the likes over the Internet. It’s a digital dashboard where you can build a graphic
interface for your project by simply dragging and dropping widgets.

Blynk setup

1. Download Blynk app for Android or IOS


2. Create a new account in Blynk App.
3. Create a New Project. Then choose the board and connection you will use.
4. After the project was created, we will receive Auth Token over email.
https://openlabpro.com/guide/wifi-controlled-light-using-esp32/ 3/6
25/11/2021 14:10 WiFi controlled Light using ESP32 - openlabpro.com

5. Check the email inbox and find the Auth Token.


6. Download the latest version of Blynk library for Arduino it Products
will be a zipLearning
file. Center My Account 
1. Unzip it. You will notice that archive contains several folders and several libraries.
2. Copy all those files to respective folders (Note that libraries should go to libraries and
tools to tools)
7. To create our first example sketch code goto the Blynk Examples Sketch Builder
1. From there Choose the board (for example: Arduino UNO, ESP8266, ESP32 etc)
2. Then choose the connection (WiFi, Ethernet, Bluetooth, USB…)

Steps to create a project


1. To create our first example sketch code goto the Blynk Examples Sketch Builder
1. From there Choose the board as ESP32
2. Then choose the connection as ESP32 WiFi
3. Give the Auth token that was received in the Email
4. Select any of the Example code.
5. Finally, copy the example code and paste it in the Arduino IDE and change the SSID
and Password.
2. Now Flash the code to your hardware

Code Snippet
#define BLYNK_PRINT Serial

int pin = 2;

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

https://openlabpro.com/guide/wifi-controlled-light-using-esp32/ 4/6
25/11/2021 14:10 WiFi controlled Light using ESP32 - openlabpro.com

// You should get Auth Token in the Blynk App.

// Go to the Project Settings (nut icon).


Products Learning Center My Account 
char auth[] = "Your auth token key";

// Your WiFi credentials.

// Set password to "" for open networks.

char ssid[] = "Your network name";

char pass[] = "Your network password";

void setup() {

pinMode(pin, OUTPUT);

pinMode(pin, HIGH);

Serial.begin(115200);

delay(10);

Serial.print("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, pass);

int wifi_ctr = 0;

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(".");

Serial.println("WiFi connected");

Blynk.begin("Your auth token key", ssid, pass);

void loop(){

Blynk.run();

https://openlabpro.com/guide/wifi-controlled-light-using-esp32/ 5/6
25/11/2021 14:10 WiFi controlled Light using ESP32 - openlabpro.com

Spread the love, share this Products Learning Center My Account 

Embedded Design Platforms Learn – Online Courses, About Us 





(ARM/PIC/AVR/8051) tutorials and Example codes
Distributors & Resellers
Embedded Development Embedded Systems Courses
Boards ((ARM/PIC/8051) Affiliate Program
Internet of Things Courses
Embedded Basic Support
Development Kits
(ARM/PIC/8051) Help & FAQs

All-in-One IoT Development


Kit
Sensor Boards

Copyright © 2012 - 2019 Etiq Technologies, All Rights Reserved | Terms of Service | Privacy Policy | Legal Notices

https://openlabpro.com/guide/wifi-controlled-light-using-esp32/ 6/6

You might also like