Course Content
IoT Engineering Course using ESP32 with 12 Real-World Projects

📡 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 "Your_Template_ID"
#define BLYNK_TEMPLATE_NAME "SmartParking"
#define BLYNK_AUTH_TOKEN "Your_Auth_Token"

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

char ssid[] = "YOUR_WIFI_NAME";
char pass[] = "YOUR_WIFI_PASSWORD";

BlynkTimer timer;

// -------- IR Sensors --------
int ir1 = 14;
int ir2 = 27;
int ir3 = 26;
int ir4 = 25;
int ir5 = 33;

// -------- Ultrasonic --------
#define TRIG 4
#define ECHO 5

// -------- Servo --------
Servo gateServo;
int servoPin = 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 (slot1 == HIGH) available++;
if (slot2 == HIGH) available++;
if (slot3 == HIGH) available++;
if (slot4 == HIGH) available++;
if (slot5 == HIGH) available++;

// Send slot data
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
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);

duration = pulseIn(ECHO, HIGH);
distance = duration * 0.034 / 2;

if (distance < 15) {

if (available > 0) {
gateServo.write(90);
Blynk.virtualWrite(V6, "Gate Open - Slots Available");
delay(3000);
gateServo.write(0);
}
else {
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.attach(servoPin);
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.”

Scroll to Top