π 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