π‘ Smart Parking System β Home WiFi Mode ( Blynk )
β
Connect to Internet
β
Send parking data to Blynk Cloud
β
Show live slot status on mobile
β
Show total available slots
β
Control gate automatically
1οΈβ£ Blynk IoT Setup (Step-by-step)
2οΈβ£ Datastream Configuration
3οΈβ£ Dashboard Setup
4οΈβ£ Complete ESP32 Code
5οΈβ£ Full Code Explanation
π PART 1 β BLYNK IOT SETUP
Go to:
π https://blynk.cloud
Login / Sign Up
π£ Step 1: Create Template
Click New Template
Fill:
-
Template Name β SmartParking
-
Hardware β ESP32
-
Connection Type β WiFi
Click Create.
π£ Step 2: Create Datastreams (Very Important)
Go to:
Template β Datastreams β New Datastream β Virtual Pin
Create these:
πΉ V0 β Total Available Slots
-
Name β Available Slots
-
Virtual Pin β V0
-
Data Type β Integer
-
Min β 0
-
Max β 5
-
Save
πΉ V1 β Slot 1 Status
-
Name β Slot1
-
Virtual Pin β V1
-
Data Type β Integer
-
Min β 0
-
Max β 1
(1 = Available, 0 = Occupied)
πΉ V2 β Slot 2 Status
Same as above
Virtual Pin β V2
πΉ V3 β Slot 3 Status
Virtual Pin β V3
πΉ V4 β Slot 4 Status
Virtual Pin β V4
πΉ V5 β Slot 5 Status
Virtual Pin β V5
πΉ V6 β Parking Message
-
Name β Parking Status
-
Virtual Pin β V6
-
Data Type β String
π£ Step 3: Create Device
Go to:
Devices β New Device β From Template
Select SmartParking template
Device Name β Parking_01
Click Create.
π£ Step 4: Copy Credentials
Open Device β Device Info
Copy:
-
BLYNK_TEMPLATE_ID
-
BLYNK_TEMPLATE_NAME
-
BLYNK_AUTH_TOKEN
You will paste them in code.
π± PART 2 β BLYNK MOBILE DASHBOARD SETUP
Open Blynk IoT App.
Select your device.
Add Widgets:
π’ Widget 1: Gauge (Total Slots)
-
Virtual Pin β V0
-
Range β 0 to 5
π’ Widget 2β6: LED Widgets (Slot Status)
Add 5 LED widgets:
-
Slot1 β V1
-
Slot2 β V2
-
Slot3 β V3
-
Slot4 β V4
-
Slot5 β V5
Green = Available
Red = Occupied
π‘ Widget 7: Label (Parking Message)
Virtual Pin β V6
Now dashboard is ready.
π» PART 3 β COMPLETE ESP32 CODE (Blynk IoT Version)
Install libraries first:
Sketch β Manage Libraries β Install:
-
Blynk
-
Servo (if not installed)
#define BLYNK_TEMPLATE_ID "TMPL3dZSykeR9"
#define BLYNK_TEMPLATE_NAME "parking system"
#define BLYNK_AUTH_TOKEN "eZxTaLBVerEHslZe6VB5XEEi_Vg3iEw0"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <ESP32Servo.h>
char ssid[] = "NextGen";
char pass[] = "12345678";
BlynkTimer timer;
// IR Sensors
#define IR1 14
#define IR2 27
#define IR3 26
#define IR4 25
#define IR5 33
// Ultrasonic Sensor
#define TRIG 4
#define ECHO 19
// Servo
Servo gateServo;
#define SERVO_PIN 18
long duration;
float distance;
void sendData()
{
int available = 0;
int slot1 = digitalRead(IR1);
int slot2 = digitalRead(IR2);
int slot3 = digitalRead(IR3);
int slot4 = digitalRead(IR4);
int slot5 = digitalRead(IR5);
// If IR sensor HIGH means slot empty
if (slot1 == HIGH) available++;
if (slot2 == HIGH) available++;
if (slot3 == HIGH) available++;
if (slot4 == HIGH) available++;
if (slot5 == HIGH) available++;
// Send to Blynk
Blynk.virtualWrite(V0, available);
Blynk.virtualWrite(V1, slot1);
Blynk.virtualWrite(V2, slot2);
Blynk.virtualWrite(V3, slot3);
Blynk.virtualWrite(V4, slot4);
Blynk.virtualWrite(V5, slot5);
// Ultrasonic Distance
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
duration = pulseIn(ECHO, HIGH);
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.println(distance);
if (distance > 0 && distance < 15)
{
if (available > 0)
{
gateServo.write(90);
Blynk.virtualWrite(V6, "Gate Open - Slots Available");
delay(3000);
gateServo.write(0);
}
else
{
gateServo.write(0);
Blynk.virtualWrite(V6, "Parking Full - Gate Closed");
}
}
}
void setup()
{
Serial.begin(115200);
pinMode(IR1, INPUT);
pinMode(IR2, INPUT);
pinMode(IR3, INPUT);
pinMode(IR4, INPUT);
pinMode(IR5, INPUT);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
gateServo.setPeriodHertz(50);
gateServo.attach(SERVO_PIN, 500, 2400);
gateServo.write(0);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(2000L, sendData);
}
void loop()
{
Blynk.run();
timer.run();
}
π§ FULL CODE EXPLANATION
1οΈβ£ Template Credentials
These connect ESP32 to Blynk Cloud.
Without them β Device will not connect.
2οΈβ£ BlynkTimer
We use timer instead of delay() because:
Blynk needs continuous communication.
Delay blocks cloud communication.
3οΈβ£ sendData() Function
Runs every 2 seconds.
It:
-
Reads IR sensors
-
Counts available slots
-
Sends data to virtual pins
-
Checks ultrasonic
-
Controls gate
-
Sends status message
4οΈβ£ Virtual Pins
V0 β Total available slots
V1βV5 β Individual slot status
V6 β Parking message
π What You Will See in App
When slots available:
Gauge β 3
LEDs β Some ON (green)
Label β Gate Open – Slots Available
When full:
Gauge β 0
All LEDs OFF
Label β Parking Full – Gate Closed
π Viva Explanation
“In this version, ESP32 connects to WiFi and communicates with Blynk Cloud. Each parking slot status is sent to virtual pins. The mobile dashboard displays real-time slot availability. The ultrasonic sensor detects vehicles and the servo motor controls the gate. The system allows remote monitoring and smart city integration.”