The implementation includes Arduino (ESP32), RFID, Ultrasonic Sensor, Servo Motor, and a Web Dashboard that retrieves data from the Favoriot IoT platform.

Concept

This system uses RFID or ANPR (Automatic Number Plate Recognition) to detect vehicles entering and exiting a parking area. When a vehicle is detected, the boom gate opens automatically, and all entry/exit data is recorded in Favoriot IoT Platform for real-time monitoring and analysis.


Hardware Components

1. Required Hardware

  • ESP32 (or Arduino + ESP8266 WiFi Module) – Microcontroller for processing and connectivity
  • RFID Reader (RC522) / Camera for ANPR (OpenCV) – Vehicle identification
  • Ultrasonic Sensor (HC-SR04) – Detect vehicle under the boom gate
  • Servo Motor (MG995 / SG90) – Boom gate automation
  • LED and Buzzer – Indicators for access granted/denied
  • WiFi Module (ESP32 / ESP8266) – Sending data to Favoriot IoT Platform

2. Software & Cloud

  • Arduino IDE / Python (OpenCV for ANPR)
  • Favoriot IoT Platform – Cloud data logging
  • MySQL / Firebase – Vehicle tracking database
  • Web Dashboard (HTML, JavaScript, PHP) – Real-time monitoring UI

Step-by-Step Implementation

Step 1: Connect the Hardware

  1. Wiring Configuration:RFID (RC522) to ESP32 (SPI Communication)Ultrasonic Sensor (HC-SR04) to ESP32 (Trigger, Echo)
    • Servo Motor (PWM Pin) to ESP32
    • WiFi (Built-in ESP32) to send data to Favoriot
  2. Wiring Diagram:
  3. RFID (RC522)      → ESP32 (SPI Pins: MOSI, MISO, SCK, SDA)
  4. Ultrasonic Sensor → ESP32 (Trigger, Echo)
  5. Servo Motor       → ESP32 (PWM Pin)

Step 2: Code for ESP32 with Favoriot (RFID + Servo Motor)

The following code:

  • Reads RFID data
  • Sends data to Favoriot
  • Opens the boom gate if the vehicle is authorized
#include <WiFi.h>
#include <HTTPClient.h>
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>

// Define pins for RFID
#define SS_PIN  5
#define RST_PIN 0
MFRC522 mfrc522(SS_PIN, RST_PIN);

// Define WiFi credentials
const char* ssid = "Your_WiFi_Name";
const char* password = "Your_WiFi_Password";

// Define Favoriot API endpoint
const char* favoriotURL = "https://apiv2.favoriot.com/v2/streams";
String apiKey = "YOUR_FAVORIOT_API_KEY";

// Servo for boom gate
Servo gateServo;

void setup() {
    Serial.begin(115200);
    SPI.begin();
    mfrc522.PCD_Init();

    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
        Serial.println("Connecting to WiFi...");
    }
    Serial.println("WiFi Connected");

    gateServo.attach(9);
    gateServo.write(0); // Boom gate closed
}

void loop() {
    if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {
        return;
    }

    // Get RFID tag ID
    String rfidID = "";
    for (byte i = 0; i < mfrc522.uid.size; i++) {
        rfidID += String(mfrc522.uid.uidByte[i], HEX);
    }
    Serial.println("RFID Detected: " + rfidID);

    // Send data to Favoriot
    sendDataToFavoriot(rfidID);

    // Open Boom Gate
    gateServo.write(90);
    delay(5000);
    gateServo.write(0);
}

void sendDataToFavoriot(String rfid) {
    if (WiFi.status() == WL_CONNECTED) {
        HTTPClient http;
        http.begin(favoriotURL);
        http.addHeader("Content-Type", "application/json");
        http.addHeader("apikey", apiKey);

        String jsonPayload = "{\"device_developer_id\":\"parking-system\",\"data\":{\"rfid\":\"" + rfid + "\"}}";

        int httpResponseCode = http.POST(jsonPayload);
        if (httpResponseCode > 0) {
            String response = http.getString();
            Serial.println("Data sent to Favoriot: " + response);
        } else {
            Serial.println("Failed to send data");
        }
        http.end();
    }
}


Step 3: Python Code for ANPR (Number Plate Recognition)

If using ANPR (Automatic Number Plate Recognition) with a camera, this Python script:

  • Reads number plates using OpenCV
  • Sends data to Favoriot
import cv2
import pytesseract
import requests

API_KEY = "YOUR_FAVORIOT_API_KEY"
FAVORIOT_URL = "https://apiv2.favoriot.com/v2/streams"

def send_to_favoriot(plate_number):
    headers = {
        "Content-Type": "application/json",
        "apikey": API_KEY
    }
    data = {
        "device_developer_id": "parking-system",
        "data": {"plate_number": plate_number}
    }
    response = requests.post(FAVORIOT_URL, json=data, headers=headers)
    print("Response from Favoriot:", response.text)

cap = cv2.VideoCapture(0)

while True:
    ret, frame = cap.read()
    if not ret:
        break

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    plate_text = pytesseract.image_to_string(gray, config='--psm 8')

    if plate_text.strip():
        print("Detected Plate:", plate_text)
        send_to_favoriot(plate_text.strip())

    cv2.imshow("ANPR", frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()


Step 4: Web Dashboard (PHP + Favoriot API)

To monitor vehicles in real-time, this PHP script fetches data from Favoriot API and displays it in a table.

<?php
$apiKey = "YOUR_FAVORIOT_API_KEY";
$url = "https://apiv2.favoriot.com/v2/streams?device_developer_id=parking-system";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("apikey: $apiKey"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>

<html>
<head>
    <title>Parking System Dashboard</title>
</head>
<body>
    <h2>Vehicle Entry Records</h2>
    <table border="1">
        <tr>
            <th>RFID / Plate Number</th>
            <th>Date & Time</th>
        </tr>
        <?php foreach ($data['data'] as $entry) { ?>
            <tr>
                <td><?php echo $entry['data']['rfid'] ?? $entry['data']['plate_number']; ?></td>
                <td><?php echo $entry['timestamp']; ?></td>
            </tr>
        <?php } ?>
    </table>
</body>
</html>


Conclusion

This Automated Parking System enables real-time vehicle monitoring via Favoriot IoT Platform. You can enhance it by integrating:

✅ Payment systems for parking fees
✅ Mobile notifications for users
✅ Data analytics for optimizing parking usage

This project demonstrates a scalable smart parking system with IoT and cloud-based monitoring.

References

Disclaimer

This article provides a step-by-step guide. The source code may need adjustments to fit the final project design.

Podcast also available on PocketCasts, SoundCloud, Spotify, Google Podcasts, Apple Podcasts, and RSS.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Share this post with your friends!