Introduction: How to Use ESP32 to Control LED With Blynk Via WiFi

This tutorial is going to use ESP32 development board to control LED with Blynk via WiFi. Blynk is a Platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. It is a digital dashboard where you can build a graphic interface for your project by simply dragging and dropping widgets. It is also can linked to the Internet over Wi-Fi, Ethernet or Bluetooth.

For details of this module, you may refer to here.

Step 1: Pin Definition

Step 2: Material Preparation

For this tutorial, we require these items:

  1. Arduino NodeMcu IoT ESP32 WiFi & Bluetooth Development Board
  2. LED
  3. Blynk App in Android or iOS apps

Step 3: Pin Connection

In this tutorial, connect LED's anode to ESP32's p21 and LED's cathode to ESP32's GND.

Step 4: Setting Up Blynk App

1. Download blynk apps from Play Store or App Store.

2. After download is done, open the apps and create an account. If you already create an account, you may log in.

3. After you successful create an account, start by creating a new project.

4. Create a project name and choose device by ESP32 Dev Board and choose connection type by WiFi.

5. After press "Create" button, a window will pop up "Auth token was sent to....". You can open your email to check your authentication key.

6. Then, tap anywhere on the canvas to open the widget box. All the available widgets are located here. Now choose a button.

7. Tap on the widget to change the setting. Select the LED pin to Digital- gp21 and mode select to switch.

8. When you are done with the setting, press the PLAY button. This will switch you from EDIT mode to PLAY mode where you can interact with the hardware. While in PLAY mode, you won’t be able to drag or set up new widgets, press STOP and get back to EDIT mode.

Step 5: Sample Source Code

For this tutorial, it is necessary to download and install the Blynk library from here. This library is enable ESP32 can connect with Blynk.To be able to interface the ESP32 with Blynk, you will have to download this library and save it into your Arduino's libraries files. Then, download this sample source code and change the auth token by check your email and copy it to the coding.

Step 6: Results

Based on the result, the LED will turn on or off when you switch the button on the Blynk app. When you open the serial monitor on Arduino, it will shows out connected to WiFi and the Blynk logo as the diagram below.

Step 7: Video

This video shows the demonstration of the tutorial for the use ESP32 to control LED with Blynk via WiFi.