In current times, the increase in traffic is increasing the major problems of developing cities. Main roads are filled with vehicle traffic at every road or traffic light (intersection point). We encountered the common problem of traffic jams at almost all junctions, which is even critical if you go to big cities. A lot of time, energy and precious fuel are wasted just because of these traffic jams on the roads.
To solve this problem, traffic cameras are used at traffic intersection points. Traffic cameras capture images of vehicles in traffic and send them to MATLAB so start with matlab . Here in this project, Traffic Surveillance System is demonstrated how traffic can be controlled at traffic intersection points from Traffic Control Room. This is a very effective system for Traffic Surveillance.
Below are some snapshots depicting the working of Arduino based traffic surveillance system.
Figure 1: Image showing the operation of the traffic surveillance system based on Arduino and Matlab
Figure 2: Traffic surveillance system prototype based on Arduino and Matlab
Figure 3: Image showing matchboxes used as cars in the prototype model
Figure 4: Image of the Matlab code used in the traffic surveillance system
Figure 5: Image of photograph captured of traffic in Matlab
Figure 6: Filtered image image of traffic in Matlab
Figure 7: Image of the traffic report sent to the cell phone number registered as SMS
Description
The operation of this Traffic Surveillance System is easy and quite simple. The first reader needs to know how to get started with Arduino . There are two Arduino UNO boards that are used to control all operations. GPS and GSM technologies are also used in the project. Here GPS is used with Arduino to get coordinates of a traffic jam and GSM is used with Arduino for sending these coordinates to the Traffic Control Room. But besides GPS and GSM there are two more important things that are used in the Traffic Surveillance Project: Cameras and MATLAB.
Figure 8: Block diagram of traffic surveillance system based on Arduino and Matlab
Block diagram without LCD
MATLAB sends commands to cameras to capture traffic images, where MATLAB subsequently identifies or counts the total number of vehicles at the traffic intersection or on the road. If the total number of vehicles on the road exceeds the limits in a given situation, MATLAB sends signals to the Arduino UNO (A).
Arduino UNO (A) sends interrupt to the second Arduino UNO (B). Now the second Arduino UNO (B) takes the coordinates of the Traffic Jam and sends these coordinates to the Traffic Control Room using the GSM module. Here you can use an LCD to show the traffic status such as traffic jam or no traffic.
Figure 9: Block diagram of traffic surveillance system based on Arduino and Matlab
Block diagram with LCD
Circuit diagram and programming explanation
Circuit Description
The circuit of this system is also quite simple. You can connect the entire system using a jumper wire. Laptop camera is used as traffic camera for monitoring purpose and matchboxes are used in place of vehicles. MATLAB is also used in Laptop to process the working of the project. The Arduino is directly connected to the laptop using USB. Pin number 8 of Arduino UNO (A) is directly connected to pin number 8 of Arduino UNO (B). A GPS module and a GSM module are connected to the Arduino UNO (B). You can also connect a 16×2 liquid crystal display (LCD) to the Arduino UNO (B) to display traffic status.
See circuit diagram guide for without LCD and with LCD
Program
There are three programs for this system, the first is the Arduino MATLAB program for image processing and vehicle counting. The Arduino MATLAB support package file must be installed on your computer (see the previous article on GUI interface with Arduino). The second program is also the Arduino MATLAB support package (see the previous article about GUI interface with Arduino) for Arduino UNO (A). The third program is for Arduino UNO (B) which takes control of GPS, GSM and LCD.
Figure 10: Screenshot of the Arduino code used to initialize the traffic surveillance system
Figure 11: Screenshot of the Matlab code used in the traffic surveillance system
Components used
1. Two Arduino UNO boards
2. GSM Module
3. GPS Module
4. Portable
5. 16X2 liquid crystal display (optional)
6. Power supply
7. Connecting Wires
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(" traffic "); // 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 receipt 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 incoming data from GPS { char inChar = (char)Serial.read; str(i)= inChar; //store incoming data from GPS to temporary 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 |