You are on page 1of 63

Abstract

Objective: The purpose of this project is to independently create a vehicle tracking system based on GPS and GSM technology using the Arduino
Uno microcontroller.

Material and Methods: We interfaced a GSM module SIM 300, a 16x2 LCD
display and GPS module with an Arduino Uno. We then burned the requisite code to the microcontroller using Arduino IDE. The coordinates of the
current location were displayed in the LCD display and sent as a text
message to the input number using SIM card in the GSM module.

Results: The data was successfully received as expected.

Chapter 1
Introduction to VTS
1.1 Introduction
Vehicle Tracking System (VTS) is the technology used to determine the location of a
vehicle using different methods like GPS and other radio navigation systems operating
through satellites and ground based stations. By following triangulation or trilateration methods the tracking system enables to calculate easy and accurate location of the vehicle. Vehicle
information like location details, speed, distance traveled etc. can be viewed on a digital
mapping with the help of a software via Internet. Even data can be stored and downloaded to
a computer from the GPS unit at a base station and that can later be used for analysis. This
system is an important tool for tracking each vehicle at a given period of time and now it is
becoming increasingly popular for people having expensive cars and hence as a theft prevention and retrieval device.
The system consists of modern hardware and software components enabling one to track
their vehicle online or offline. Any vehicle tracking system consists of mainly three parts mobile
vehicle unit, fixed based station and, database and software system.
i.

Vehicle Unit: It is the hardware component attached to the vehicle having either a GPS/

GSM modem. The unit is configured around a primary modem that functions with the tracking
software by receiving signals from GPS satellites or radio station points with the help of antenna.
The controller modem converts the data and sends the vehicle location data to the server.
ii.

Fixed Based Station: Consists of a wireless network to receive and forward the data to

the data center. Base stations are equipped with tracking software and geographic map useful for
determining the vehicle location. Maps of every city and landmarks are available in the based
station that has an in-built Web Server.
iii.

Database and Software: The position information or the coordinates of each visiting

points are stored in a database, which later can be viewed in a display screen using digital maps.
However, the users have to connect themselves to the web server with the respective vehicle ID
stored in the database and only then s/he can view the location of vehicle traveled.

1.2 Vehicle Security using VTS


Vehicle Security is a primary concern for all vehicle owners. Owners as well as researchers are always on the lookout for new and improved security systems for their vehicles. One has to be thankful for the upcoming technologies, like GPS systems, which enables
the owner to closely monitor and track his vehicle in real-time and also check the history of
vehicles movements. This new technology, popularly called Vehicle Tracking Systems has
done wonders in maintaining the security of the vehicle tracking system is one of the biggest
technological advancements to track the activities of the vehicle. The security system uses
Global Positioning System GPS, to find the location of the monitored or tracked vehicle and
then uses satellite or radio systems to send to send the coordinates and the location data to
the monitoring center. At monitoring center various softwares are used to plot the Vehicle on
a map. In this way the Vehicle owners are able to track their vehicle on a real-time basis. Due
to real-time tracking facility, vehicle tracking systems are becoming increasingly popular
among owners of expensive vehicles

Figure 1.1 Vehicle tracking system

The vehicle tracking hardware is fitted on to the vehicle. It is fitted in such a manner
that it is not visible to anyone who is outside the vehicle. Thus it operates as a covert unit
which continuously sends the location data to the monitoring unit.
When the vehicle is stolen, the location data sent by tracking unit can be used to find
the location and coordinates can be sent to police for further action. Some Vehicle tracking

System can even detect unauthorised movements of the vehicle and then alert the owner.
This gives an edge over other pieces of technology for the same purpose
Monitoring center Software helps the vehicle owner with a view of the location at
which the vehicle stands. Browsing is easy and the owners can make use of any browser and
connect to the monitoring center software, to find and track his vehicle. This in turn saves a
lot of effort to find the vehicle's position by replacing the manual call to the driver.
As we have seen the vehicle tracking system is an exciting piece of technology for vehicle security. It enables the owner to virtually keep an eye on his vehicle any time and from
anywhere in the world.
A vehicle tracking system combines the installation of an electronic device in a vehicle,
or fleet of vehicles, with purpose-designed computer software at least at one operational
base to enable the owner or a third party to track the vehicle's location, collecting data in the
process from the field and deliver it to the base of operation. Modern vehicle tracking systems commonly use GPS or GLONASS technology for locating the vehicle, but other types
of

automatic vehicle location technology can also be used. Vehicle information can be

viewed on electronic maps via the Internet or specialized software. Urban public transit authorities are an increasingly common user of vehicle tracking systems, particularly in large
cities.
Vehicle tracking systems are commonly used by fleet operators for fleet management
functions such as fleet tracking, routing, dispatch, on-board information and security. Along
with commercial fleet operators, urban transit agencies use the technology for a number of
purposes, including monitoring schedule adherence of buses in service, triggering changes
of buses' destination sign displays at the end of the line (or other set location along a bus
route), and triggering pre-recorded announcements for passengers. The American Public
Transportation Association estimated that, at the beginning of 2009, around half of all transit
buses in the United States were already using a GPS-based vehicle tracking system to trigger
automated stop announcements. This can refer to external announcements (triggered by the
opening of the bus's door) at a bus stop, announcing the vehicle's route number and destination, primarily for the benefit of visually impaired customers, or to internal announcements
(to passengers already on board) identifying the next stop, as the bus (or tram) approaches a
stop, or both. Data collected as a transit vehicle follows its route is often continuously fed

into a computer program which compares the vehicle's actual location and time with its
schedule, and in turn produces a frequently updating display for the driver, telling him/her
how early or late he/she is at any given time, potentially making it easier to adhere more
closely to the published schedule. Such programs are also used to provide customers with
real-time information as to the waiting time until arrival of the next bus or tram/streetcar at a
given stop, based on the nearest vehicles' actual progress at the time, rather than merely giving information as to the scheduled time of the next arrival. Transit systems providing this
kind of information assign a unique number to each stop, and waiting passengers can obtain
information by entering the stop number into an automated telephone system or an application on the transit system's website. Some transit agencies provide a virtual map on their
website, with icons depicting the current locations of buses in service on each route, for customers' information, while others provide such information only to dispatchers or other employees.
Other applications include monitoring driving behaviour, such as an employer of an
employee, or a parent with a teen driver.
Vehicle tracking systems are also popular in consumer vehicles as a theft prevention and
retrieval device. Police can simply follow the signal emitted by the tracking system and locate
the stolen vehicle. When used as a security system, a Vehicle Tracking System may serve as either an addition to or replacement for a traditional car alarm. Some vehicle tracking systems
make it possible to control vehicle remotely, including block doors or engine in case of emergency. The existence of vehicle tracking device then can be used to reduce the insurance cost,
because the loss-risk of the vehicle drops significantly.

Vehicle tracking systems are an integrated part of the "layered approach" to vehicle
protection, recommended by the National Insurance Crime Bureau (NICB) to prevent motor
vehicle theft. This approach recommends four layers of security based on the risk factors pertaining to a specific vehicle. Vehicle Tracking Systems are one such layer, and are described
by the NICB as very effective in helping police recover stolen vehicles.
Some vehicle tracking systems integrate several security systems, for example by sending an automatic alert to a phone or email if an alarm is triggered or the vehicle is moved
without authorisation, or when it leaves or enters a geofence.

1.3 Active versus Passive Tracking


5

Several types of vehicle tracking devices exist. Typically they are classified as "passive" and "active". "Passive" devices store GPS location, speed, heading and sometimes a
trigger event such as key on/off, door open/closed. Once the vehicle returns to a predetermined point, the device is removed and the data downloaded to a computer for evaluation.
Passive systems include auto download type that transfer data via wireless download. "Active" devices also collect the same information but usually transmit the data in real-time via
cellular or satellite networks to a computer or data center for evaluation.
Many modern vehicle tracking devices combine both active and passive tracking abilities: when a cellular network is available and a tracking device is connected it transmits data
to a server; when a network is not available the device stores data in internal memory and
will transmit stored data to the server later when the network becomes available again.
Historically vehicle tracking has been accomplished by installing a box into the vehicle,
either self-powered with a battery or wired into the vehicle's power system. For detailed vehicle locating and tracking this is still the predominant method; however, many companies
are increasingly interested in the emerging cell phone technologies that provide tracking of
multiple entities, such as both a salesperson and their vehicle. These systems also offer tracking of calls, texts, and Web use and generally provide a wider range of options.
1.4 History of Vehicle Tracking
GPS or Global Positioning Systems were designed by the United States Government
and military, which the design was intended to be used as surveillance. After several years
went by the government signed a treaty to allow civilians to buy GPS units also only the
civilians would get precise downgraded ratings.
Years after the Global Positioning Systems were developed the military controlled the
systems despite that civilians could still purchase them in stores. In addition, despite that Europe has designed its own systems called the Galileo the US military still has complete control.
GPS units are also called tracking devices that are quite costly still. As more of these
devices develop however the more affordable the GPS can be purchased. Despite of the innovative technology and designs of the GPS today the devices has seen some notable
changes or reductions in pricing. Companies now have more access to these devices and
many of the companies can find benefits.
6

These days you can pay-as-you go or lease a GPS system for your company. This
means you do not have to worry about spending upfront money, which once stopped companies from installing the Global positioning systems at one time.
Todays GPS applications have vastly developed as well. It is possible to use the Global
Positioning Systems to design expense reports, create time sheets, or reduce the costs of fuel
consumption. You can also use the tracking devices to increase efficiency of employee driving. The GPS unit allows you to create Geo-Fences about a designated location, which
gives you alerts once your driver(s) passes through. This means you have added security
combined with more powerful customer support for your workers.
Todays GPS units are great tracking devices that help fleet managers stay in control of
their business. The applications in todays GPS units make it possible to take full control of your
company. It is clear that the tracking devices offer many benefits to companies, since you can
build automated expense reports anytime.

GPS units do more than just allow companies to create reports. These devices also help
to put an end to thieves. According to recent reports, crime is at a high, which means that car
theft is increasing. If you have the right GPS unit, you can put an end to car thefts because
you can lock and unlock your car anytime you choose.
GPS are small tracking devices that are installed in your car and it will supply you with
feedback data from tracking software that loads from a satellite. This gives you more control
over your vehicles.
The chief reason for companies to install tracking devices is to monitor their mobile
workforce. A preventive measure device allows companies to monitor their employees activities. Company workers can no longer take your vehicles to unassigned locations. They will
not be able to get away with unauthorised activities at any time because you can monitor
their every action on a digital screen.
The phantom pixel is another thing some web masters do to get better rankings. Unfortunately it will backfire on you since the search engines do not want this to occur. You see,
the phantom pixel is when you might have a 1 pixel image or an image so small it cannot be
seen by the regular eye. They use the pixel to stuff it with keywords. The search engine can
view it in the code, which is how they know it is there and can give you better rank for the

keywords in theory. Of course since the search engines dont like this phantom pixel you are
instead not getting anything for the extra keywords except sent to the bottomless pit.

1.4.1 Early Technology


In the initial period of tracking only two radios were used to exchange the information.
One radio was attached to the vehicle while another at base station by which drivers were
enabled to talk to their masters. Fleet operator could identify the progress through their
routes.
The technology was not without its limits. It was restricted by the distance which became a hurdle in accuracy and better connectivity between driver and fleet operators. Base
station was dependent on the driver for the information and a huge size fleet could not have
been managed depending on man-power only.
The scene of vehicle tracking underwent a change with the arrival of GPS technology.
This reduced the dependence on man-power. Most of the work of tracking became electronic.
Computers proved a great help in managing a large fleet of vehicle. This also made the information authentic. As this technology was available at affordable cost all whether small or
big fleet could take benefit of this technology
Because of the cheap accessibility of the device computer tracking facilities has come
to stay and associated with enhanced management. Today each vehicle carries tracking unit
which is monitored from the base station. Base station receives the data from the unit.
All these facilities require a heavy investment of capital for the installation of the infrastructure of tracking system for monitoring and dispatching

1.4.2 New development in technology


New system costs less with increased efficiency. Presently it is small tracking unit in
the vehicle with web-based interface, connected through a mobile phone. This device avoids
unnecessary investment in infrastructure with the facility of monitoring from anywhere for
the fleet managers. This provides more efficient route plan to fleet operators of all sizes and
compositions saving money and time.
Vehicle tracking system heralded a new era of convenience and affordability in fleet
management. Thus due to its easy availability it is going to stay for long.

1.5 Vehicle Tracking System Features


Monitoring and managing the mobile assets are very important for any company dealing with the services, delivery or transport vehicles. Information technologies help in supporting these functionalities from remote locations and update the managers with the latest
information of their mobile assets. Tracking the mobile assets locations data and analyzing
the information is necessary for optimal utilization of the assets.
Vehicle Tracking System is a software & hardware system enabling the vehicle owner
to track the position of their vehicle. A vehicle tracking system uses either GPS or radio
technology to automatically track and record a fleet's field activities. Activity is recorded by
modules attached to each vehicle. And then the data is transmitted to a central, internet-connected computer where it is stored. Once the data is transmitted to the computer, it can be
analyzed and reports can be downloaded in real-time to your computer using either web
browser based tools or customized software.

1.5.1 Vehicle Tracking Benefits


An enterprise-level vehicle tracking system should offer customizable reporting tools,
for example to provide a summary of the any day activities. It should have the ability to produce and print detailed maps and reports displaying actual stops, customer locations, mileage
traveled, and elapsed time at each location, and real-time access to vehicle tracking data and
reports. Vehicle tracking system can be active, passive or both depending upon the application. Here are steps involved in the vehicle tracking:
i.

Data capture: Data capturing is the first step in tacking your vehicle. Data in a vehicle

tracking system is captured through a unit called automated vehicle unit. The automated vehicle
unit uses the Global Positioning System (GPS) to determine the location of the vehicle. This unit
is installed in the vehicle and contains interfaces to various data sources. This paper considers the
location data capture along with data from various sensors like fuel, vehicle diagnostic sensors
etc.
ii.

Data storage: Captured data is stored in the memory of the automated vehicle unit.

iii.

Data transfer: Stored data are transferred to the computer server using the mobile net-

work or by connecting the vehicle mount unit to the computer.


iv.

Data analysis: Data analysis is done through software application. A GIS mapping com-

ponent is also an integral part of the vehicle tracking system and it is used to display the correct
location of the vehicle on the map.

1.6 Vehicle Tracking in India


Vehicle tracking system in India is mainly used in transport industry that keeps a realtime track of all vehicles in the fleet. The tracking system consists of GPS device that brings
together GPS and GSM technology using tracking software. The attached GPS unit in the
vehicle sends periodic updates of its location to the route station through the server of the
cellular network that can be displayed on a digital map. The location details are later transferred to users via SMS, e-mail or other form of data transfers.
There are various GPS software and hardware developing companies in India working
for tracking solutions. However, its application is not that much of popular as in other countries like USA, which regulates the whole GPS network. In India it is mostly used in Indian
transport and logistics industry and not much personal vehicle tracking. But with better
awareness and promotion the market will increase. Lets have a look at its current application
in India using vehicle tracking though in less volume.

a) Freight forwarding
Logistic service providers are now increasingly adopting vehicle-tracking system for
better fleet management and timely service. The system can continuously monitor shipment
location and so can direct the drivers directly in case of any change of plan. Fleet managers
can keep an eye on all activities of workers, vehicle over speed, route deviation etc. The driver in turn can access emergency service in case of sickness, accident or vehicle breakdown.
All in turn supports money and time management, resulting better customer service.

b) Call centers
In commercial vehicle segments the taxi operators of various call centers are now using
vehicle tracking system for better information access. However, its application is in its infant
stage in India and if adequate steps are taken in bringing the cost of hardware and software

10

low then it can be used for tracking personal vehicle, farming (tractor), tourist buses, security
and emergency vehicle etc. Again Government needs to cut down the restriction imposed
upon the availability of digital maps for commercial use and this will encourage software industry in developing cost-effective tracking solutions. Though, sales of both commercial and
passenger vehicles are growing but price of tracking service is very high and this is the key
issue in Indian market. Hence, its important for market participants to reduce prices of GPS
chips and other products in order to attract more and more users.
As far as Indian vehicle tracking and navigation market is concerned the recent association of India with Russian Global Navigation Satellite System (GLONASS) will act as a catalyst in the improvement of vehicle tracking system. This will give an advantage in managing traffic, roadways and ports and also as an important tool for police and security agency to
track stolen vehicles. Hence, in near future there is large prospect for the utility of vehicle
tracking system in India, which can revolutionise the way we are communicating.

11

Chapter 2
Fundamentals of Technology
2.1 Overview
VTS technology requires two main technologies:
GSM: To communicate with the mobile phone which functions as a controller
GPS: To obtain the coordinates from the satellites and accurately determine the location of the
tracker
2.2 GSM Technology
GSM (Global System for Mobile communication) is a digital mobile telephony system
that is widely used in Europe and other parts of the world. GSM uses a variation of time division
multiple access (TDMA) and is the most widely used of the three digital wireless telephony
technologies (TDMA, GSM, and CDMA). GSM digitises and compresses 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 MHz or 1800 MHz frequency band.
Mobile services based on GSM technology were first launched in Finland in 1991. Today,
more than 690 mobile networks provide GSM services across 213 countries and GSM represents
82.4% of all global mobile connections. According to GSM World, there are now more than 2
billion GSM mobile phone users worldwide. GSM World references China as "the largest single
GSM market, with more than 370 million users, followed by Russia with 145 million, India with
83 million and the USA with 78 million users."
Since many GSM network operators have roaming agreements with foreign operators,
users can often continue to use their mobile phones when they travel to other countries. SIM
cards (Subscriber Identity Module) holding home network access configurations may be
switched to those will metered local access, significantly reducing roaming costs while experiencing no reductions in service.
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), and Universal Mobile
Telecommunications Service (UMTS).
2.3 GPS Technology
2.3.1 Introduction
The Global Positioning System (GPS) is a satellite-based navigation system made up of a network of 24 satellites placed into orbit by the U.S. Department of Defence. GPS was originally

12

intended for military applications, but in the 1980s, the government made the system available
for civilian use. GPS works in any weather conditions, anywhere in the world, 24 hours a day.
There are no subscription fees or setup charges to use GPS.
2.3.2 Technology
Over the next few years, GPS tracking will be able to provide businesses with a number
of other benefits. Some companies have already introduced a way for a customer has signed
the credit card and managed at local level through the device. Others are creating ways for
dispatcher to send the information re-routing, the GPS device directly to a manager. Not a
new requirement for GPS systems is that they will have access to the Internet and store information about the vehicle as a driver or mechanic GPS device to see the diagrams used to
assist with the vehicle you want to leave. Beyond that all the information be saved and stored
in its database.

2.3.3 Types of GPS Vehicle Tracking


There are three main types of GPS vehicle tracking, tracking based mobile, wireless
passive tracking and satellite in real-time GPS tracking. This article discusses the advantages
and disadvantages to all three types of GPS vehicle tracking circumference.
i)

Mobile phone based tracking


The initial cost for the construction of the system is slightly lower than the other two

options. With a mobile phone-based tracking average price is about $ 500. A cell-based monitoring system sends information about when a vehicle is every five minutes during a rural
network. The average monthly cost is about thirty-five dollars for airtime.
ii)

Wireless Passive Tracking


A big advantage that this type of tracking system is that there is no monthly fee, so that

when the system was introduced, there will be other costs associated with it. But setting the
scheme is a bit 'expensive. The average is about $ 700 for hardware and $ 800 for software
and databases. With this type of system, most say that the disadvantage is that information
about where the vehicle is not only can exist when the vehicle is returned to the base business. This is a great disadvantage, particularly for companies that are looking for a monitoring system that tells them where their vehicle will be in case of theft or an accident. However, many systems are now introducing wireless modems into their devices so that tracking

13

information can be without memory of the vehicle to be seen. With a wireless modem that is
wireless passive tracking systems are also able to gather information on how fast the vehicle
was traveling, stopping, and made other detailed information. With this new addition, many
companies believe that this system is perfect, because there is no monthly bill.
iii)

Via satellite in real time


This type of system provides less detailed information, but work at the national level,

making it a good choice for shipping and trucking companies. Spending on construction of
the system on average about $ 700. The monthly fees for this system vary from five dollars
for a hundred dollars, depending on how the implementation of a reporting entity would be.
2.3.4 Typical Architecture
Major constituents of the GPS based tracking are

i.

GPS tracking device


The device fits into the vehicle and captures the GPS location information apart from
other vehicle information at regular intervals to a central server. The other vehicle
information can include fuel amount, engine temperature, altitude, reverse geocoding, door open/close, tire pressure, cut off fuel, turn off ignition, turn on headlight,
turn on taillight, battery status, GSM area code/cell code decoded, number of GPS
satellites in view, glass open/close, fuel amount, emergency button status, cumulative
idling, computed odometer, engine RPM, throttle position, and a lot more. Capability of these devices actually decides the final capability of the whole tracking system.

ii.

GPS tracking server


The tracking server has three responsibilities: receiving data from the GPS tracking
unit, securely storing it, and serving this information on demand to the user.

iii.

User interface
The UI determines how one will be able to access information, view vehicle data, and
elicit important details from it.

14

Chapter 3
Hardware

3.1 Hardware Components Used:


Arduino UNO Platform
GSM SIM 900a shield
16 x 2 LCD MATRIX
GPS SIM 28M Receiver shield
Resistors

3.2 Microcontroller :
[1]

Microcontroller, as the name suggests, are small controllers. They are like single

chip computers that are often embedded into other systems to function as processing/controlling unit. For example, the remote control you are using probably has micro controllers inside that do decoding and other controlling functions. They are also
used in automobiles, washing machines, microwave ovens, toys etc, where automation is needed. Here we are using AVR AT Mega 328 microcontroller based on Arduino Platform.
Platform refers to hardware architecture with software framework on which other
software can run
3.2.1 Description
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. Arduino can sense the environment by receiving input
15

from a variety of sensors and can affect its surroundings by controlling lights, motors, and other
actuators. The microcontroller on the board is programmed using the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing). Arduino projects can be stand-alone or they can communicate with software running on a computer
(e.g. Flash, Processing, MaxMSP).The boards can be built by hand or purchased preassembled;
the software can be downloaded for free. The hardware reference designs (CAD files) are available under an open-source license, you are free to adapt them to your needs. Arduino received an
Honorary Mention in the Digital Communities section of the 2006 Ars Electronica Prix. The Arduino team is: Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis.

3.2.2 Advantages of Arduino


Arduino is being used in thousands of different projects and applications. The Arduino
software is easy-to-use for beginners, yet flexible enough for advanced users. It runs
on Mac, Windows, and Linux.

It is used by teachers and students to build low cost scientific instruments, to prove chemistry and physics principles, or to get started with programming and robotics.

Designers and architects use it to build interactive prototypes.

Musicians and artists use it for their installations and to experiment with new musical instruments.

Makers use it to build many of the projects exhibited in the market and fairs.

Arduino also simplifies the process of working with microcontrollers, but it offers
some advantage for teachers, students, and interested amateurs over other systems:

Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by
hand, and even the pre-assembled Arduino modules cost less than $50

Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and
Linux operating systems. Most microcontroller systems are limited to Windows.

Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use


for beginners, yet flexible enough for advanced users to take advantage of as well. For

16

teachers, it's conveniently based on the Processing programming environment, so students learning to program in that environment will be familiar with how the Arduino IDE
works.

Open source and extensible software - The Arduino software is published as open
source tools, available for extension by experienced programmers. The language can be
expanded through C++ libraries, and people wanting to understand the technical details
can make the leap from Arduino to the AVR C programming language on which it's
based. Similarly, you can add AVR-C code directly into your Arduino programs if you
want to.

Open source and extensible hardware - The plans of the Arduino boards are published
under a Creative Commons license, so experienced circuit designers can make their own
version of the module, extending it and improving it. Even relatively inexperienced users
can build the breadboard version of the module in order to understand how it works and
save money.

3.2.3 Hardware-Arduino
An Arduino board consists of an 8-bit Atmel AVR microcontroller with complementary
components to facilitate programming and incorporation into other circuits. An important aspect of the Arduino is the standard way that connectors are exposed, allowing
the CPU board to be connected to a variety of interchangeable add-on modules known
as shields. Some shields communicate with the Arduino board directly over various
pins, but many shields are individually addressable via an IC serial bus, allowing many
shields to be stacked and used in parallel. Official Arduinos have used the megaAVR
series of chips, specifically the ATmega8, ATmega168, ATmega328, ATmega1280, and
ATmega2560. A handful of other processors have been used by Arduino compatibles.
Most boards include a 5 volt linear regulator and a 16 MHz crystal oscillator (or ceramic
resonator in some variants), although some designs such as the LilyPad run at 8 MHz
and dispense with the onboard voltage regulator due to specific form-factor restrictions. An Arduino's microcontroller is also pre-programmed with a boot loader that
simplifies uploading of programs to the on-chip flash memory, compared with other
devices that typically need an external programmer.At a conceptual level, when using

17

the Arduino software stack, all boards are programmed over an RS-232 serial connection, but the way this is implemented varies by hardware version. Serial Arduino
boards contain a simple inverter circuit to convert between RS-232-level and TTLlevel signals. Current Arduino boards are programmed via USB, implemented using
USB-to-serial adapter chips such as the FTDI FT232. Some variants, such as the Arduino Mini and the unofficial Boarduino, use a detachable USB-to-serial adapter board
or cable, Bluetooth or other methods. (When used with traditional microcontroller
tools instead of the Arduino IDE, standard AVR ISP programming is used.)The Arduino
board exposes most of the microcontroller's I/O pins for use by other circuits. The
Diecimila, Duemilanove, and current Uno provide 14 digital I/O pins, six of which can
produce pulse-width modulated signals, and six analog inputs. These pins are on the top
of the board, via female 0.1inch headers.

3.2.3.1 The Arduino Family


Arduino makes several different boards, each with different capabilities. In addition, part of being open source hardware means that others can modify and produce derivatives of Arduino
boards that provide even more form factors and functionality. The following is the list of commonly used Arduino Boards:
1. Arduino Uno (R3)
It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a
USB connection, a power jack, a reset button and more. It contains everything needed to support
the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-toDC adapter or battery to get started.

Figure 3.1 Arduino Uno

18

2. LilyPad Arduino
LilyPad is a wearable e-textile technology developed by Leah Buechley and cooperatively designed by Leah and SparkFun. Each LilyPad is creatively designed with large connecting pads
and a flat back to allow them to be sewn into clothing with conductive thread. The LilyPad also
has its own family of input, output, power, and sensor boards that are also built specifically for etextiles.

Figure 3.2 LilyPad Arduino

3. RedBoard
The RedBoard can be programmed over a USB Mini-B cable using the Arduino IDE. Its more
stable due to the USB/FTDI chip being used, plus its completely flat on the back, making it easier to embed in your projects. It can be powered over USB or through the barrel jack. The onboard power regulator can handle anything from 7 to 15VDC.

19

Figure 3.3 RedBoard

4. Arduino Mega (R3)


The Arduino Mega is like the UNOs big brother. It has 54 digital input/output pins (14 can be
used as PWM outputs), 16 analog inputs, a USB connection, a power jack, and a reset button. It
contains everything needed to support the microcontroller; simply connect it to a computer with
a USB cable or power it with a AC-to-DC adapter or battery to get started. The large number of
pins make this board very handy for projects that require a bunch of digital inputs or outputs
(like lots of LEDs or buttons).

Figure 3.4 Arduino Mega (R3)

5. Arduino Leonardo
The Leonardo is Arduinos first development board to use one microcontroller with built-in
USB.

Figure 3.5 Arduino Leonardo

20

3.2.3.2 Arduino UNO


The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It
has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header,
and a reset button. It contains everything needed to support the microcontroller;
simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter
or battery to get started. The Uno differs from all preceding boards in that it does not
use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter. Revision 2 of the
board has the following new features:

1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two other new
pins placed near to the RESET pin, the IOREF that allow the shields to adapt to the voltage provided from the board. In future, shields will be compatible both with the board
that use the AVR, which operate with 5V and with the Arduino Due that operate with
3.3V. The second one is a not connected pin, that is reserved for future purposes.

Stronger RESET circuit.

Atmega 16U2 replace the 8U2.

"Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0.
The Uno and version 1.0 will be the reference versions of Arduino, moving forward.
The Uno is the latest in a series of USB Arduino boards, and the reference model for
the Arduino platform.

Figure 3.6 Arduino Uno Top View and Bottom View

3.2.3.1.a Power

21

The Arduino Uno can be powered via the USB connection or with an external power
supply. The power source is selected automatically. External (non-USB) power can
come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be
connected by plugging a 2.1mm center-positive plug into the board's power jack.
Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER
connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less
than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the
board. The recommended range is 7 to 12 volts.
The power pins are as follows:

VIN. The input voltage to the Arduino board when it's using an external power source (as
opposed to 5 volts from the USB connection or other regulated power source). You can
supply voltage through this pin, or, if supplying voltage via the power jack, access it
through this pin.

5V.This pin outputs a regulated 5V from the regulator on the board. The board can be
supplied with power either from the DC power jack (7 - 12V), the USB connector (5V),
or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses
the regulator, and can damage your board. We don't advise it.

3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50
mA.

GND. Ground pins.

3.2.3.1.b Memory
The ATmega328 has 32 KB (with 0.5 KB used for the boot loader). It also has 2 KB of
SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

3.2.3.1.c Input and Output

22

Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin
can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialised functions:

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data.
These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a


low value, a rising or falling edge, or a change in value. See the attachInterrupt() function
for details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication
using the SPI library.

LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of
resolution (i.e. 1024 different values). By default they measure from ground to 5
volts, though is it possible to change the upper end of their range using the AREF pin
and the analogReference() function. Additionally, some pins have specialized functionality:

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire
library.

There are a couple of other pins on the board:

AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.

23

3.2.3.1.d Communication
The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega16U2
on the board channels this serial communication over USB and appears as a virtual
com port to software on the computer. The '16U2 firmware uses the standard USB
COM drivers, and no external driver is needed. However, on Windows, a .inf file is required. The Arduino software includes a serial monitor which allows simple textual
data to be sent to and from the Arduino board. The RX and TX LEDs on the board will
flash when data is being transmitted via the USB-to-serial chip and USB connection to
the computer (but not for serial communication on pins 0 and 1).
3.2.3.1.e Programming
The Arduino Uno can be programmed with the Arduino software. Select "Arduino Uno
from the Tools > Board menu (according to the microcontroller on your board)..
The ATmega328 on the Arduino Uno comes preburned with a bootloader that allows
you to upload new code to it without the use of an external hardware programmer. It
communicates using the original STK500 protocol

3.2.3.1.f USB Over current Protection


The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts
and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will
automatically break the connection until the short or overload is removed.
3.2.3.1.g Physical Characteristics
The maximum length and width of the Uno PCB are 2.7 and 2.1 inches respectively, with the
USB connector and power jack extending beyond the former dimension. Four screw holes allow
the board to be attached to a surface or case. Note that the distance between digital pins7 and 8 is
160 mil (0.16"), not an even multiple of the 100 mil spacing of the other pins.

24

3.2.4 Pin Diagram

Figure 3.7 Pin Diagram of UNO with mapping of Atmega 328 pins

3.2.5 Summary

Microcontroller

ATmega328

Operating Voltage

5V

Input Voltage (recommended)

7-12V

Input Voltage (limits)

6-20V

Digital I/O Pins

14 (of which 6 provide PWM output)

Analog Input Pins

25

DC Current per I/O Pin

40 mA

DC Current for 3.3V Pin

50 mA

Flash Memory

32 KB (ATmega328) of which 0.5 KB used by bootloader

SRAM

2 KB (ATmega328)

EEPROM

1 KB (ATmega328)

Clock Speed

16 MHz

3.2.6 Block Diagram

Figure 3.8 Block Diagram of Uno

26

Figure 3.9 Arduino Board

3.3 LCD (Liquid Crystal Display)


[7]Frequently,

a program must interact with the outside world using input and output

devices that communicate directly with a human being. One of the most common devices attached to a controller is an LCD display. Some of the most common LCDs connected to the Arduino Uno are 16x2 and 20x2 displays. This means 16 characters per
line by 2 lines and 20 characters per line by 2 lines, respectively.
Fortunately, a very popular standard exists which allows us to communicate with the
vast majority of LCDs regardless of their manufacturer. The standard is referred to as
HD44780U, which refers to the controller chip which receives data from an external
source (in this case, the UNO) and communicates directly with the LCD.
3.3.1 44780 Background

27

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the
data bus. The user may select whether the LCD is to operate with a 4-bit data bus or
an 8-bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines
(3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD
will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus).
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that you are
sending it data. To send data to the LCD, your program should make sure this line is
low (0) and then set the other two control lines and/or put data on the data bus.
When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD),
and end by bringing it low (0) again.
The RS line is the "Register Select" line. When RS is low (0), the data is to be treated
as a command or special instruction (such as clear screen, position cursor, etc.). When
RS is high (1), the data being sent is text data which should be displayed on the
screen. For example, to display the letter "T" on the screen you would set RS high.
The RW line is the "Read/Write" control line. When RW is low (0), the information on
the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read
command. All others are write commands--so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0,
DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
As we've mentioned, the LCD requires either 8 or 11 I/O lines to communicate with.
For the sake of this tutorial, we are going to use an 8-bit data bus--so we'll be using
11 of the 8051's I/O pins to interface with the LCD.
Let's draw a sample pseudo-schematic of how the LCD will be connected to the UNO.

28

Figure 3.10 LCD-Microcontroller Interfacing

As you can see, we've established a 1-to-1 relation between a pin on the UNO and
a line on the 44780 LCD. Thus we write our sketch to access the LCD, by including
library LIQUIDCRYSTAL.H and using the in build functions provided by Arduino IDE.
Following is a list of functions that can be used for LCD.

3.3.2 List of Functions

Hello World: displays "hello world!" and the seconds since reset.

Blink: control of the block-style cursor.

Cursor: control of the underscore-style cursor.

Display: quickly blank the display without losing what's on it.

TextDirection: control which way text flows from the cursor.

Scroll: scroll text left and right.

Serial input: accepts serial input, displays it.

SetCursor: set the cursor position.

29

Autoscroll: shift text right and left.

3.3.3 Pin Diagram

Figure 3.11 LCD Pin diagram

3.4 GSM SIM 900A


The SIM900 is a complete Quad-band GSM/GPRS solution in a SMT module which can
be embedded in the customer applications.
It features an industry-standard interface, the SIM900 delivers GSM/GPRS
850/900/1800/1900MHz performance for voice, SMS, Data, and Fax in a small form
factor and with low power consumption. With a tiny configuration of 24mm x 24mm x
3 mm, SIM900 can fit almost all the space requirements in your M2M application, especially for slim and compact demand of design.

SIM900 is designed with a very powerful single-chip processor integrating AMR926EJ-S


core

Quad - band GSM/GPRS module with a size of 24mmx24mmx3mm

SMT type suit for customer application

An embedded Powerful TCP/IP protocol stack


30

Based upon mature and field-proven platform, backed up by our support service, from
definition to design and production

3.4.1 General Features

Quad-Band 850/ 900/ 1800/ 1900 MHz

GPRS multi-slot class 10/8

GPRS mobile station class B

Compliant to GSM phase 2/2+


o Class 4 (2 W @850/ 900 MHz)
o Class 1 (1 W @ 1800/1900MHz)

Dimensions: 24* 24 * 3 mm

Weight: 3.4g

Control via AT commands (GSM 07.07 ,07.05 and SIMCOM enhanced AT Commands)

SIM application toolkit

Supply voltage range 3.4 - 4.5 V

Low power consumption.

Operation temperature: -30 C to +80 C

3.4.2 Specifications for SMS via GSM/ GPRS

Point-to-point MO and MT

SMS cell broadcast

Text and PDU mode

3.4.3 Drivers

MUX Driver

3.4.4 Interfaces

Interface to external SIM 3V/ 1.8V

analog audio interface

RTC backup

SPI interface

Serial interface

Antenna pad

I2C

GPIO

31

PWM

ADC

3.4.5 Antenna

SMA Antenna
Technical specification
Frequency

2.4-2.5 GHz

Polarization

Linear

Operating Temperature

-40 to 85o

Impedance

50 ohm

Weight

7.4g

Antenna Type

Swivel

Peak Gain

4.1dBi

Efficiency

85%

3.4.6 Compatibility

AT cellular command interface.

Figure 3.12 GSM sim900a

32

3.4.7 Pin Diagram

Figure 3.13 GSM sim900a Pin Diagram

3.5 GPS SIM 28M


This GPS Receiver Modem is based on SIMCOM' Sim28M/Sim28 ML GPS Module. SIM 28
ML is stand-alone or A-GPS receiver with build in LNA. SIM 28M can relax antenna requirement and doesn't need for external LNA. Sim 28ML can track as low as -167 dbm signal even
without network assistance. SIM 28ML has excellent low power consumption
characteristics(acquisition 17mA, tracking 16 mA). Sim 28ML supports various location and
navigation applications including autonomous GPS, QZSS,SBAS ranging(WASS, EGNOS,
GAGAN, MSAS). DGPS and A-GPS.

SIM28 SIM Com presents a high performance and reliable assisted GPS module-SIM28. This is
a standalone L1 frequency GPS module in a SMT type with MTK high sensitivity navigation
engine, which allows you to achieve the industrys highest levels of sensitivity, accuracy and
Time-to-First-Fix (TTFF) with lowest power consumption.
3.5.1 Mechanical Data
Dimensions: 16*12.2*2.4mm
Weight: 1g
Package: SMT
33

3.5.2 Interfaces

Serial interfaces:UART, SPI / IC


Digital I/O EINT0 input
GPIO
Pulse-per-second (PPS)
Protocols NMEA
PMTK

3.5.3 Performance Data

Receiver type 22 tracking/66 acquisition-channel GPS receiver GPS L1, C/A Code
Max update rate 10Hz
Sensitivity1
Tracking -165dBm
Navigation -160dBm
Cold starts -147dBm
Time-To-First-Fix2
Cold starts with EASY: 13s
Warm starts with EASY: 1~2s
Cold starts: 33s
Cold starts with EPO Assist: 13s
Hot starts <1s

3.5.4 Accuracy

Automatic Position3 2.5m CEP


EPO 30days DATA 1.99m
Speed4: 0.1m/s
Operation temperature5 -40 to +85

3.5.5 Electrical Data

Power supply 2.9 V~3.6 V


Power consumption 2,5
Acquisition 23 mA
Tracking 17 mA
Always LocateTM 3 mW
Antenna type Active and passive
Antenna power External or internal VCC_RF

34

3.5.6 Pin Diagram

Figure 3.14 GPS Sim 28M Pin Diagram

Figure 3.15 GPS Sim 28M

35

Chapter 4
Software
[9]Connecting

hardware according to the circuit diagram doesnt work really. You need to pro-

gram the components accordingly so as to work according to the algorithm you have designed in
order to make the project work properly as required. Following is the description of software
used.

4.1 Arduino IDE


The Arduino IDE is a cross-platform application written in Java, and is derived from
the IDE for the Processing programming language and the Wiring project. It is designed to introduce programming to artists and other newcomers unfamiliar with
software development. It includes a code editor with features such as syntax highlighting, brace matching, and automatic indentation, and is also capable of compiling
and uploading programs to the board with a single click. There is typically no need to
edit makefiles or run programs on a command-line interface. Although building on
command-line is possible if required with some third-party tools such as Ino. The Arduino IDE comes with a C/C++ library called "Wiring" (from the project of the same
name), which makes many common input/output operations much easier.

4.1.1 Key Features

Cross-platform program

Open-Source

Different instructions for different OS

Example Programs

4.1.2 Blink Program

36

Once we have downloaded/unzipped the Arduino IDE, we can Plug the Arduino to our
PC via USB cable.We are actually ready to burn our first program on the Arduino
board. To select blink led, the physical translation of the well known programming
hello world, select
File>Sketchbook>Arduino-0017>Examples>Digital>Blink
Once we have our sketch well see something very close to the screenshot on the following page.

Fig 4.1 A screenshot of the Arduino IDE showing the "Blink" program, a simple beginner program

37

4.1.3 Functions Library


[10]Arduino

programs are written in C/C++, although users only need define two func-

tions to make a runnable program:

setup() a function run once at the start of a program that can initialize settings

loop() a function called repeatedly until the board powers off

A typical first program for a microcontroller simply blinks an LED on and off. In the
Arduino environment, the user might write a program like this:
#define LED_PIN 13
void setup () {
pinMode (LED_PIN, OUTPUT);
}

// enable pin 13 for digital output

void loop () {
digitalWrite (LED_PIN, HIGH); // turn on the LED
delay (1000);
// wait one second (1000 milliseconds)
digitalWrite (LED_PIN, LOW); // turn off the LED
delay (1000);
// wait one second
}

It is a feature of most Arduino boards that they have an LED and load resistor connected between
pin 13 and ground, a convenient feature for many simple tests. The above code would not be
seen by a standard C++ compiler as a valid program, so when the user clicks the "Upload to I/O
board" button in the IDE, a copy of the code is written to a temporary file with an extra include
header at the top and a very simple main() function at the bottom, to make it a valid C++ program. The Arduino IDE uses the GNU toolchain and AVR Libc to compile programs, and uses
avrdude to upload programs to the board. As the Arduino platform uses Atmel microcontrollers
Atmels development environment, AVR Studio or the newer Atmel Studio, may also be used to
develop software for the Arduino.
setup()
The setup() function is called when a sketch starts. Use it to initialise variables, pin modes, start
using libraries, etc. The setup function will only run once, after each power up or reset of the Arduino board.

38

Example
int buttonPin = 3;
void setup()
{
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}
void loop()
{
// ...
}

loop()
After creating a setup() function, which initialises and sets the initial values, the loop() function
does precisely what its name suggests, and loops consecutively, allowing your program to
change and respond. Use it to actively control the Arduino board.
Example
const int buttonPin = 3;
// setup initialises serial and the button pin
void setup()
{
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}
// loop checks the button pin each time,
// and will send serial if it is pressed
void loop()
{
if (digitalRead(buttonPin) == HIGH)
Serial.write('H');
else
Serial.write('L');
}

delay(1000);

Define
#define

is a useful C component that allows the programmer to give a name to a constant value

before the program is compiled. Defined constants in Arduino don't take up any program memory space on the chip. The compiler will replace references to these constants with the defined
value at compile time. This can have some unwanted side effects though, if for example, a con-

39

stant name that had been #defined is included in some other constant or variable name. In that
case the text would be replaced by the #defined number (or text).
In general, the const keyword is preferred for defining constants and should be used instead of
#define.
Arduino defines have the same syntax as C defines:
Syntax
#define constantName value

Note that the # is necessary.


Example
#define ledPin 3
// The compiler will replace any mention of ledPin with the value 3 at compile time.

#include
#include is used to include outside libraries in your sketch. This gives the programmer access to
a large group of standard C libraries (groups of pre-made functions), and also libraries written
especially for Arduino.
The main reference page for AVR C libraries (AVR is a reference to the Atmel chips on which
the Arduino is based) is here.
Note that #include, similar to #define, has no semicolon terminator, and the compiler will
yield cryptic error messages if you add one.
Example

This example includes a library that is used to put data into the program space flash instead of
ram. This saves the ram space for dynamic memory needs and makes large lookup tables more
practical.
#include <avr/pgmspace.h>
prog_uint16_t myConstants[] PROGMEM = {0, 21140, 702 , 9128, 0, 25764, 8456,
0,0,0,0,0,0,0,0,29810,8968,29762,29762,4500};

40

pinMode()
Description

Configures the specified pin to behave either as an input or an output. See the description of digital pins for details on the functionality of the pins.
As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pullups.
Syntax

pinMode(pin, mode)
Parameters

pin: the number of the pin whose mode you wish to set
mode: INPUT, OUTPUT, or INPUT_PULLUP. (see the digital pins page for a more complete
description of the functionality.)
Returns

None
Example

int ledPin = 13; // LED connected to digital pin 13

void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}

void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off

41

delay(1000); // waits for a second


}

digitalRead()
Description

Reads the value from a specified digital pin, either HIGH or LOW.
Syntax

digitalRead(pin)
Parameters

pin: the number of the digital pin you want to read (int)
Returns

HIGH or LOW
Example
int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0;

// variable to store the read value

void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(inPin, INPUT);

// sets the digital pin 13 as output


// sets the digital pin 7 as input

}
void loop()
{
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}

Sets pin 13 to the same value as the pin 7, which is an input.

42

digitalWrite()
Description

Write a HIGH or a LOW value to a digital pin.


If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. If the pin is
configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K
pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup. The pullup
resistor is enough to light an LED dimly, so if LEDs appear to work, but very dimly, this is a
likely cause. The remedy is to set the pin to an output with the pinMode() function.
NOTE: Digital pin 13 is harder to use as a digital input than the other digital pins because it has
an LED and resistor attached to it that's soldered to the board on most boards. If you enable its
internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the
onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If
you must use pin 13 as a digital input, use an external pull down resistor.
Syntax

digitalWrite(pin, value)
Parameters

pin: the pin number


value: HIGH or LOW
Returns

none
Example
int ledPin = 13;

// LED connected to digital pin 13

void setup()
{
pinMode(ledPin, OUTPUT);

// sets the digital pin as output

43

}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000);

// waits for a second

digitalWrite(ledPin, LOW); // sets the LED off


delay(1000);

// waits for a second

Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW.
Serial
Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use
these functions, you cannot also use pins 0 and 1 for digital input or output. You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board. Click the
serial monitor button in the toolbar and select the same baud rate used in the call to begin().
The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). To use these pins to
communicate with your personal computer, you will need an additional USB-to-serial adaptor, as
they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an
external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's
TX pin, and the ground of your Mega to your device's ground. (Don't connect these pins directly
to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.)
The Arduino Due has three additional 3.3V TTL serial ports: Serial1 on pins 19 (RX) and 18
(TX); Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). Pins 0 and 1
are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip,
which is connected to the USB debug port. Additionally, there is a native USB-serial port on the
SAM3X chip, SerialUSB'. The Arduino Leonardo board uses Serial1 to communicate via TTL
(5V) serial on pins 0 (RX) and 1 (TX). Serial is reserved for USB CDC communication. For
more information, refer to the Leonardo getting started page and hardware page.

44

analogRead()
Description

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. This means that it
will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This
yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit.
The input range and resolution can be changed using analogReference().
It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate
is about 10,000 times a second.
Syntax

analogRead(pin)
Parameters

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini
and Nano, 0 to 15 on the Mega)
Returns

int (0 to 1023)
Note

If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your
hand is to the board, etc.).
Example
int analogPin = 3;

// potentiometer wiper (middle terminal) connected to analog pin 3

// outside leads to ground and +5V


int val = 0;

// variable to store the value read

void setup()
{
Serial.begin(9600);

// setup serial

45

void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val);

// debug value

Boolean Operators
These can be used inside the condition of an if statement.
&& (logical and)
True only if both operands are true, e.g.
if (digitalRead(2) == HIGH && digitalRead(3) == HIGH) { // read two switches
// ...
}

is true only if both inputs are high.

if (conditional) and ==, !=, <, > (comparison operators)


if,

which is used in conjunction with a comparison operator, tests whether a certain condition has

been reached, such as an input being above a certain number. The format for an if test is:
if (someVariable > 50)
{
// do something here
}

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular
action. Put another way, if the statement in parentheses is true, the statements inside the brackets
are run. If not, the program skips over the code.
The brackets may be omitted after an if statement. If this is done, the next line (defined by the
semicolon) becomes the only conditional statement.
if (x > 120) digitalWrite(LEDpin, HIGH);
if (x > 120)
digitalWrite(LEDpin, HIGH);

46

if (x > 120){ digitalWrite(LEDpin, HIGH); }


if (x > 120){
digitalWrite(LEDpin1, HIGH);
digitalWrite(LEDpin2, HIGH);
}

// all are correct

4.2 Our Code


4.2.1 Functions performed:
Interfaces Arduino with the LCD display via a step down transformer
Interfaces Arduino with the GPS Module via a step down transformer
Interfaces Arduino with the GSM Module
Obtains GPS coordinates from GPS module and parses the required data
Receives the SMS to activate tracker and sends back the coordinates of the tracker through the
same method
4.2.2 <Code>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

//GPS
char rec=' ';
char arr_gps[100] = "";
uint8_t valid_data_gps_flag=0;
uint8_t start_gps_reading=1;
uint8_t gps_count=0;
uint8_t arr_count_gps=0;
#define TRUE 1
#define FALSE 0
char time[30];
char gps_valid;
char latitude[20];
char lat_ns;

47

char longitude[20];
char lon_ew;
SoftwareSerial GPSSerial(4,5); // RX, TX

//GSM Serial
SoftwareSerial GSerial(2,3); // RX, TX

// GSM

char aux_string[25];
char phone_number[20]="9818998345";
char SMS[400];

int led = 13;


int relay = A3;
int buzzer = A2;
LiquidCrystal lcd(6, 7, 8, 9, 10, 11);
unsigned long previousMillis=5000;
//*************************************************
int8_t sendATcommand2(char* ATcommand, char* expected_answer1, char* expected_answer2, unsigned int timeout)
//This function sends command to the GSM Modem and wait for reply according
to arguments
{
uint8_t x=0, answer=0;
char response[300];
unsigned long previous;
memset(response, '\0', 100); // Initialize the string
delay(100);
while( GSerial.available() > 0) GSerial.read(); // Clean the input buffer
GSerial.println(ATcommand); // Send the AT command
x = 0;
previous = millis();
// this loop waits for the answer

48

do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(GSerial.available() != 0){
response[x] = GSerial.read();
x++;
// check if the desired answer 1 is in the response of the module
if (strstr(response, expected_answer1) != NULL)
{
answer = 1;
}
// check if the desired answer 2 is in the response of the module
else if (strstr(response, expected_answer2) != NULL)
{
answer = 2;
}
}
}
// Waits for the asnwer with time out
while((answer == 0) && ((millis() - previous) < timeout));
return answer;
}
//*************************************************
void send_message(char *message)
{
char aux_string[25];
uint8_t answer=0;
Serial.print(F("GSM : Sending SMS ..."));
memset(aux_string, '\0', 24); // Initialize the string
sprintf(aux_string,"AT+CMGS=\"%s\"", phone_number);
answer = sendATcommand2(aux_string, ">", ">", 3000); // send the SMS number
if (answer == 1)
{
GSerial.println(message);
GSerial.write(0x1A);
answer = sendATcommand2("", "OK", "OK", 20000);
if (answer == 1)
{
Serial.println(F("Sent"));
}
else

49

{
Serial.println(F("X....Error"));
}
}
else
{
Serial.print(F("X...error "));
Serial.println(answer, DEC);
}
}
//*************************************************
void send_msg_location(char *message)
{
char aux_string[50];
uint8_t answer=0;
Serial.print(F("GSM : Sending SMS ..."));
memset(aux_string, '\0', 24); // Initialize the string
sprintf(aux_string,"AT+CMGS=\"%s\"", phone_number);
answer = sendATcommand2(aux_string, ">", ">", 3000); // send the SMS number
if (answer == 1)
{
GSerial.print(message);GSerial.print("
:
");GSerial.print(latitude);GSerial.print(lat_ns);GSerial.print(",
");GSerial.print(longitude);GSerial.print(lon_ew);
GSerial.write(0x1A);
answer = sendATcommand2(" ", "OK", "OK", 20000);
if (answer == 1)
{
//

Serial.println(F("Sent"));
}
else
{

//

Serial.println(F("X....Error"));
}

}
else
{
Serial.print(F("X...error "));
Serial.println(answer, DEC);
}
}

50

//*************************************************
void init_gsm()
{
uint8_t answer=0;
uint8_t gsm_detect_count=0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("GSM init...");
delay(2000);
GSerial.begin(9600);

//UART for GSM Modem

while((sendATcommand2("AT", "OK","OK", 2000)!=1) && (gsm_detect_count<3))


gsm is not connected then it is not initialized

//If 3 times

{
gsm_detect_count++;
Serial.println(F("GSM : Not Detected"));
delay(5000);
}
if(gsm_detect_count>=3)
{
Serial.println(F("GSM : Finally Not Detected"));
Serial.println(F("GSM : System Hang"));
lcd.print("X");
lcd.setCursor(0, 1);
lcd.print("System Hang");
while(1);
}
else
{
lcd.print("OK");
Serial.println(F("GSM : Detected, Initializing"));
//************
Serial.print(F("GSM : Setting SMS mode..."));
answer = sendATcommand2("AT+CMGF=1", "OK", "OK", 1000); // sets the SMS mode to text
if(answer == 1)
{
Serial.println("OK");
}
else

51

{
Serial.println("X");
}
//************
Serial.print(F("GSM : Setting Baud Rate..."));
answer = sendATcommand2("AT+IPR=9600", "OK", "OK", 1000); // sets the SMS mode to text
if(answer == 1)
{
Serial.println(F("OK"));
}
else
{
Serial.println(F("X"));
}
//************
}
delay(2000);
lcd.clear();
}
//*************************************************
void process_gps_data(char *arr)
{
uint8_t i;
//Get time
i=0;
while(*arr!=',')
{
time[i++]=*arr;
arr++;
}
time[i]='\0';
//Get GPS_valid
arr++;
gps_valid=*arr;
arr++;
//Get latitude
arr++;
i=0;
while(*arr!=',')

52

{
// latitude[i++]=*arr;
arr++;
}
//latitude[i]='\0';
//Get lat_ns
arr++;
if(*arr==',')
{lat_ns='\0';}
else
{lat_ns=*arr;
arr++;}
//Get longitude
arr++;
i=0;
while(*arr!=',')
{
// longitude[i++]=*arr;
arr++;
}
//longitude[i]='\0';
//Get lon_ew
arr++;
if(*arr==',')
{lon_ew='\0';}
else
{lon_ew=*arr;
arr++;}
//Display GPS data on uart, for debugging only
Serial.println();
Serial.print("Time:");Serial.print(time);Serial.print("\r\n");
Serial.print("Data Valid:");Serial.print(gps_valid);Serial.print("\r\n");
Serial.print("Latitude:");Serial.print(latitude);Serial.print("\r\n");
Serial.print("Latitude N/S:");Serial.print(lat_ns);Serial.print("\r\n");
Serial.print("Longitude:");Serial.print(longitude);Serial.print("\r\n");
Serial.print("Longitude E/W:");Serial.print(lon_ew);Serial.print("\r\n");
}

53

//*************************************************
void read_gps2()
{
if(GPSSerial.available() > 0)
{
rec=GPSSerial.read();
if(gps_count==7)
{
if(rec==0x0D)
{
gps_count=0;
arr_gps[arr_count_gps] = '\0';
valid_data_gps_flag=TRUE;
the array

//Valid GPS data is received in

Serial.println();
process_gps_data(arr_gps);
//start_gps_reading=0;
}
else
{
arr_gps[arr_count_gps++] = rec;
Serial.print(rec);
//uart_tx(rec);

//Debugging on uart

}
}
//***************
if(gps_count==6)
{
if(rec==',')
{
gps_count=7;
//uart1_puts("\r\n");

//Debugging on uart

}
else
{gps_count=0;}
}
//***************
if(gps_count==5)
{
if(rec=='C')
{gps_count=6;}

54

else
{gps_count=0;}
}
//***************
if(gps_count==4)
{
if(rec=='M')
{gps_count=5;}
else
{gps_count=0;}
}
//***************
if(gps_count==3)
{
if(rec=='R')
{gps_count=4;}
else
{gps_count=0;}
}
//***************
if(gps_count==2)
{
if(rec=='P')
{gps_count=3;}
else
{gps_count=0;}
}
//***************
if(gps_count==1)
{
if(rec=='G')
{gps_count=2;}
else
{gps_count=0;}
}
//***************
if(rec=='$')
{
if(start_gps_reading==1)
{
gps_count=1;

55

arr_count_gps=0;

// GPS data array count reset to 0

}
}
//***************
/////
}
}
//*************************************************
void disp_gps_lcd()
{
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("LAT:");lcd.print(latitude);lcd.print(lat_ns);
lcd.setCursor(0, 1);
lcd.print("LON:");lcd.print(longitude);lcd.print(lon_ew);
delay(5000);
}
//*************************************************
void receive_gsm_message()
{
char *n1;
int8_t answer;
int x;
unsigned long previous;
unsigned int timeout=5000;
// answer = sendATcommand("AT+CMGR=1", "+CMGR:", 5000); // reads the first SMS
answer = sendATcommand2("AT+CMR=1", "+CMGR:", "OK", 250); // reads the first SMS
if(answer==1)
{
Serial.println(F("\nGSM : Some Message Received"));
answer = 0;
x=0;
previous = millis();
do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(GSerial.available() > 0){
SMS[x] = GSerial.read();
x++;
// check if the desired answer (OK) is in the response of the module

56

/*
if (strstr(SMS, "OK") != NULL)
{
answer = 1;
}*/
}
}while(answer == 0 && ((millis() - previous) < timeout)); // Waits for the asnwer with time out
SMS[x] = '\0';
answer = sendATcommand2("AT+CMGD=1", "OK", "OK", 500); // sets the SMS mode to text
/*Serial.print("Answer2 = ");
Serial.println(answer,DEC);
*/
Serial.print(F("GSM : Message Rec-"));Serial.println(SMS);
//decode_mobile_no(SMS);
//decode_string(SMS);
//decode_array3(SMS);
if(strstr(SMS,"<LOC>"))
{
Serial.println(F("Yes, <LOC> String Present"));
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Received Message");
lcd.setCursor(0, 1);
lcd.print("Location Info");
GPSSerial.listen();
start_gps_reading=1;
valid_data_gps_flag=FALSE;
while(valid_data_gps_flag!=TRUE)
{
read_gps2();
}
disp_gps_lcd();
GSerial.listen();
send_msg_location("Location");
delay(6000);
}
else if(strstr(SMS,"<OFF>"))
{
Serial.println(F("Yes, <OFF> String Present"));
lcd.clear();
lcd.setCursor(0, 0);

57

lcd.print("Received Message");
lcd.setCursor(0, 1);
lcd.print("Engine Cutoff");
digitalWrite(buzzer, HIGH);
digitalWrite(relay, HIGH);
GPSSerial.listen();
start_gps_reading=1;
valid_data_gps_flag=FALSE;
while(valid_data_gps_flag!=TRUE)
{
read_gps2();
}
delay(2000);
disp_gps_lcd();
GSerial.listen();
send_msg_location("Engine Cutoff success, Location");
delay(6000);
}

else
{
Serial.println(F("No, String Not Present"));
}
}
else
{
//Serial.println(F("GSM : Error, No Message"));
}
}
//*************************************************
void setup()
{
Serial.begin(9600);
GPSSerial.begin(9600);
Serial.println("Program Started");
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(relay, OUTPUT);
digitalWrite(led, LOW);

58

digitalWrite(relay, LOW);
digitalWrite(buzzer, LOW);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("GPS GSM TRACKING");
lcd.setCursor(0, 1);
lcd.print("");
delay(5000);
lcd.clear();
init_gsm();
delay(10000);
GSerial.listen();
send_message("Module Started");
}
//*************************************************
void loop()
{
if(millis() - previousMillis > 5000)
{
GPSSerial.listen();
start_gps_reading=1;
valid_data_gps_flag=FALSE;
while(valid_data_gps_flag!=TRUE)
{
read_gps2();
}
disp_gps_lcd();
GSerial.listen();
receive_gsm_message();
previousMillis = millis();
}
/*
GPSSerial.listen();
start_gps_reading=1;
valid_data_gps_flag=FALSE;
while(valid_data_gps_flag!=TRUE)
{
read_gps2();

59

}
disp_gps_lcd();
GSerial.listen();
send_msg_location("MMD Smoke Detected");
delay(6000);
digitalWrite(relay, LOW);
}
*/
}
//*************************************************

60

Chapter 5
Applications
When some technology comes to be used at practical level it happens to cherish both plus
as well as minus points of its own. But sometimes technology may be positive in itself but its
application can be misused. Before we go ahead to give space to any technology in our house or
work place we should have pre-estimates of its fall outs.
The positive aspects of the tracking system can be summarised as follows:
i. Core benefit of tracking vehicle is that one can monitor ones vehicle from a distance
whether on individual or commercial level. It helps busy parents to keep a watch on the
children even from their office and control their roaming here and there. Thus can put a
check on their rash driving. This gives immense relief to business owners as it gives
them information about the misuse of company vehicle or delay in delivering services
or drivers violation of speed code, if any. All this keeps a check on wastage of fuel,
time and ensures the better services. With the use of this technology one need not enquire the location of the vehicle by phone again and again. One can get all the required
details just by a click on the internet. Map on the screen displays the position of vehicle
at a particular time.
ii. In view of long journeys and night journeys by car the technology can provide a safety
network to the person in condition of emergency. It can cut time of journey short by
providing the information regarding location, speed, distance from the destination leading to best route planning.
iii. Best feature of the technology is that it is easy to use. just an automated unit is needed
to be installed in the vehicle and connected to the centre which may be provided by
some company. This instrument is monitored by the GPS tracking company which
keeps all the records or its customers locations. All details of location etc are communicated to the user by cell phone or internet connection. Increasing productivity of your
mobile workers.
iv. It helps monitoring employee driving habits and activities.
v. Helps you locate your employees are on-the-road.
vi. Helps you verify the employee time sheet.
vii. Helps you in monitoring all your vehicles.

The negative aspects of the tracking system can be summarised as follows:


No technology is free from dark areas. This technology helps monitoring vehicles and children as well and ensures increased productivity at commercial level and safety at personal level.
But at the same time it encroaches the privacy of the individual. The liberty of the person gets
restricted. This may lead to business owner to measure the performance of the employee by these
stats only and there leaves no room for human analysis.

61

Chapter 6
Conclusion and Future Scope
The project titled tracing down the vehicle using GSM and satellite communication is a
model for vehicle tracking unit with the help of gps receivers and GSM modem. Vehicle Tracking System resulted in improving overall productivity with better fleet management that in turn
offers better return on your investments. Better scheduling or route planning can enable you handle larger jobs loads within a particular time. Vehicle tracking both in case of personal as well as
business purpose improves safety and security, communication medium, performance monitoring
and increases productivity. So in the coming year, it is going to play a major role in our day-today living.
We have completed the project as per the requirements of our project. Finally the aim of the
project i.e. to trace the vehicle is successfully achieved.
Future Scope
We can use the EEPROM to store the previous Navigating positions up to 256 locations and
we can navigate up to N number of locations by increasing its memory.
We can reduce the size of the kit by using GPS+GSM on the same module.
We can increase the accuracy up to 3m by increasing the cost of the GPS receivers.
We can use our kit for detection of bomb by connecting to the bomb detector.
With the help of high sensitivity vibration sensors we can detect the accident.
Whenever vehicle unexpectedly had an accident on the road with help of vibration sensor we
can detect the accident and we can send the location to the owner, hospital and police.
We can use our kit to assist the traffic. By keeping the kits in the entire vehicles and by
knowing the locations of all the vehicles.
If anybody steals our car we can easily find our car around the globe. By keeping vehicle positioning vehicle on the vehicle.

62

References
[1]. Chen, H., Chiang, Y. Chang, F., H. Wang, H. (2010). Toward Real-Time Precise Point Positioning: Differential GPS Based on IGS Ultra Rapid Product,SICE Annual Conference, The
Grand Hotel, Taipei, Taiwan August 18-21.
[2]. Asaad M. J. Al-Hindawi, Ibraheem Talib, Experimentally Evaluation of GPS/GSM Based
System Design, Journal of Electronic Systems Volume 2 Number 2 June 2012
[3]. Chen Peijiang, Jiang Xuehua, Design and Implementation of Remote monitoring system
based on GSM, vol.42, pp.167-175. 2008.
[4]. V.Ramya, B. Palaniappan, K. Karthick, Embedded Controller for Vehicle In-Front Obstacle
Detection and Cabin Safety Alert System, International Journal of Computer Science &
Information Technology (IJCSIT) Vol 4, No 2, April 2012.
[5]. N, B. E. "What Is an Arduino?" Sparkfun. N.p., n.d. Web.
[6]. Arduino-Introduction. Arduino.cc. Arduino, n.d. Web. 27 Oct. 2015.
[7]. Arduino Board Uno." Arduino.cc. Arduino, n.d. Web. 27 Oct. 2015.
[8]. "Re: Comments to Access Board Docket Number 2007-1" (PDF). Office of Technical Information Services, APTA. January 20, 2009. p. 3.
[9]. "Libraries." Arduino.cc. Arduino, n.d. Web. 27 Oct. 2015.

63