๐ 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
- User presses a button in the app
- Command goes to Blynk Cloud
- ESP32 receives command via WiFi
- 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
- Click on โDeveloper Zoneโ
- Click โNew Templateโ
- 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
- Go to Devices
- Click New Device
- Select From Template
- Choose your template
- 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
- Open Blynk mobile app
- Select your device
- 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_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
- Upload code to ESP32
- Open Serial Monitor
- Open Blynk app
- 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