How to Use ESP32 to Control LED With Blynk Via WiFi




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.

Be the First to Share


    • Electronics Contest

      Electronics Contest
    • Origami Speed Challenge

      Origami Speed Challenge
    • Tinkercad to Fusion 360 Challenge

      Tinkercad to Fusion 360 Challenge



    Question 2 years ago on Introduction

    I'm also trying to SSH into my ESP32 WROOM chip. I'm able o gett it to work with Atom IDE and PyMakr after many months of work, getting around their bugs. But since the ESP32 has built in WIFI, can't I just SSH into it, instead of using REPL, or ESPtools?

    Surely by now, people should realize that by now, having an SSH Server on the ESP32 chip would be really advantageous. Especially in field testing, where I can have an SSH client on my iPad or iPhone, and to be able to SSH into the ESP32 via it's built in WIFI, will make it far easier for me to do "Field tests".

    Also, my Mac, running Atom IDE is constantly in the repair shop due to intermittent problem we've never been able to pin down.

    I'm using the Pythonista 3 app on my iPad, I haven't yet discovered it's features yet, but hoping it has the ability to edit iCloud or Google Doc files, but if they had a SSH feature built in, I could have a decent way of doing field tests while in the field without having to bring my Laptop, because it's also going to have to connect to the internet.

    The ESP32 already has WAN access via Wifi, so should be able to host MicroWebSrv plus an SSH server, right?

    Has anyone developed a MicroPython SSH server yet? And if so, how do I get it on the MicroPython running on the ESP32.

    If not, I would like to see if I can collect a few volunteers to help me write a SSH Server to run on MicroPython. I know of REPL, and a little how to use it, but I've never tried to get it to run through the built in WIFI yet.

    Is there a forum where I can ask for help?

    John D


    Question 2 years ago on Step 7

    This worked fine all the way to the end but Blynk can't see my ESP32. It's a HiLetgo ESP32 WROOM 32. My phone is connected to the internet and so is the ESP32 but they can't seem to communicate. It appears there is a problem after the ESP has connected to my network then tries to communicate with Blynk and it doesn't. Below is the COM outputt when I run your script with the Auth code my SSID and PW. Any Thoughts


    3 years ago

    My code is like this:

    #define BLYNK_PRINT SwSerial
    #include <SoftwareSerial.h>
    SoftwareSerial SwSerial(10, 11); // RX, TX
    #include <BlynkSimpleStream.h>
    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "6b3f585f3b784db6bb1027f6ef724b56";
    void setup()
    // Debug console
    // Blynk will work through Serial
    // Do not read or write this serial manually in your sketch
    void loop()
    // You can inject your own code or combine it with other sketches.
    // Check other examples on how to communicate with Blynk. Remember
    // to avoid delay() function!


    3 years ago

    Hai mybotic
    Why it shows wasn't online yet on Blynk App? I tried with esp32. I could upload the sketch, but on my mobile wsn't online yet.


    4 years ago

    Non riesco provare il progetto per il seguente errore :

    C:\Program Files (x86)\Arduino\libraries\Blynk\src/BlynkSimpleEsp32.h:15:2: error: #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.

    #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.