i
VEHICLE OVER SPEED DETECTION SYSTEM
By
EITHAR ABD ALSLAM MOHAMMED AHMED
INDEX NO. 124034
Supervisor
Prof. Mustafa Omer Nawari
A REPORT SUBMITTED TO
University of Khartoum
In partial fulfillment for the degree of
B.Sc. (HONS) in Electrical and Electronic Engineering
(Control and Instrumentation Systems)
Faculty of Engineering
Department of Electrical and Electronics Engineering
ii
DECLARATION OF ORGINALITY
I declare this report entitled “Vehicle over speed detection system” is my own work except as cited in
references. The report has not been accepted for any degree and it is not being submitted currently in
candidature for any degree or other reward.
Signature:
Name:
Date:
iii
ACKNOWLEDGMENT
Unlimited praise for Allah for his blessing and guidance.
I would like to present my gratitude and thanks to our supervisor Prof. Mustafa Omer Nawari for his
support, motivation, patience, humility and also, problems resolving.
Also many thanks to all my colleagues for their support and help.
iv
ABSTRACT
WHO Statistics showed that over speeding is the main contributory factor in road crashes.
This project aims to monitor vehicles’ speed to prevent crashes occurrence and reduce the impact
when they occur, lessening the severity of injuries sustained by the victims.
The project proposes a modern and an efficient methodology for detecting and reporting illegal
speeds.
The System mainly consists of a GPS module for speed measurement and location identification,
Raspberry PI as the processing and controlling unit and A GSM module for sending infractions
to authorities’ web server.
The system alerts the driver if he exceeded the allowed speed limit. An infraction is reported
against him if he didn’t slow down within a predefined amount of time.
The infractions are sent to a central database and are displayed in a webpage.
The system was implemented in a local network, so an Ethernet cable sufficed for the
communication purpose.
The RPI controls all the other units and the overall system.
The project objectives were successfully met. More features, e.g. Google map, are suggested to
be added in future work.
Over speeding has been identified as a major cause for traffic accidents. The accidents due to
high speed result in crashes, dangerous injuries and death.
vi
المستخلص
تظهر إحصاءات منظمة الصحة العالمية أن السرعات العالية التي تسير بها المركبات في الطرق هي العامل الرئيسي في حوادث الطريق.
صاباتاإلما يقلل من خطورة و رصد السرعات العالية لمنع وقوع الحوادث و الحد من تأثيرها عندما تحدث م يهدف هذا المشروع لقياسو
و الخسارات في األرواح.
. ارعات غير القانونية واإلبالغ عنهويقترح المشروع منهجية حديثة وفعالة للكشف عن الس
الذي رسا المخالاات إل خادم الوي إلو وحدة وحدة معالجة و بجهازتحديد المواقع العالمي يتكون النظام أساسا من وحدة قياس السرعة
. تمتلكه الجهات المسؤولة
سرعة. يتم اإلبالغ عن مخالاة ضده إذا لم يبطئ في غضون فترة محددة مسبقا من يقوم النظام بتنبيه السائق إذا تجاوز الحد المسموح به لل
بإستخدام موصل وقد تم تنايذ النظام في شبكة محلية.يتم إرسا المخالاات إل قاعدة بيانات مركزية ويتم عرضها في صاحة وي .الزمن
. االنترنت
بل.في المستق و استخدام مخدم عالميطة جوجل الميزات، مثل خري المزيد منو سوف تضاف وقد تحققت أهداف المشروع بنجاح.
vii
TABLE OF CONTENTS
DECLARATION OF ORGINALITY .................................................................................................. II
ACKNOWLEDGMENT ...................................................................................................................... III
ABSTRACT ........................................................................................................................................... IV
V ................................................................................................................................................. المستخلص
LIST OF FIGURES .............................................................................................................................. XI
LIST OF ABBREVIATIONS ............................................................................................................... XII
CHAPTER ONE: INTRODUCTION .......................................... Error! Bookmark not defined.
1.1 Introduction ......................................................................... Error! Bookmark not defined.
1.2 Problem Statement ................................................................................................................ 1
1.3 Project Background ............................................................................................................... 2
1.4 Motivation ........................................................................... Error! Bookmark not defined.
1.5 Objectives ............................................................................................................................. 2
1.6 Thesis Layout ........................................................................................................................ 2
CHAPTER TWO: LITERATURE REVIEW .......................................................................... 4
2.1 Introduction ........................................................................................................................... 4
2.2 Overview ............................................................................................................................... 4
2.3 GPS ....................................................................................................................................... 4
2.3.1 Positioning, Navigation and Timing ............................................................................. 5
2.3.2 More detailed description ............................................................................................. 6
2.3.2.1 Space Segment ..................................................... Error! Bookmark not defined.
2.3.2.2 Control Segment. ................................................................................................... 7
2.3.2.3 User Segment ......................................................................................................... 7
2.4 GSM (Global System for Mobile Communication) .............................................................. 7
2.4.1 The GSM Network Parts .............................................................................................. 8
2.4.1.1 The Switching System ........................................................................................... 8
2.4.1.2 The Base Station System ....................................................................................... 8
2.4.1.3 Mobile Station ....................................................................................................... 9
viii
2.4.2 GSM Modem ................................................................................................................ 9
2.5 Processing and Controlling ................................................................................................. 10
2.5.1 Raspberry PI ............................................................................................................... 10
2.5.1.1 Raspberry Pi Generations .................................................................................... 10
2.5.1.2 RPI General Properties ......................................... Error! Bookmark not defined.
2.5.1.3 Raspberry Pi Hardware ........................................................................................ 12
2.5.1.4 External Peripherals ............................................................................................. 12
2.5.1.5 Raspberry Pi Operating System ........................................................................... 12
2.5.2 Python ......................................................................................................................... 13
2.6 Similar Papers and Researches ........................................................................................... 13
2.6.1 Detection of Over Speeding on Highways ................................................................. 13
2.6.2 Automated Over Speeding Detection and Reporting System..................................... 13
2.6.3 Car Over Speed Detector ............................................................................................. 13
CHAPTER THREE: METHODOLOGY ............................................................................... 14
3.1 Introduction ......................................................................................................................... 14
3.2 Initiating The Project .......................................................................................................... 14
3.3 Planning The Project ........................................................................................................... 14
3.4 System Design .................................................................................................................... 15
3.4.1 Location (GPS) ........................................................................................................... 15
3.4.1.1 Message Structure ................................................................................................ 16
3.4.2 Processing (RPI) ......................................................................................................... 17
3.4.2.1 Reporting Methodology ....................................................................................... 17
3.4.3 Communication........................................................................................................... 17
3.4.3.1 PuTTY ................................................................................................................. 19
3.4.4 Web Serving ............................................................................................................... 19
3.4.4.1 XAMPP Server .................................................................................................... 19
3.4.4.2 phpMyAdmin ....................................................................................................... 20
3.4.4.3 Web Page ............................................................................................................. 20
CHAPTER FOUR: IMPLEMENTATION AND RESULTS ................................................ 21
4.1 Introduction ......................................................................................................................... 21
ix
4.2 System Implementation ...................................................................................................... 21
4.2.1 Hardware..................................................................................................................... 21
4.2.1.1 GPS Module ........................................................................................................ 21
4.2.1.2 GPS Antenna ....................................................................................................... 22
4.2.1.3 SMA to UFL Adapter Cable ................................................................................ 23
4.2.1.4 USB to TTL Cable ............................................................................................... 23
4.2.1.5 Ethernet Cable ..................................................................................................... 24
4.2.1.6 Raspberry Pi......................................................................................................... 24
4.2.1.7 SD Card ............................................................................................................... 25
4.2.1.8 Power Supply ....................................................................................................... 26
4.2.1.9 Buzzer ................................................................................................................... 26
4.2.2 Software ...................................................................................................................... 26
4.2.2.1 LX Terminal ........................................................................................................ 27
4.2.2.2 XAMPP ................................................................................................................ 27
4.2.2.3 PuTTY .................................................................................................................. 28
4.2.2.4 phpMyAdmin ........................................................................................................ 28
4.3 Hardware Implementation .................................................................................................. 39
4.3.1 Interfacing the GPS with the RPI ............................................................................... 29
4.3.2 System Implementation .............................................................................................. 30
4.4 Software Implementation .................................................................................................... 30
4.4.1 RPI software ............................................................................................................... 30
4.4.2 Connection to MySQL ................................................................................................ 31
4.4.3 Web Page Software..................................................................................................... 31
4.5 Testing................................................................................................................................. 31
4.5.1 RPI Testing .................................................................................................................. 31
4.5.2 Internet Connection Testing ......................................................................................... 32
4.5.2.1 USB Tethering Configurations ............................................................................. 32
4.5.3 GPS Testing ................................................................................................................. 33
4.5.4 External Antenna Testing ............................................................................................ 35
4.5.5 Buzzer Testing ............................................................................................................. 35
4.5.6 Network Testing........................................................................................................... 35
x
4.5.7 System Testing ................................................................................................................ 36
4.6 Results .................................................................................................................................... 36
CHAPTER FIVE: CONCLUSION AND FUTURE WORK ................................................ 39
5.1 Conclusion .......................................................................................................................... 39
5.2 Problems and Limitations ................................................................................................... 39
5.3 Future Work ........................................................................................................................ 39
REFERENCES .......................................................................................................................... 40
APPENDIX A ...................................................................................................................................... A-1
xi
LIST OF FIGURES
Figure 2-1: GPS Positioning ..................................................................................................................5
Figure 2-2: Raspberry Pi Logo............................................................................................................ 10
Figure 2-3: Raspberry Pi 2 Model B.....................................................................................................11
Figure 3-1: Involved Technologies........................................................................................................15
Figure 3-2: Server Configuration .........................................................................................................18
Figure 4-2: Adafruit GPS ..................................................................................................................... 22
Figure 4-3: External GPS Antenna...................................................................................................... 22
Figure 4-4: SMA to UFL Adapter Cable............................................................................................. 23
Figure 4-5: USB to TTL Cable............................................................................................................. 24
Figure 4-6: Ethernet Cable................................................................................................................... 24
Figure 4-7: Raspberry Pi....................................................................................................................... 25
Figure 4-8: SD Card............................................................................................................................... 25
Figure 4-9: Power Bank......................................................................................................................... 26
Figure 4-10: Buzzer................................................................................................................................ 26
Figure 4-11: LX Terminal..................................................................................................................... 27
Figure 4-12: XAMPP............................................................................................................................. 27
Figure 4-13: PuTTY Terminal.............................................................................................................. 28
Figure 4-14: Interfacing the GPS with the RPI................................................................................... 29
Figure 4-15: GPS Readings................................................................................................................... 29
Figure 4-16: System Implementation....................................................................................................30
Figure 4-17: Pinging Google.................................................................................................................. 33
Figure 4-18: GPS Connections............................................................................................................... 34
Figure 4-19: GPS Readings.................................................................................................................... 34
Figure 4-20: Pinging the Raspberry Pi................................................................................................. 35
xii
Figure 4-21: Pinging the Server......................................................................................................... 36
Figure 4-22: Database......................................................................................................................... 37
Figure 4-23: Web Page........................................................................................................................ 37
xiii
LIST OF ABBREVIATIONS
RPI Raspberry Pi
WHO World Health Organization
OS Operating system
SSH Secure Shell
SQL Structured Query Language
HTTP Hypertext Transfer Protocol
HTML Hypertext Markup Language
GPS Global Positioning System
CSS Cascading Style Sheets
GPIO General Purpose Input Output
GPSD Global Positioning System Daemon
GSM Global System for Mobile Communication
HDMI High Definition Multimedia Interface
PHP Personal Home Page Tools
SD Secure Digital
IP Internet Protocol
SIM Subscriber Identity Module
USB Universal Serial Bus
NMEA National Marine Electronics
CHAPTER ONE INTRODUCTION
1
CHAPTER ONE INTRODUCTION
1.1 Introduction
This chapter is intended to give the reader a general idea about the project background, problem
statement, motivations and project objectives. In addition, an overview of thesis layout will be
presented.
1.2 Problem Statement
Over speeding has been identified as a major cause for traffic accidents. The accidents due to
high speed result in crashes, dangerous injuries and death.
WHO statistics showed that in high-income countries, speed contributes to about 30% of deaths
on the road, while in some low-income and middle income countries, speed is estimated to be the
main contributory factor in about half of all road crashes.
Controlling vehicles’ speed can prevent crashes occurrence and reduce the impact when they
occur, lessening the severity of injuries sustained by the victims.
1.2.1 How does speed affect traffic collisions and injury? [1]
The higher the speed of a vehicle, the shorter the time a driver has to stop and avoid a
crash. A car travelling at 50 km/h will typically require 13 meters in which to stop, while
a car travelling at 40 km/h will stop in less than 8.5 meters.
An increase in average speed of 1 km/h typically results in a 3% higher risk of a crash
involving injury, with a 4–5% increase for crashes that result in fatalities.
Speed also contributes to the severity of the impact when a collision does occur. For car
occupants in a crash with an impact speed of 80 km/h, the likelihood of death is 20 times
what it would have been at an impact speed of 30 km/h.
CHAPTER ONE INTRODUCTION
2
1.3 Project Background
The project aims to provide applicable knowledge of:
GPS technology and GPS tracking.
GSM technology.
Raspberry pi.
Web application.
1.4 Motivation
Solving this serious problem with a suitable and economically feasible solution.
Learning more about the Raspberry Pi; its abilities and applications.
Learning about new technologies like GPS and GSM.
Learning more about Linux OS.
Getting introduced to web serving.
1.5 Objectives
The main objectives of the project can be summarized as follows:
Designing speed monitoring system to monitor the speed of travelling buses in highways.
Alarming the driver when the speed exceeds the maximum allowed speed.
Reporting illegal speeds to central server if the driver continues with the high speed.
Designing a web site linked with google-map for tracking buses and viewing reports.
Protecting the device from tampering.
Establishing a secure connection between the web server and the tracking system.
1.6 Thesis Layout This section provides brief information about the rest of the thesis. It is organized as follows:
Chapter 2: Literature review: This chapter overviews various technologies that have been
employed in the design and implementation of vehicle over-speed detection system. It also gives
an overview about the similar systems.
Chapter 3: Methodology: This chapter describes the design of the system (the hardware
design and the software design).
CHAPTER ONE INTRODUCTION
3
Chapter 4: Implementation and results: This chapter shows the implementation details of
the system, including a brief description of the hardware and software components. The testing
performed and the results obtained were also discussed in this chapter.
Chapter 5: Conclusion and future work: This chapter shows the conclusion of the results
obtained and discusses the future work.
References: Contains the citations indexed by numbers.
Appendix A: This appendix contains all the codes used in the project.
CHAPTER TWO LITERATURE REVIEW
4
CHAPTER TWO
LITERATURE REVIEW
2.1 Introduction
This chapter overviews various technologies and techniques that have been employed for the
design and implementation of vehicle over-speed detection system. Besides, presenting the
similar researches and papers. It also aims to provide guidance through the remaining chapters.
2.2 Overview
The system consists of server side (monitoring side) and client side (vehicle). The block of the
controller (RPI) and the sensor (GPS) constitutes the link between these two ends.
The project may be divided into four main parts:
GPS.
Communication.
Processing and controlling.
Web serving
2.3 GPS
Global Positioning System or GPS is a United States space-based radio-navigation system that
helps pinpoint a three dimensional position to about a meter of accuracy (for example latitude,
longitude and altitude) and provide nanosecond precise time anywhere on Earth.
CHAPTER TWO LITERATURE REVIEW
5
Figure 2-1: GPS Positioning
2.3.1 Positioning, Navigation, and Timing (PNT) [2]
The term Positioning, Navigation, and Timing is commonly used to describe the services that
Global Positioning System (GPS) / Global Navigation Satellite System (GNSS) constellations
provide, or to denote the various methods and technologies by which navigation is supported.
These words are defined as follows:
Positioning is the ability to accurately and precisely determine one's location and orientation
two-dimensionally or sometimes three-dimensionally when referenced to a standard geodetic
system such as World Geodetic System 1984 (WGS84) or the International Terrestrial Reference
Frame (ITRF).
Navigation is the ability to determine current and desired position (relative or absolute) and
apply corrections to course, orientation, and speed to attain a desired position anywhere around
the world, from sub-surface to surface and from surface to space.
Timing is the ability to acquire and maintain accurate and precise time from a standard
Coordinated Universal Time (UTC) anywhere in the world and within user-defined parameters.
Timing also includes time transfer.
The GPS concept is based on time and the known position of GPS specialized satellites. The
satellites carry very stable atomic clocks that are synchronized with one another and with the
CHAPTER TWO LITERATURE REVIEW
6
ground clocks. Any drift from true time maintained on the ground is corrected daily. In the same
manner, the satellite locations are known with great precision. GPS receivers have atomic clocks
as well. However, they are usually not synchronized with "true time", and are therefore less
stable.
GPS satellites continuously transmit data about their current time and position. A GPS receiver
monitors multiple satellites and solves equations to determine the precise position of the receiver
and its deviation from true time. At a minimum, four satellites must be in view of the receiver for
it to compute four unknown quantities (three position coordinates and clock deviation from
satellite time).
2.3.2 More Detailed Description
Each GPS satellite continually broadcasts a signal.
A pseudorandom code that is known to the receiver is used for modulation. By time-aligning, the
time of arrival (TOA) of a defined point in the code sequence, called an epoch, can be found in
the receiver clock time scale.
A message that includes the time of transmission (TOT) of the code epoch (in GPS system time
scale) and the satellite position at that time.
Conceptually, the receiver measures the TOAs (according to its own clock) of four satellite
signals. From the TOAs and the TOTs, the receiver forms four time of flight (TOF) values,
which are (given the speed of light) approximately equivalent to receiver-satellite range
differences. The receiver then computes its three-dimensional position and clock deviation from
the four TOFs.
The receiver's Earth-centered solution location is usually converted to latitude, longitude and
height relative to an ellipsoidal Earth model.
The current GPS consists of three major segments. These are the space segment, a control
segment, and a user segment. The U.S. Air Force develops, maintains, and operates the space
and control segments. GPS satellites broadcast signals from space, and each GPS receiver uses
these signals to calculate its three-dimensional location (latitude, longitude, and altitude) and the
current time.
CHAPTER TWO LITERATURE REVIEW
7
2.3.2.1 Space Segment
A constellation of at least 24 US government satellites-to improve reliability and availability of
the system- distributed in six orbital planes inclined 55° from the equator in a Medium Earth
Orbit (MEO) at about 20,200 kilometers (12,550 miles) and circling the Earth every 12 hours.
2.3.2.2 Control Segment
Stations on Earth monitoring and maintaining the GPS satellites.
2.3.2.3 User Segment
Receivers that process the navigation signals from the GPS satellites and calculate position and
time. The user segment is composed of hundreds of thousands of U.S. and allied military users of
the secure GPS Precise Positioning Service, and tens of millions of civil, commercial and
scientific users of the Standard Positioning Service (see GPS navigation devices). In general,
GPS receivers are composed of an antenna, tuned to the frequencies transmitted by the satellites,
receiver-processors, and a highly stable clock (often a crystal oscillator). They may also include
a display for providing location and speed information to the user. A receiver is often described
by its number of channels: this signifies how many satellites it can monitor simultaneously.
Receivers typically have between 12 and 20 channels.
Many GPS receivers can relay position data to a PC or other device using the NMEA 0183
protocol. Although this protocol is officially defined by the National Marine Electronics
Association (NMEA), references to this protocol have been compiled from public records,
allowing open source tools like gpsd to read the protocol without violating intellectual property
laws. Other proprietary protocols exist as well, such as the SiRF and MTK protocols. Receivers
can interface with other devices using methods including a serial connection, USB, or Bluetooth.
2.4 GSM (Global System for Mobile Communication) [3]
GSM is a second-generation digital mobile telephone standard used for transmitting mobile voice
and data services. GSM uses a variation of Time Division Multiple Access (TDMA) and it is the
CHAPTER TWO LITERATURE REVIEW
8
most widely used of the three digital wireless telephone technologies - CDMA (Code Division
Multiple Access), GSM and TDMA. GSM digitizes and compresses voice data, then sends it
down a channel with two other streams of user data, each in its own time slot. It operates at
either the 900, 1800 or 1,900MHz frequency bands. It is expanded over time to include data
communications, first by circuit-switched transport, then by packet data transport
via GPRS (General Packet Radio Services) and EDGE (Enhanced Data rates for GSM Evolution,
or EGPRS).
GSM was initially developed as a pan-European collaboration, intended to enable mobile
roaming between member countries. As at March 2003, GSM digital wireless services were
offered in some form in over 193 countries. In June 2002, about 69% of all digital mobile
subscriptions in the world used GSM phones on GSM networks.
2.4.1 The GSM network can be divided into three broad parts: [4]
Switching System (SS)
The Base Station (BSS)
Mobile station (MS).
2.4.1.1 The Switching System (SS)
SS is very operative system in which many crucial operations are conducted. SS systems holds
five databases with in it which performs different functions. It performs call processing and
subscriber related functions. These databases from SS systems are HLR, MSC, VLR, AUC and
EIR. The MSC in cooperation with Home Location register (HLR) and Visitor location register
(VLR), take care of mobile calls and routing of phone calls. Authentication center (AUC) is
small unit which handles the security end of the system and Equipment identity register (EIR) is
another important database which holds crucial information regarding mobile equipment.
2.4.1.2 The Base Station System (BSS)
BSS has very important role in mobile communication. Base station systems are basically
outdoor units which consist of iron rods and are usually of high length. They are responsible for
connecting subscribers (MS) to mobile networks. All the communication is made in Radio
transmission. The Base station System is further divided in two systems BTS and BSC. BTS
(Base Transceiver station) handles communication using radio transmission with mobile station
CHAPTER TWO LITERATURE REVIEW
9
and BSC (Base station controller) creates physical link between subscriber (MS) and BTS, then
manage and controls functions of it.
2.4.1.3 Mobile Station (Subscriber)
MS consists of a mobile unit and a smart card which is also referred as a subscriber Identity
Module (SIM) card. This card fitted with the GSM Modem and gives the user more personal
mobility. The equipment itself is identified by a unique number known as the International
Mobile Equipment Identity (IMEI).
GSM, together with other technologies, is part of the evolution of wireless mobile
telecommunications that includes
High-Speed Circuit-Switched Data (HSCSD).
General Packet Radio System (GPRS).
Enhanced Data GSM Environment (EDGE).
Universal Mobile Telecommunications Service (UMTS).
2.4.2 GSM Modem [5]
GSM modem is a specialized type of modem which accepts a SIM card, and operates over a
subscription to a mobile operator, just like a mobile phone. From the mobile operator
perspective, a GSM modem looks just like a mobile phone.
When a GSM modem is connected to a computer, this allows the computer to use the GSM
modem to communicate over the mobile network. While these GSM modems are most
frequently used to provide mobile internet connectivity, many of them can also be used for
sending and receiving SMS and MMS messages.
A GSM modem can be a dedicated modem device with a serial, USB or Bluetooth
connection, or it can be a mobile phone that provides GSM modem capabilities.
GSM modem is used as a generic term to refer to any modem that supports one or more of
the protocols in the GSM evolutionary family, including the 2.5G technologies GPRS and
EDGE, as well as the 3G technologies WCDMA, UMTS, HSDPA and HSUPA.
CHAPTER TWO LITERATURE REVIEW
10
To transmit data using GSM Modem, there are various methods that can be used, such as:
SMS
CSD or HSCSD
GPRS / UMTS
2.5 Processing and Controlling
2.5.1 Raspberry Pi [6]
The Raspberry Pi (short: RPi or RasPi) is an ultra-low-cost credit-card sized Linux computer
which was conceived with the primary goal of teaching computer programming to children. It
was developed by the Raspberry Pi Foundation, which is a UK registered charity, with the
intention of promoting the teaching of basic computer science in schools.
Figure 2-2: Raspberry Pi Logo
2.5.1.1 Raspberry Pi Generations:
The first generation is Raspberry Pi 1 Model B, followed by the simpler and
cheaper Model A.
Raspberry Pi 1 Model B+: A board with an improved design.
Raspberry Pi 2: More RAM is added.
Raspberry Pi Zero: Smaller size, reduced input/output (I/O) and general-purpose
input/output (GPIO) capabilities.
CHAPTER TWO LITERATURE REVIEW
11
Raspberry Pi 3 Model B: Bundled with on-board WiFi, Bluetooth and USB boot
capabilities.
Raspberry Pi 3 Model B: it is the newest mainline Raspberry Pi.
Raspberry Pi Zero W: it is identical to the Raspberry Pi Zero, but has the Wi-Fi and
Bluetooth functionality of the Raspberry Pi 3
Raspberry Pi models have either 26 pinout pins (Raspberry Pi 1 Models A and B) or 40 pins.
In this project, Raspberry Pi 2 model B is used.
Figure 2-3: Raspberry Pi 2 Model B
2.5.1.2 General Properties:
All models feature a Broadcom system on a chip (SoC), which includes
an ARM compatible central processing unit (CPU) and an on-chip graphics processing
unit (GPU, a VideoCore IV).
The Foundation provides Raspbian, a Debian-based Linux distribution for download, as well as
third-party Ubuntu, Windows 10 IOT Core, RISC OS, and specialized media center distributions.
It promotes Python and Scratch as the main programming language, with support for many other
languages. The default firmware is closed source, while an unofficial open source is available.
CHAPTER TWO LITERATURE REVIEW
12
2.5.1.3 Raspberry Pi Hardware
The Processor: This chip is a 32 bit, 700 MHz System on a Chip, which is built on the
ARM11 architecture.
USB port: Most boards have between one and four USB slots
Ethernet port
Status LEDs: Provide visual feedback.
Analog Audio output: This is a standard 3.5mm mini analog audio jack, intended to drive
high impedance loads.
Power input: MicroUSB connector is used to supply power.
General Purpose Input and Output (GPIO) and other pins: A physical interface between
the PI and the outside world.
The Display Serial Interface (DSI) connector: This connector accepts a 15 pin flat ribbon
cable that can be used to communicate with a LCD or OLED display screen.
The Camera Serial Interface (CSI) connector
P2 and P3 headers: These two rows of headers are the JTAG testing headers for the
Broadcom chip (P2) and the LAN9512 networking chip (P3).
2.5.1.4 External Peripherals
Power supply: A microUSB adapter that can provide 5V and at least 700mA of current is
used.
An SD/microSD Card: At least 4GB, and it should be a class 4 or a higher class (up to
class 10).It is used to store the operating system and the programs.
VGA to HDMI convertor: Needed if the Raspberry Pi is connected to a screen.
2.5.1.5 Raspberry Pi Operating System
Many options are available. But most of them are Linux OS.
The install manager for Raspberry Pi is NOOBS. The OSs included with NOOBS are:
RISC OS
Pidora (Fedora Remix)
Raspbmc
Archlinux ARM
OpenELEC
Raspbian
In the project, Raspbian OS is used.
CHAPTER TWO LITERATURE REVIEW
13
2.5.2 Python
Python is a powerful high-level programming language for general purpose programming that is
easy to use (easy to read and write). It is created by Guido Van Rossum and first released in
1991. It is capable of exception handling and interfacing with the Amoeba operating system.
Among the several different languages available to be used with RPI, python was used in this
project for a couple of reasons. Python has a large and comprehensive standard library. Besides,
Python’s syntax is very clear, with an emphasis on readability because it uses English keywords.
2.6 Similar Papers and Researches
2.6.1 Detection of Over Speeding Vehicles on Highways[7]
The entire implementation requires an IR transmitter, an IR receiver, a control circuit and a
buzzer. The speed limit is set by the police who use the system depending upon the traffic at the
certain location. The time taken by the vehicle to travel from one set point to the other is
calculated by control circuit and displayed on seven segment displays. Moreover, if the vehicle
crosses the speed limit, a buzzer sounds alerting the police.
2.6.2 Automated Over Speeding Detection and Reporting System [8] The system involves a speed gun which is used to check for over-speeding of vehicles by placing
it in the direction of moving vehicle. This involves manpower with a person holding the gun. If
over-speeding is detected, the person informs the Toll where the vehicle can be charged.
2.6.3 Car Over speed Detector [9]
This project consists of two pairs of transmitter-receiver. A microcontroller calculates the speed
(displacement/time). If the speed exceeds the particular limit the buzzer buzzes.
CHAPTER THREE METHODOLOGY
14
CHAPTER THREE
METHODOLOGY
3.1 Introduction
This chapter illustrates the phases that the project has gone through, beginning with the initiation
phase, planning, design and concluding with the implementation procedures.
3.2 Initiating the project
The project idea was proposed by the Nile Center for technology researches and an approval
from the department was obtained. The planning for the project started in January 2017 and the
final project form was agreed on with the supervisor.
3.3 Planning the project
After the project approval, a comprehensive plan was set up.
The required components were specified.
The project was divided into small modules. The technologies to be used were stated and the
learning process started.
CHAPTER THREE METHODOLOGY
15
Figure 3-1: Involved Technologies
3.4 System Design
The design of the system has passed through several steps; each one took a specified amount of
time to be completed.
The system is formed of four units:
1. Location (GPS).
2. Processing (RPI).
3. Communication unit.
4. Web serving and Maps.
Each unit will be explained next in details.
3.4.1 Location (GPS)
The purpose of this module is to acquire the speed, location of the vehicle and record the time of
data acquisition
CHAPTER THREE METHODOLOGY
16
The data is sent in standardized protocol called NMEA which is developed for communication
between electronic marine instruments. It uses a simple ASCII, serial communications protocol.
Data is transmitted in the form of "sentences".
3.4.1.1 Message Structure
The NMEA sentence starts with $, followed by two characters identifying the talker and three
others identifying the type of the message. Then the data field is followed by an asterisk if a
checksum is supplied.
NMEA sentence structure
The GPS receiver performs a two-dimensional sequential search process for satellite signals. It
looks for at least four visible satellites. A LED blinks at about 1 Hz while it's searching for
satellites and blinks once every 15 seconds when a fix is found.
The measurements must be taken under a clear view of the sky and in area that doesn't contain
tall buildings which block the signal, however this is not the case in highways.
CHAPTER THREE METHODOLOGY
17
3.4.2 Processing (RPI)
The RPI continuously checks the value of the speed, if it was above the allowed limit (80 km/h
in Sudan) the buzzer's pin is derived high to warn the driver. If the driver didn't slow down
within 7 seconds, the infraction is reported.
3.4.2.1 Reporting Methodology
A message contains the plate number, location, speed value, date and time of the infraction is
stored in the database and then sent to the web server.
The infraction is displayed in the web page-the monitoring side- and the driver is charged later.
Sometimes, due to various causes, the network signal may become poor, that's why the
information is stored in the database so it can be sent when the signal is strong again.
Also the accumulation of data allows statistical analysis to be carried out which plays an
important role in stating policies and any other decisions by the responsible authorities.
3.4.3 Communication
A network is established to allow the Raspberry Pi to connect with a server through Ethernet
cable. The RPI represents the client-side and the laptop represents the server-side.
To transfer the data from the Raspberry Pi to the server, both of them were given static IPs.
CHAPTER THREE METHODOLOGY
18
Figure 3-2: Server Configuration
Client Configurations:
Firstly, SSH is enabled by the following command:
sudo raspi-config
Interfacing options window is displayed from which SSH is enabled.
Then the interface file is edited to set the network configuration:
sudo nano/etc/network/interfaces
A static IP is set. It must be of the same class and gateway of the server.
The bind-address in MySQL configuration file should be edited to allow the Raspberry Pi to
connect to the MySQL database.
The configuration file is found in
.\xampp\mysql\bin\my.ini.
Bind-address parameter is changed to 0.0.0.0.
(The default value is 127.0.0.1, which allows only the local computer to connect).
CHAPTER THREE METHODOLOGY
19
For auto start of the system, the executable python program is added to the boot.
Commands:
sudo bash #switching for root to have administrator privilages
chmod +x code.py #Make the file executable
nano /etc/rc.local
The execution file is added to the boot by adding
/home/pi/file.py
in the startup
3.4.3.1 PuTTY
It is a free implementation of SSH and Telnet for Windows and UNIX platforms, along with an
Xterm terminal emulator, serial console and network file transfer application.
3.4.4 Web Serving
3.4.4.1 XAMPP Server
XAMPP: Cross-Platform, Apache HTTP Server, MySQL, PHP and Perl.
Cross Platform means it works equally well on Linux, Mac and Windows.
It is a development environment that contains Apache server, MariaDB database, PHP, and Perl
interpreters. It is an open source package.
Apache
It is a free and open-source cross-platform web server software.
MySQL
It is an open source relational database management system (database server). MySQL is a
central component of the XAMPP web application software stack.
CHAPTER THREE METHODOLOGY
20
PHP
PHP: Hypertext Preprocessor. It is a widely used open source general purpose scripting
language that is especially suited for web development and can be embedded into HTMLP
3.4.4.2 phpMyAdmin
It is a free and open source tool written in PHP intended to handle the administration of MySQL
with the use of a web browser. It can perform various tasks such as creating, modifying or
deleting databases, tables, fields or rows, executing SQL statements, or managing users and
permissions.
3.4.4.3 Web Page
Main building components are HTML and CSS.
HTML
HTML: Hypertext Markup Language. It is the standard markup language for creating web pages
and web applications. It is used to interpret and compose text, images, and other material into
visual or audible web pages.
CSS
CSS: Cascading Style Sheets. It is a stylesheet language used to describe the presentation of a
document written in HTML. It describes how elements should be rendered on screen, on paper,
in speech, or on other media.
CHAPTER FOUR IMPLEMENTATION AND RESULTS
21
CHAPTER FOUR
IMPLEMENTATION AND RESULTS
4.1 Introduction
This chapter shows the implementation details of the vehicle over speed detection system,
including a brief description of the hardware components and software tools.
Also, the results are displayed and discussed. Moreover, the challenges we have faced during the
implementation phase are represented.
4.2 System Implementation
The system can be divided into two main parts: hardware and software.
4.2.1 Hardware
4.2.1.1 GPS Module:
Among the available technologies to be used in measuring the speed of the vehicles, the GPS
technology was chosen due to a major reason. It provides multiple and accurate data items,
including the speed, location, date and time, which are the pieces of information we are
interested in. Other technologies, for example IR sensor based systems, require separate
components for measuring each of the three data items.
In this project, Adafruit Ultimate GPS is used. This one was certainly chosen according to
restricted specifications:
Low Power consumption. It can be powered by the Raspberry Pi, i.e. no external power
source is needed.
Accurate speed readings.
Readings are updated every few seconds (every 2 seconds)
Acceptable fault range (less than 100 meters)
CHAPTER FOUR IMPLEMENTATION AND RESULTS
22
Figure 4-2: Adafruit GPS
4.2.1.2 GPS Antenna
An additional antenna was needed to strengthen the signal coming from the satellites in order to
make the GPS find a fix in a small time. This antenna draws about 10mA and gives an additional
28 dB of gain.
Figure 4-3: External GPS Antenna
CHAPTER FOUR IMPLEMENTATION AND RESULTS
23
4.2.1.3 SMA to UFL Adapter Cable
This cable was used to connect the GPS with the GPS antenna.
Figure 4-4: SMA to UFL Adapter Cable
4.2.1.4 USB to TTL Cable
This cable was used to connect the RPI with the GPS. Inside the USB plug there is a USB to
Serial conversion chip and at the end of the 36 cable there are four wires as shown below:
Red power: provides the 5V – 500mA direct from the USB port.
Black: ground
White: RX into USB port. It provides 3.3V
Green: TX out of the USB port. It provides 3.3V
CHAPTER FOUR IMPLEMENTATION AND RESULTS
24
Figure 4-5: USB to TTL Cable
4.2.1.5 Ethernet Cable
This cable was used to connect the Raspberry Pi with the server.
Figure 4-6: Ethernet Cable
4.2.1.6 Raspberry Pi
RPI 2 Model B was chosen to be the processing and controlling unit of the project since it
satisfies the required specifications. It has 512 MB RAM, two USB ports, a 10/100 Mbps
CHAPTER FOUR IMPLEMENTATION AND RESULTS
25
Ethernet.
Figure 4-7: Raspberry Pi
4.2.1.7 SD Card
It is used to store the operating system and programs. The Raspberry Pi should work with any
compatible SD card, although there are some guidelines that should be followed:
SD card size:
For installation of NOOBS, the minimum recommended card size is 8GB.
SD card class:
The card class determines the write speed for the card; a class 4 card will be able to write at
4MB/s, whereas a class 10 card will be able to write at 10MB/s.
In this project 16 GB, class 10 micro SD card with adapter is used.
Figure 4-8: SD Card
CHAPTER FOUR IMPLEMENTATION AND RESULTS
26
4.2.1.8 Power Supply
In our system a LINDO power bank model 310 with capacity of 80000mAh 29.6 Wh and output
5V -2A was used to supply the Raspberry Pi with the required power.
In the real implementation the device will be powered from the vehicle battery.
Figure 4-9: Power Bank
4.2.1.9 Buzzer
An electric buzzer was used to alarm the driver when he exceeds the speed limit. It operates in
the range of (3-24) V.
Figure 4-10: Buzzer
4.2.2 Software
There are many software tools used in this project. Some of them are listed below:
CHAPTER FOUR IMPLEMENTATION AND RESULTS
27
4.2.2.1 LX Terminal
This terminal allows a user to directly manipulate his system (in this case RPI) through
commands and scripts.
Figure 4-11: LX Terminal
4.2.2.2 XAMPP
XAMPP was used to create a local web server for testing and deployment purposes (Local
Hosting).
Figure 4-12: XAMPP
CHAPTER FOUR IMPLEMENTATION AND RESULTS
28
4.2.2.3 PuTTY
PUTTY is a terminal emulator for the Raspberry Pi. It was used to operate the RPI headless
without a need for a monitor.
Figure 4-13: PuTTY Terminal
4.2.2.4 phpMyAdmin
It is used for the administration of MySQL database with the use of a web browser.
CHAPTER FOUR IMPLEMENTATION AND RESULTS
29
4.3 Hardware implementation
4.3.1 Interfacing the GPS with the RPI
The GPS was connected with the RPI using USB to TTL cable. The GPSD understands the GPS
message and can make use of it. Figure 14-4 shows the connection between the GPS and the
RPI.
Figure 4-14: Interfacing the GPS with the RPI
Figure 4-15: GPS Readings
CHAPTER FOUR IMPLEMENTATION AND RESULTS
30
4.3.2 System Implementation
Figure 4-16: System Implementation
4.4 Software Implementation
The software implementation process was divided into three parts:
4.4.1 RPI Software
This is the code which converts the GPS readings into raw text, stores them in a database server
and controls the operation of the whole system.
It was written using Python programming language through Python IDLE which is already
provided in Raspbian; the RPI operating system.
CHAPTER FOUR IMPLEMENTATION AND RESULTS
31
4.4.2 Connection to MySQL
This code inserts the acquired data from the client into the database server.
4.4.3 Web Page Software
A free template was customized and edited. Some libraries were installed, e.g, Bootstrap, to
support additional features.
It worth mentioning that the main libraries needed in the project are:
GPSD
Python MySQLdb
MySQL Server
Open SSH Server
4.5 Testing
Each unit was tested separately to ensure it has a proper response.
4.5.1 RPI Testing:
Raspbian OS was installed on a SD card. The card was inserted into the RPI and the latter was
connected to the power supply. The status LEDs lighted indicating that there is no failure or fault
with the chip.
CHAPTER FOUR IMPLEMENTATION AND RESULTS
32
The RPI was connected to a screen with a VGA to HDMI converter to ensure that the OS was
successfully installed.
4.5.2 Internet Connection Testing:
Internet access was needed to download the required libraries.
The RPI model we are using doesn't support WiFi. So USB tethering feature was used instead.
4.5.2.1 USB tethering configurations are as following:
1. Booting Raspberry Pi
2. In the startup screen the following command is entered to open the file “interfaces”
sudo nano /etc/network/interfaces
3. The line “iface usb0 inet dhcp” is added below the following lines
CHAPTER FOUR IMPLEMENTATION AND RESULTS
33
auto eth0
iface eth0 inet dhcp
4. The file is saved
5. Rebooting Raspberry Pi by executing the command
sudo reboot
To test the internet access, a ping request to google was issued and a reply is received indicating
successful connection.
Figure 4-17: Pinging Google
4.5.3 GPS Testing:
The GPSD library was installed then the GPS was wired to the Raspberry Pi.
CHAPTER FOUR IMPLEMENTATION AND RESULTS
34
Figure 4-18: GPS Connections
The GPS readings were checked with the following command:
cgps -s
Figure 4-19: GPS Readings
CHAPTER FOUR IMPLEMENTATION AND RESULTS
35
The readings were reasonable.
4.5.4 External Antenna Testing:
After adding it to the system it took it a little time to find a fix and the signal was stable.
4.5.5 Buzzer Testing
It was connected with +3.3 V and ground. It beeped.
4.5.6 Network Testing
A local network containing the RPI and the laptop was established. Ping command was used to
test the communication between the network devices.
At first, no reply was received. After a lot of search and trials the cause of the problem was
determined. It turned out that the windows firewall is configured to block the ping request. The
problem was solved by reconfiguring the firewall and setting the bind address to 0.0.0.0 instead
of 127.0.0.1
Pinging the Raspberry Pi
Figure 4-20: Pinging the Raspberry Pi
CHAPTER FOUR IMPLEMENTATION AND RESULTS
36
Pinging the laptop
Figure 4-21: Pinging the Server
4.5.6 System Testing
The system was developed till completion and tested on a moving car. The results were accurate
and all the required outputs were met. No modifications were needed.
The speed limit was set to 10 Km/h for testing purposes due to the traffic congestion.
4.6 Results
The results of the final implementation are:
The speed was measured accurately; GPS speed readings matched the car’s speedometer
readings.
Speeds above the specified limit were successfully reported after the buzzer alarmed the
driver.
CHAPTER FOUR IMPLEMENTATION AND RESULTS
37
The database and webpage were continuously updated without realizable amount of
delay.
Figure 4-22: Database
CHAPTER FIVE CONCLUSION AND FUTURE WORK
39
CHAPTER FIVE
CONCLUSION AND FUTURE WORK
5.1 Conclusion
The main objective of the project, which is the design and implementation of vehicle over-speed
detection system has been achieved successfully, the project status can be elaborated as follows:
The system can measure the speed of a vehicle accurately. If the speed exceeded the
allowed limit, the driver is alarmed and given a chance to slow down.
If the driver didn't slow down within the specified time, an infraction is reported.
A web page is designed from which the authorities can get access to the list of over
speeding infractions.
5.2 Problems and Limitations
The GPS was sensitive to weather variations. It needs a clear sky.
The system is implemented on a local host due to the expensive fees required to rent a
server
5.3 Future Work
Using global domain and online hosting.
Adding more features to the system, e.g., connecting it with google map for location
identification.
Guarantee secure connections.
Manufacturing a product that is well-packed and protected from tampering
40
References
[1] WHO, “Road safety- Speed,” p. 2, 2004.
[2] T. Mai, “National,” 2015.
[3] M. Rouse, “What is GSM (Global System for Mobile communication)? - Definition from
WhatIs.com.” [Online]. Available:
http://searchmobilecomputing.techtarget.com/definition/GSM.
[4] “GSM @ searchmobilecomputing.techtarget.com.”
[5] “GSM Modem” [Online]. Available: https://www.nowsms.com/faq/what-is-a-gsm-
modem. [Accessed: 01-Sep-2017].
[6] “Raspberry Pi” [Online]. Available: https://elinux.org/RPi_Hub. [Accessed: 01-Sep-
2017].
[7] “Monika Jain1, Praveen Kumar2, Priya Singh “Detection of Over Speeding Vehicles on
Highways,” vol. 4, no. 4, pp. 613–619, 2015.
[8] “Automated Over Speeding Detection and Reporting System” vol. 4, no. 4, pp. 613–619, 2015.
[9] “http://www.projecttopics.info/Embedded/Car-Overspeed-Detector.php”
[10] https://learn.adafruit.com/adafruit-ultimate-gps-on-the-raspberry-pi
1
APPENDIX A
Vehicle Over Speed Detection System Codes
A-1 RPI Code:
import RPi.GPIO as GPIO
import os
from gps import *
import MySQLdb as mdb
import time
import threading
db = MySQLdb.connect(host="168.254.130.134",user="root",passwd="root",db="reports")
cur = db.cursor()
GPIO.setmode(GPIO.BOARD)
gpsd = None #seting the global variable
os.system('clear') #clear the terminal (optional)
class GpsPoller(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
global gpsd #bring it in scop
40
gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info
self.current_value = None
self.running = True #setting the thread running to true
def run(self):
global gpsd
while gpsp.running:
gpsd.next() #this will continue to loop and grab EACH set of gpsd info to clear the buffer
if __name__ == '__main__':
gpsp = GpsPoller() # create the thread
try:
gpsp.start() # start it up
while True:
#It may take a second or two to get good data
os.system('clear')
print 'speed (m/s) ' , gpsd.fix.speed
speed= gpsd.fix.speed
if speed >= 80:
GPIO.setup(11,GPIO.OUT)
GPIO.output(11,GPIO.HIGH)
time.sleep(7)
GPIO.output(11,GPIO.LOW)
if speed >= 80:
41
cur.execute("insert into company(plate,speed) values (%s,%s)",('1',str(speed)))
cur = db.cursor()
db.commit()
except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
print "\nKilling Thread..."
gpsp.running = False
gpsp.join() # wait for the thread to finish what it's doing
print "Done.\nExiting."
42
A-2Web page Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Bare - Start Bootstrap Template</title>
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- Custom styles for this template -->
<style>
body {
padding-top: 54px;
}
@media (min-width: 992px) {
body {
padding-top: 56px;
}
}
43
</style>
</head>
<body>
<body>
<div class="container">
<div class="row">
<table class="table">
<thead>
<tr>
<th>Plate Number</th>
<th>Speed</th>
<th>Date & Time</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "reports";
// Create connection
$conn = new mysqli($servername, $username,
$password, $dbname);
// Check connection
44
if ($conn->connect_error) {
die("Connection failed: " . $conn-
>connect_error);
}
$sql = "SELECT * FROM company";
$result = $conn->query($sql);
?>
<?php
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>".$row['plate']."</td>";
echo "<td>".$row['speed']."</td>";
echo "<td>".$row['time']."</td>";
echo "</tr>";
}
?>
</tr>
</tbody>
</table>
</div>
</div>
</body>
<!-- Bootstrap core JavaScript -->
Top Related