Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Traffic Surveillance System using MATLAB and Arduino

September 27, 2014 By Salman Khan

 

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

Project Source Code

###

//#include<LiquidCrystal.h>
//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

Related Articles Read More >

Wireless distance measurement using ultrasonic sensor
Computerized wireless Pick and Place Robot
Designing an Arduino-based ECG monitor using an AD8232 ECG sensor
Controlling Appliances Wirelessly using RF Technology

Featured Tutorials

  • Screenshot of Raspbian OS on Raspberry Pi RPi Python Programming 03: Raspberry Pi as Linux System
  • Raspberry Pi Models RPI Python Programming 02: Raspberry Pi Models
  • Raspberry Pi 4 RPi Python Programming 01: Introduction to Raspberry Pi 4
  • RPi Python Programming 05: Introduction to Python
  • RPi Python programming 04 RPi Python programming 04: Setting up Raspberry Pi Linux computer
  • Python Basics RPi Python Programming 06: Python basics

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

Recent Articles

  • Arduino’s L293D motor driver shield guide
  • NXP launches its first Wi-Fi 6E Tri-Band system-on-chip
  • Nexperia launches industry’s first 80 V RETs for high-voltage bus circuits
  • TDK releases low-profile medical sensors
  • Getting started with Raspberry Pi
...

RSS EDABOARD.com Discussions

  • What the best way to store data of size ( 90,000 * 32) bit (taken from a text file) using VHDL?
  • HSPICE Simulation refuses to match the Spectre Simulation
  • How to draw a helical coil around a rectangular core in Maxwell?
  • Where can I find the description of each layer in TSMC's pdk?
  • Same geometry but slightly different results

RSS Electro-Tech-Online.com Discussions

  • Where has the fun gone?
  • Where can I find a pole pig?
  • Voltage based relay
  • XC8 v2.31 Help: Integer Arithmetic With Numbers Larger Than 32 Bits?
  • new to Ardunio but trying to compile
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2021 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering