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

esp32blynk

Components Required

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

Circuit Diagram

LED-IoT

  • 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.
  5. Check the email inbox and find the Auth Token.
  6. Download the latest version of Blynk library for Arduino it will be a zip file.
    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>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
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();
}
Spread the love, share this