πŸ“˜ Lesson 1.5 – Blynk Integration & Mobile Control Setup


🎯 Lesson Objective

In this lesson, students will learn:

  • How to fully set up the Blynk IoT platform
  • How to connect ESP32 with Blynk Cloud
  • How to design a mobile control dashboard
  • How to send commands from mobile to ESP32

By the end of this lesson, students will be able to control a robot using their smartphone over the internet.


πŸ“± What is Blynk IoT?

Blynk is a powerful IoT platform that allows you to:

  • Control hardware remotely
  • Build mobile apps without coding
  • Communicate with ESP32 over the internet

πŸ‘‰ It works as a bridge between your mobile phone and ESP32


πŸ”„ How Blynk System Works

Mobile App β†’ Blynk Cloud β†’ ESP32 β†’ Robot

  1. User presses a button in the app
  2. Command goes to Blynk Cloud
  3. ESP32 receives command via WiFi
  4. Robot performs action

πŸ› οΈ COMPLETE BLYNK SETUP (STEP-BY-STEP)


πŸ”Ή Step 1 – Install App

  • Download Blynk IoT from Play Store
  • Open the app

πŸ”Ή Step 2 – Create Account

  • Sign up using email
  • Verify email
  • Login to dashboard

πŸ”Ή Step 3 – Create Template

  1. Click on β€œDeveloper Zone”
  2. Click β€œNew Template”
  3. Fill details:
  • Template Name β†’ WiFi Robot
  • Hardware β†’ ESP32
  • Connection Type β†’ WiFi

πŸ‘‰ Click Create


πŸ”Ή Step 4 – Add Datastreams (VERY IMPORTANT)

Go to Datastreams β†’ New Datastream β†’ Virtual Pin

Create the following:

Name Virtual Pin Type
Forward V0 Integer
Backward V1 Integer
Left V2 Integer
Right V3 Integer

πŸ‘‰ Set:

  • Min = 0
  • Max = 1

πŸ”Ή Step 5 – Create Device

  1. Go to Devices
  2. Click New Device
  3. Select From Template
  4. Choose your template
  5. Click Create

πŸ”Ή Step 6 – Get Auth Token

  • Open your device
  • Copy Auth Token

πŸ‘‰ This will be used in ESP32 code


πŸ”Ή Step 7 – Create Mobile Dashboard

  1. Open Blynk mobile app
  2. Select your device
  3. Click Edit Dashboard

πŸ”Ή Step 8 – Add Buttons

Add 4 Button Widgets:

Button 1:

  • Name: Forward
  • Datastream: V0
  • Mode: Switch

Button 2:

  • Name: Backward
  • Datastream: V1
  • Mode: Switch

Button 3:

  • Name: Left
  • Datastream: V2
  • Mode: Switch

Button 4:

  • Name: Right
  • Datastream: V3
  • Mode: Switch

πŸ”Ή Step 9 – Save Dashboard

  • Click Save
  • Exit edit mode

πŸ’» ESP32 Code for Blynk Connection

Β 
#define BLYNK_TEMPLATE_ID “YourTemplateID”
#define BLYNK_TEMPLATE_NAME “WiFi Robot”
#define BLYNK_AUTH_TOKEN “YourAuthToken”

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>

char ssid[] = “YourWiFiName”;
char pass[] = “YourPassword”;

void setup() {
Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}

void loop() {
Blynk.run();
}

Β 

πŸ” Understanding Virtual Pins

  • Virtual Pins (V0, V1, etc.) are software pins
  • They send values from app to ESP32
  • Example:
    • Button ON β†’ sends 1
    • Button OFF β†’ sends 0

πŸ§ͺ Practical Activity

  1. Upload code to ESP32
  2. Open Serial Monitor
  3. Open Blynk app
  4. Press buttons

πŸ‘‰ Observe:

  • ESP32 connects to Blynk
  • Device status becomes Online

🧠 Key Learning Concepts

  • Cloud-based IoT control
  • Mobile app interface design
  • Virtual communication (no physical wires)
  • Real-time device interaction

⚠️ Common Issues & Solutions

Problem Solution
Device Offline Check WiFi connection
Wrong Auth Token Copy correct token
Buttons not working Check Virtual Pins
Not connecting to Blynk Check internet

πŸ”§ Troubleshooting Tips

  • Keep internet stable
  • Restart ESP32 if needed
  • Re-upload code if error occurs
  • Check Template ID and Auth Token carefully

πŸ“ Lesson Summary

In this lesson, students learned how to fully set up the Blynk platform, create a mobile dashboard, and connect ESP32 to control hardware over the internet.


πŸ“Œ Practice Task

  • Add one extra button (Stop)
  • Change Virtual Pin and test
  • Try renaming buttons