How to Use ESP32 to Control LED With Blynk Via WiFi

14,731

55

3

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.

Share

    Recommendations

    • Tape Contest

      Tape Contest
    • Trash to Treasure

      Trash to Treasure
    • Arduino Contest 2019

      Arduino Contest 2019

    3 Discussions

    0
    None
    nala65113

    2 months 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
    SwSerial.begin(9600);
    // Blynk will work through Serial
    // Do not read or write this serial manually in your sketch
    Serial.begin(9600);
    Blynk.begin(Serial,auth);
    }
    void loop()
    {
    Blynk.run();
    // 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!
    }

    0
    None
    nala65113

    2 months 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.

    0
    None
    PaoloM51

    1 year 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.

    ^