Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Traffic Surveillance System using MATLAB and Arduino

By Salman Khan July 25, 2021

 

In present times increasing Traffic is adding to the big woes of developing cities. The main roads are packed with vehicular traffic on each and every road or a traffic signal (Intersection Points). One comes across the common problem of traffic jams on almost all Traffic Junctions which is even critical if you go to big cities. A lot of time, energies besides precious fuel is wasted just because of these Traffic Jams on the roads.

To solve this problem Traffic Cameras are used over Traffic Intersection points. Traffic Cameras capture the image of vehicles in traffic and sends to MATLAB then start with matlab. Here in this project Traffic Surveillance System is demonstrated by way of how the traffic could be controlled over traffic intersection points from the Traffic Control Room. This is a very effective system for Traffic Surveillance.

Given below are some snapshots depicting the working of the arduino based traffic surveillance system.

Image showing working of Arduino and Matlab based Traffic Surveillance System

Fig. 1: Image showing working of Arduino and Matlab based Traffic Surveillance System

Prototype of Arduino and Matlab based Traffic Surveillance System

Fig. 2: Prototype of Arduino and Matlab based Traffic Surveillance System

Image showing matchstick boxes used as cars in the prototype model

Fig. 3: Image showing matchstick boxes used as cars in the prototype model

Image of Matlab Code used in Traffic Surveillance System

Fig. 4: Image of Matlab Code used in Traffic Surveillance System

Image of captured photograph of Traffic on Matlab

Fig. 5: Image of captured photograph of Traffic on Matlab

Image of filtered picture of traffic on Matlab

Fig. 6: Image of filtered picture of traffic on Matlab

Image of traffic report sent to registered mobile number as SMS

Fig. 7: Image of traffic report sent to registered mobile number as SMS

Description

Working of this Traffic Surveillance System is easy and quite simple. First reader need to know how to start with arduino . There are two Arduino UNO boards which are used for controlling all the operations. GPS and GSM technologies are also used in the project. Here GPS is used with arduino for taking coordinates of a Traffic Jam and GSM is used with arduino for sending these coordinates to Traffic Control Room. But besides GPS and GSM there are two more other important things which are used in the Traffic Surveillance Project and that are Cameras and MATLAB.

Block Diagram of Arduino and Matlab based Traffic Surveillance System

Fig. 8: Block Diagram of Arduino and Matlab based Traffic Surveillance System

Block Diagram without LCD

MATLAB sends command to cameras for capturing the images of traffic, where MATLAB later identifies or count the total number of vehicles over the Traffic Intersection or over on road. If the total number of vehicles over the road exceeds the limits in a given situation then the MATLAB sends signals to Arduino UNO (A).

Arduino UNO (A) sends interrupt to second Arduino UNO (B). Now the second Arduino UNO (B) takes coordinates of the Traffic Jam and sends these coordinates to the Traffic Control Room using GSM module. Here you can use a LCD for showing the traffic status like Traffic Jam or No Traffic.

Block Diagram of Arduino and Matlab based Traffic Surveillance System

Fig. 9: Block Diagram of Arduino and Matlab based Traffic Surveillance System

Block Diagram with LCD

Circuit Diagram & Programming Explanation

Circuit Description

Circuitry of this system is also quite simple. You can connect the whole system using jumper wire. Laptop Camera is used as Traffic Camera for monitoring purposes and Match Boxes are used in place of vehicles. MATLAB is also used in Laptop for processing the operation of the project. Arduino is directly connected to the Laptop using USB. Arduino UNO’s (A) pin number 8 is directly connected to 8 number pin of Arduino UNO (B). A GPS and a GSM module are connected with Arduino UNO (B). One can also connect a 16×2 Liquid Crystal Display (LCD) with Arduino UNO (B) for displaying Traffic Status.

Please Refer Circuit Diagram Tab for Without LCD and With LCD

Program

There are three programs for this system, first is Arduino MATLAB program for Image Processing and counting the vehicles. Arduino MATLAB support package file should be installed in your computer (see previous article of GUI interfacing with Arduino). Second program is also Arduino MATLAB support package (see previous article of GUI interfacing with Arduino) for Arduino UNO (A). Third program is for Arduino UNO (B) which takes control on GPS, GSM and LCD.

Screenshot of Arduino Code used for Initialization of Traffic Surveillance System

Fig. 10: Screenshot of Arduino Code used for Initialization of Traffic Surveillance System

Screenshot of Matlab Code used in Traffic Surveillance System

Fig. 11: Screenshot of Matlab Code used in Traffic Surveillance System

Components Used

1.      Two Arduino UNO Board

2.      GSM Module

3.      GPS Module

4.      Laptop

5.      16X2 Liquid Crystal Display(Optional)

6.     Power Supply

7.      Connecting Wires

You may also like:


  • What are top applications of CAN protocol?

  • What is LoRa and LoRaWAN?

  • What are the sensors used in self-driving cars?

  • What is an Actuator Sensor Interface (AS-i)?

  • What is LiDAR and how does it work?

  • What is Light Fidelity (Li-Fi)?

Project Source Code

###

//#include
//LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

char str[70];
char *test="$GPGGA";      
char logitude[10];
char latitude[10];

int In=8;
//int LED=8;

int i,j,k;
int temp;
//int Ctrl+z=26;    //for sending msg

void setup()
{
//  lcd.begin(16,2);
  Serial.begin(9600);
  pinMode(In, INPUT);
//  pinMode(LED, OUTPUT);
//  lcd.setCursor(0,0);
//  lcd.print("     trafic    ");
//  lcd.setCursor(0,1);
//  lcd.print("   survilience ");
//  delay(4000);
}

void loop()
{
  
  while(digitalRead(In) != 1);
  if (temp==1)
  {
    for(i=18;i<27;i++)          //extract latitude from string
    {
      latitude[j]=str[i];
      j++;
    }
   
    for(i=30;i<39;i++)          //extract longitude from string
    {
      logitude[k]=str[i];
      k++;
    }
   
   // lcd.setCursor(0,0);        //display latitude and longitude on 16X2 lcd display 
   // lcd.print("Lat(N)");
   // lcd.print((unsigned)latitude);
   // lcd.setCursor(0,1);
   // lcd.print("Lon(E)");
   // lcd.print((unsigned)logitude);
   // delay(100);
   // digitalWrite(LED, HIGH);
    Serial.println("AT+CMGF=1");    //select text mode
    delay(10);
    Serial.println("AT+CMGS="9610126059"");  // enter receipent number
    Serial.println("Trafic Jam ");
    Serial.print("Latitude(N): ");             //enter latitude in msg
    Serial.println(latitude); 
    Serial.print("Longitude(E): ");            //enter Longitude in Msg
    Serial.println(logitude); 
                    //enter latitude value in msg
                    //enter longitude value in msg
    Serial.println("Thanks");  
    Serial.write(26);                      //send msg  Ctrl+z=26
    temp=0;
    i=0;
    j=0;
    k=0;
    delay(4000);                        // next reading within 20 seconds
   // digitalWrite(LED, LOW);
}
}

void serialEvent()
{
  while (Serial.available())            //Serial incomming data from GPS
  {
    char inChar = (char)Serial.read();
     str[i]= inChar;                    //store incomming data from GPS to temparary string str[]
     i++;
     if (i < 7)                      
     {
      if(str[i-1] != test[i-1])         //check for right string
      {
        i=0;
      }
     }
    if(i >=60)
    {
     temp=1;
    }
  }
}


###

 


Circuit Diagrams

Circuit-Diagram-Arduino-Matlab-Based-Traffic-Surveillance-System
Circuit-Diagram-Arduino-Matlab-Based-Traffic-Surveillance-System_0

Project Video


Filed Under: Electronic Projects, PIC Microcontroller
Tagged With: 16x2 LCD, Arduino, gps, gsm, lcd, matlab
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Colpitts oscillator
  • BiSS-C Behavior Without Slave (dsPIC33AK128MC106 + iC-MB4)
  • GanFet power switch starts burning after 20 sec
  • AC amplifier, transistor with bias network
  • Sub 1-Ghz Range calculation of CC1352P in urban and rural areas

RSS Electro-Tech-Online.com Discussions

  • Wish to buy Battery, Charger and Buck converter for 12V , 2A router
  • Need Help Figuring Out the Schematics Of Circuit Board
  • applying solder paste from a jar
  • Question i-nears headphones magnetic drivers
  • An Update On Tarrifs

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • Sienna Semiconductor data converters feature sample rates from 20 to 250 Msps
  • Delta’s 5,500 W power supplies achieve 97.5% energy efficiency for AI servers
  • Novosense Microelectronics releases digital isolators with capacitive-based design
  • MIPI C-PHY adds encoding option to support next-gen image sensor applications
  • Littelfuse gate driver delivers 1.9 A source and 2.3 A sink output current

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe