Arduino-Based Smart Toll Gate Automation System with RFID, GSM, Ultrasonic Sensor and LCD Display

 

The Smart Toll Gate Automation System using Arduino UNO is an intelligent traffic management solution designed to automate vehicle entry and toll collection using RFID technology, ultrasonic sensing, GSM communication, servo motor barrier control, and LCD display interface. This system enhances toll booth efficiency by reducing manual intervention and enabling fast, secure vehicle authentication.

The RFID RC522 module is used to identify vehicles equipped with RFID tags. When a vehicle approaches the toll gate, the system scans the RFID card and verifies the vehicle ID against stored data. Upon successful authentication and sufficient balance confirmation (if integrated with a prepaid system), the gate automatically opens using a servo motor-controlled barrier mechanism.

The ultrasonic sensor detects the presence of a vehicle near the toll booth and ensures the barrier operates only when a vehicle is positioned correctly. The LCD display (I2C 16x2) provides real-time information such as “Scan Card,” “Processing,” “Access Granted,” “Insufficient Balance,” or “Access Denied.”

The integrated GSM module can send SMS notifications to vehicle owners confirming toll deduction or alert authorities in case of unauthorized access attempts. The push button can be used for manual override or emergency control.

This project demonstrates real-world implementation of SPI communication (RFID), UART communication (GSM), I2C display interfacing, servo motor PWM control, vehicle detection using ultrasonic sensors, and embedded automation systems. It is suitable for smart city infrastructure development and intelligent transportation systems.


Key Features

  • RFID-based automatic toll collection system

  • Servo motor-operated toll gate barrier

  • Ultrasonic sensor for vehicle detection

  • GSM-based SMS notification system

  • I2C 16x2 LCD real-time display

  • Automated toll deduction logic

  • Reduced traffic congestion

  • Expandable IoT-enabled architecture

  • Secure and contactless vehicle authentication

Code:
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>

#define RST_PIN 9
#define SS_PIN 10
#define TRIG_PIN 6
#define ECHO_PIN 7
#define IR_PIN 4
#define SERVO_PIN 5
#define BUTTON_PIN 2
#define GSM_TX 3
#define GSM_RX 2

MFRC522 mfrc522(SS_PIN, RST_PIN);
Servo gateServo;
LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial gsm(GSM_RX, GSM_TX);

SoftwareSerial serialComm(3, 4);  // RX, TX for communication with second Arduino

// Predefined RFID Cards and Balances
struct RFIDCard {
  String uid;
  int balance;
};

RFIDCard rfidCards[] = {
  {"F3E45216", 200},
  {"A1B2C3D4", 100}
};
const int tollFee = 50;

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

  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Toll Booth Ready");

  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  pinMode(IR_PIN, INPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  gateServo.attach(SERVO_PIN);
  gateServo.write(0);

  gsm.begin(115200);
  serialComm.begin(9600); // Start serial communication with the second Arduino
  Serial.println("System Initialized.");
}

void loop() {
  // Detect a vehicle using the ultrasonic sensor
  if (detectVehicle()) {
    lcd.setCursor(0, 0);
    lcd.print("Vehicle Detected ");
    delay(500);
    lcd.clear();

    // Detect an RFID card
    if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
      String cardID = getCardID();
      int balanceIndex = getBalanceIndex(cardID);
      lcd.setCursor(0, 0);

      if (balanceIndex != -1) {
        if (rfidCards[balanceIndex].balance >= tollFee) {
          lcd.print("Pay 50 Taka?");
          Serial.println("Press the button to pay.");

          bool paymentConfirmed = false;
          unsigned long startTime = millis();
          while (millis() - startTime < 10000) {
            if (digitalRead(BUTTON_PIN) == LOW) {
              paymentConfirmed = true;
              break;
            }
          }

          if (paymentConfirmed) {
            rfidCards[balanceIndex].balance -= tollFee;
            lcd.setCursor(0, 1);
            lcd.print("Payment Success ");
            Serial.println("Payment successful.");

            // Send payment status to the second Arduino
            serialComm.println("Payment Successful");

            // Send SMS Notification
            String message = "Payment of 50 Taka successful. Remaining balance: " + String(rfidCards[balanceIndex].balance) + " Taka.";
            sendSMS("+8801743648510", message);

            openGate();
          } else {
            lcd.setCursor(0, 1);
            lcd.print("Payment Timeout");
            Serial.println("Payment timeout.");
            serialComm.println("Payment Timeout");
          }
        } else {
          lcd.print("Insufficient Bal");
          Serial.println("Insufficient balance.");
          serialComm.println("Insufficient Balance");
          delay(2000);
        }
      } else {
        lcd.print("Card Not Recognized");
        Serial.println("Card not recognized.");
        serialComm.println("Card Not Recognized");
        delay(2000);
      }
      mfrc522.PICC_HaltA();
      lcd.clear();
    }
  } else {
    lcd.setCursor(0, 0);
    lcd.print("Waiting for Car ");
    delay(500);
    lcd.clear();
  }
}

bool detectVehicle() {
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);
  long duration = pulseIn(ECHO_PIN, HIGH);
  int distance = duration * 0.034 / 2;
  return (distance < 50);
}

String getCardID() {
  String cardID = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    if (mfrc522.uid.uidByte[i] < 0x10) cardID += "0";
    cardID += String(mfrc522.uid.uidByte[i], HEX);
  }
  cardID.toUpperCase();
  return cardID;
}

int getBalanceIndex(String uid) {
  for (int i = 0; i < sizeof(rfidCards) / sizeof(rfidCards[0]); i++) {
    if (rfidCards[i].uid == uid) {
      return i;
    }
  }
  return -1;
}

void openGate() {
  Serial.println("Opening gate...");
  lcd.setCursor(0, 0);
  lcd.print("Opening Gate...");
  gateServo.write(90);
  delay(5000);
  while (digitalRead(IR_PIN) == LOW);
  lcd.setCursor(0, 0);
  lcd.print("Closing Gate...");
  gateServo.write(0);
  delay(1500);
  lcd.clear();
}

void sendSMS(String phoneNumber, String message) {
  gsm.print("AT+CMGF=1\r");
  delay(100);
  gsm.print("AT+CMGS=\"");
  gsm.print(phoneNumber);
  gsm.print("\"\r");
  delay(100);
  gsm.print(message);
  delay(100);
  gsm.write(26); // CTRL+Z to send SMS
  delay(5000);
  Serial.println("SMS sent to " + phoneNumber);
}


Applications

  • Highway toll booth automation

  • Smart city traffic management systems

  • Parking lot access control

  • Automated vehicle entry systems

  • RFID-based transportation monitoring

  • Intelligent transportation system (ITS) projects


Future Enhancements

  • Cloud-based toll management dashboard

  • Automatic balance recharge integration

  • Number plate recognition system

  • ESP32 WiFi-based live monitoring

  • Centralized toll data server

  • Multi-lane toll automation system

 

IOT & SMART SYSTEM PROJECTS

  1. IoT Weather Monitoring System (NodeMCU ESP8266 + DHT11 + Rain Sensor)
  2. ESP8266 NodeMCU Smart Health & Environment Monitoring System with Pulse, Temperature and Motion Sensors
  3. ESP32 Wi-Fi Weight Sensor with HX711
  4. Smart RFID Access Control System Using ESP32 Dev Board and UHF RFID Reader Module
  5. Smart IoT Motor Control System Using ESP32 Dev Board and L298N Motor Driver Module
  6. Smart Waste Management System Using Arduino Nano, Ultrasonic Sensor & GSM Module – Solar Powered IoT Solution
  7. Raspberry Pi Zero W and GSM SIM900 Based Ultrasonic Distance Measurement System
  8. Arduino UNO Smart Surveillance System with ESP8266 WiFi, PIR Motion Sensor & Camera Module
  9. Arduino UNO Environmental Monitoring System with OLED & 16x2 I2C LCD Display
  10. Arduino UNO-Based Smart Home Automation System with Flame and IR Sensors 
  11. Arduino Nano-Based Landslide Detection System with GSM Alerts – Smart Disaster Monitoring Project
  12. Arduino Nano Rain-Sensing Stepper Motor System
  13. Arduino Based Automatic Tire Inflator Using Pressure Sensor, Relay Module and LCD Display
  14. Arduino-Based Automatic Cooker Using Servo Motors, DC Stirrer Motor, Temperature Sensor and Relay-Controlled Heater
  15. Arduino Sketch for Plastic Bottle and Can Reverse Vending Machine

 TRAFFIC & SMART CITY PROJECTS
  1. RFID-Based Smart Traffic Control System (Arduino Mega)
  2. Arduino UNO Traffic Light Control System – Smart LED Signal Project
  3.  Arduino UNO Controlled Traffic Light System with Joystick Interface

ROBOTICS PROJECTS
  1. Arduino UNO Smart Obstacle Avoiding Robot (Ultrasonic + IR + GSM)
  2. Arduino-Powered Autonomous Obstacle Avoidance Robot with Servo Control
  3. Arduino Nano Bluetooth Controlled Line Follower Robot Using L298N Motor Driver
  4. Arduino UNO Bluetooth Controlled 4WD Robot Car Using L298N Motor Driver
  5. Arduino UNO Multi-Sensor Obstacle Avoidance & Bluetooth Controlled Robot Car Using L298N
  6. Raspberry Pi Motor Control Robot (L298N + Li-ion)
  7. RC Car Simulation with L298N Motor Driver and Joystick Control using Arduino (CirkitDesign Simulation)
  8. Raspberry Pi Robotic Arm Control System with Camera Module and Motor Driver – Smart Automation & Vision-Based Robotics Project
  9. ESP32-Based 4WD Robot Car Using Dual L298N Motor Drivers – Circuit Diagram and IoT Control Project

LORA & WIRELESS COMMUNICATION PROJECTS
  1. Arduino LoRa Communication Project Using Adafruit RFM95W LoRa RadioArduino Nano with RFM95 SX1276 LoRa
  2. Arduino Nano with RFM95 LoRa SX1276 Module – Long Range Wireless Communication Project
  3. Arduino Nano Digital Clock Using DS3231 RTC and TM1637 4-Digit Display – Circuit Diagram and Project Guide

 LED, LIGHTING & DISPLAY PROJECTS
  1. Arduino UNO Controlled NeoPixel Ring Light Show
  2. Wi-Fi Controlled NeoPixel Ring (ESP8266)
  3. Chained NeoPixel Rings with Arduino – Addressable RGB LED Control Project
  4. Arduino Nano-Controlled Lighting System with Gesture and Sound Interaction
  5. Raspberry Pi GPIO Multi-LED Control System – Beginner-Friendly Embedded Electronics Project
  6. 4 Channel Relay Module with Arduino UNO

 SENSOR & DETECTION PROJECTS
  1. Arduino UNO Color Sensor + Proximity System (TCS3200 + Inductive)
  2. Arduino Color Detection Project Using Adafruit TCS34725 RGB Color Sensor
  3. Arduino Gas Leakage Detection and Safety Alert System Using MQ-2 Gas Sensor
  4. MQ-135 Air Quality Detector Using Arduino | Cirkit Designer Simulation Project
  5. Pulse Sensor Using Arduino – Complete Guide with Simulation 
  6. HX711 Load Sensor Demo Using Arduino | Digital Weight Measurement Project
  7. Track Time with DS1307 RTC and Display on Arduino Uno with 16x2 LCD | Cirkit Designer Project
  8. Parking Sensor Simulator using Arduino Uno and HC-SR04 Ultrasonic Sensor

 FUN & INTERACTIVE PROJECTS
  1. Pong Game with Arduino UNO and OLED Display – Project Explanation
  2.   Arduino UNO Bluetooth-Controlled Servo Motor System
  3. Arduino UNO-Based Interactive Touch and Distance Sensing System with LED Indicators and Servo Control

 INDUSTRIAL / AUTOMATION PROJECTS
  1. Arduino UNO Smart Waste Sorting System Using Ultrasonic Sensor, Moisture Sensor, Servo, Stepper Motor and LCD
  2. Arduino-Based Smart Waste Segregation System Using Metal, Plastic and Moisture Sensors with Stepper and Servo Control
  3. ESP32-Based Digital Weighing Scale Using 50kg Load Cell, HX711 Module and 16x2 LCD Display
  4. Arduino-Based Smart Toll Gate Automation System with RFID, GSM, Ultrasonic Sensor and LCD Display

  5. Arduino-Based Automatic Pill Dispenser Machine with LCD Display, Servo Motor and Buzzer Reminder

  6. Arduino UNO Smart Water Quality Monitoring System with pH Sensor, Turbidity Sensor and LCD Display

  7. Arduino-Based Ocean Cleaning Boat Robot with Dual IBT-2 Motor Drivers and Conveyor Belt System

  8. IoT-Based Accident Detection and Health Monitoring System Using Raspberry Pi with GSM, GPS and Camera Integration

  9. Raspberry Pi RFID and Keypad Based Smart Door Lock System with LCD Display and L298N Motor Driver

  10. Smart Shopping Trolley Using Arduino UNO & RFID | Automatic Billing System

  11. Arduino UNO Based Automatic Liquid Hand Sanitizer & Soap Dispenser System

  12. Arduino Based Robotic Weeding Machine with Ultrasonic Obstacle Detection and L298N Motor Driver

  13. Arduino UNO Based Biometric Electronic Voting System with LCD Display and Fingerprint Authentication

  14. Arduino UNO Based Electronic Voting System with ILI9341 TFT Display

Comments