Beruflich Dokumente
Kultur Dokumente
V.Krishna Chaitanya
K.Praveen Kumar
Bachelor of Technology
In
Electronics and Communication Engineering
By
This is to certify that this project report entitled smart helmet using Arduino by V.Krishna
Chaitanya (Roll no: 09241A0478), K.Praveen Kumar (09241A0489), submitted in partial
fulfillment of the requirements for the degree of Bachelor of Technology in Electronics and
Communication Engineering of the Jawaharlal Nehru Technological University, Hyderabad,
during the academic year 2009-10, is a bonafide record of work carried out under our guidance
and supervision.
The results embodied in this report have not been submitted to any other University or Institution
for the award of any degree or diploma
(Guide)
Md.Javeed Mehdi
Assistant professor
(External examiner)
(Head of department)
Ravi Billa
ACKNOWLEDGMENT
We have immense pleasure in expressing our thanks and deep sense of gratitude to our guide
Mr.Md.Javeed Mehdi, Assistant Professor, Department of Electronics and Communication
Engineering, GRIET for his guidance throughout this project.
We would also like to express our deepest appreciation to our project coordinators
Mr.
Anantha Radhanand, Mr.V.H.Raju, and Mr.Balaji, Associate Professors, Department of
Electronics and Communication Engineering, GRIET for their technical support in our
project.
We also express our sincere thanks to Prof. Ravi Billa, Head of the Department, GRIET for
extending his help.
We wish to express our profound sense of gratitude to Prof. P. S. Raju, Director, GRIET for his
encouragement, and for all facilities to complete this project.
Finally we express our sincere gratitude to all the members of faculty and my friends who
contributed their valuable advice and helped to complete the project successfully.
V.Krishna Chaitanya
_________________
K.Praveen Kumar
_________________
Abstract
Description:
A smart helmet is a special idea which makes motorcycle driving safer
than before. This is implemented using Arduino. The working of this smart helmet
using Arduino is very simple, we place vibration sensors in different places of
helmet where the probability of hitting is more which are connected to Arduino
board. So when the rider crashes and the helmet hits the ground, the sensors sense
and the Arduino extract GPS data using the GPS module that is interfaced with
Arduino. When the data exceeds minimum stress limit then GSM module
automatically sends message to ambulance or police or family members.
Block diagram:
Platforms to be used:
Hardware: Arduino board, Bluetooth module, vibration sensors, mobile phone
with Bluetooth.
Software: Arduino IDE
ii
CONTENTS
AKNOWLEDGMENT.. (i)
ABSTRACT.. (ii)
1. INTRODUCTION
1.1
1.2
1.3
1.4
1.5
1.6
Background...1
Aim of the project................1
Methodology................2
Significance of this work.3
Outline of this report...............3
Conclusion4
2. ARDUINO
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
2.10
Overview......................5
Schematic and reference design..6
Summary...7
Power....7
Memory................8
Input and Output..8
Communication...............9
Programming................9
Automatic reset...10
USB Overcurrent protection..11
2.11 Physical Characteristics..11
Overview................12
Applications12
Dimensions.................13
Features...13
Performance specifications................14
Functional description.15
4. GPS MODULE
4.1
4.2
Overview................18
Highlights and features..18
4.3
4.4
4.5
4.6
5. GSM Module
5.1
5.2
5.3
5.4
5.5
Overview.................31
Features...31
Specifications..32
Operating conditions..34
Pin configuration...............34
6. BLOCK DIAGRAM
6.1
6.2
6.3
Block diagram.37
Flow chart...38
Program...39
BIBILOGRAPHY...45
Chapter 1
INTRODUCTION
1.1 Background
The thought of developing this project comes from social responsibility towards the
society. As we can see many accidents occurring around us, there is a lot of loss of life.
According to a survey of India there are around 698 accidents occurring due to bike crashes
per year. The reasons for the accidents may be many such as no proper driving knowledge,
no fitness of the bike, rash driving, drink and drive etc. In some cases the person injured the
accident may not be directly responsible for the accident, it may be fault of some other rider,
but end of the day its both the drivers involved in the accidents who is going to suffer.
If accidents are one issue, lack of treatment in proper time is another reason for deaths.
According to the same survey if 698 accidents occur per year, nearly half the injured people
die due to lack of treatment in proper time. The reasons for this may again be many such as
late arrival of ambulance, no person at place of accident to give information to the
ambulance.
This is what is running situation in our day to day life, a thought of finding some
solution to this problem come up with this idea of giving the information about accident as
soon as possible and in TIME.!!!!Because after all time matters a lot, if everything is
done in time, at least we can save half the lives that are lost due to bike accidents.
So, a thought from taking responsibility of society came our project SMART
HELMET USING ARDUINO.
1.3 Methodology
The idea of this project is to give information about the accident to the ambulance and
family members, so we have chose GSM technology to give the information by sending
SMS. We are using GSM module which has SIM card slot to place the SIM and send SMS.
Sending SMS alone cant help the driver, if we send and an SMS saying that accident
had occurred where the ambulance will come without knowing the location of the accident.
So we include GPS location in the SMS which we are sending so that the ambulance will
have perfect information about where and when the accident has occurred. For this we use
GPS module to extract the location of the accident, the GPS data will contain the latitude
and longitude values using which we can find the accurate position of the accident place.
To run the GPS and GSM module we use Arduino UNO board which has ATmega328
microcontroller. The Arduino is a very user friendly device which can be easily interfaced
with any sensors or modules and is very compact in size.
Now we are clear that the Arduino will send the SMS using the GSM module by
keeping the GPS location in the SMS which is obtained from the GPS module. But when
should all this be done? When accident occurs, how will the Arduino detect the accident?
We use a vibration sensor which is placed in the helmet.
The vibration sensor is placed in the helmet such that it detects vibrations of the
helmet. When the rider crashes, the helmet hits the ground and the vibration sensor detects
the vibrations that are created when the helmet hits the ground and then the Arduino will
send an SMS containing information about the accident and location of accident.
This is the methodology used in the project, let me once again give a brief description
about the working of project,
When the rider crashes, the helmet hits the ground, the vibration sensor
senses the vibrations and asks the Arduino to send SMS, the Arduino will send SMS through
GSM module containing information that accident has occurred and the GPS location
obtained from GPS module.
1.6 Conclusion
As the concluding part of this project, I would like to say that-"Without proper action at proper time, danger awaits us with a bigger face."
We must act on time when a person is injured. We must take care of person the way it is
meant. otherwise, a valuable life might be lost .We need to understand how precious lives of
people are and what importance first-aid carries in saving these precious lives.
If this project imparts this idea in even one person, I would think that the project will be
successful.
Chapter 2
ARDUINO
2.1Overview
The Arduino Uno is a microcontroller board based on the ATmega328 . 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 USBto-serial converter.
Revision3 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.
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; for a comparison with previous version
The Arduino reference design can use an Atmega8, 168, or 328, Current models use
an ATmega328, but an Atmega8 is shown in the schematic for reference. The pin configuration is
identical on all three processors.
2.3 Summary
Microcontroller
ATmega328
Operating Voltage
5V
Input Voltage
(recommended)
7-12V
6-20V
40 mA
50 mA
Flash Memory
SRAM
2 KB (ATmega328)
EEPROM
1 KB (ATmega328)
Clock Speed
16 MHz
2.4 Power
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.
IOREF. This pin on the Arduino board provides the voltage reference with which the
microcontroller operates. A properly configured shield can read the IOREF pin voltage
and select the appropriate power source or enable voltage translators on the outputs for
working with the 5V or 3.3V.
2.5 Memory
The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2 KB of SRAM
and 1 KB of EEPROM (which can be read and written with the EEPROMlibrary).
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 specialized 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.
2.7 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).
A Software Serial library allows for serial communication on any of the Uno's digital pins.
The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino software
includes a Wire library to simplify use of the I2C bus; see the documentation for details. For SPI
communication, use the SPI library.
2.8 Programming
The Arduino Uno can be programmed with the Arduino software.
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 (reference, C headerfiles).
You can also bypass the bootloader and program the microcontroller through the ICSP (InCircuit Serial Programming) header; see these instructions for details.
The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is available .
The ATmega16U2/8U2 is loaded with a DFU bootloader, which can be activated by:
On Rev1 boards: connecting the solder jumper on the back of the board (near the map of
Italy) and then resetting the 8U2.
On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to
ground, making it easier to put into DFU mode.
You can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X
and Linux) to load a new firmware. Or you can use the ISP header with an external
programmer (overwriting the DFU bootloader). See this user-contributed tutorial for
more information.
10
11
Chapter 3
PIEZO VIBRATION SENSOR
3.1 Overview
The Minisense 100is a low-cost cantilever-type vibration sensor loaded by a mass to offer high
sensitivity at low frequencies. The pins are designed for easy installation and are
solderable.Horizontal and vertical mounting optionsare offered as well as a reduced
heightversion. The active sensor area is shieldedfor improved RFI/EMI rejection.
Rugged,flexible PVDF sensing element withstands high shock overload. Sensor has excellent
linearity and dynamic range, and may beused for detecting either continuous vibration or
impacts.
3.2 APPLICATIONS
12
3.4 FEATURES
High Voltage Sensitivity (1 V/g)
Over 5 V/g at Resonance
Horizontal or Vertical Mounting
Shielded Construction
Solderable Pins, PCB Mounting
Low Cost
< 1% Linearity
Up to 40 Hz (2,400 rpm) OperationBelow Resonance
High Sensitivity
Good Frequency Response
Excellent Linearity
Shielded Construction
Analog Output
Withstands High Shock
13
14
Value
1.1
260
75
6
42
+/-1
244
0.018
0.3
Units
V/g
pC/g
Hz
V/g
Hz
%
pF
(none)
gram
Electrical description
The MiniSense 100behaves electrically as an active capacitor: it may be modelled as a perfect
voltage source (voltage proportional to applied acceleration) in series with the quoted device
capacitance. Any external input or load resistance will form a high-pass filter, with a roll-off
frequency as tabulated above, or calculated from the formula f(c) = 1/(2_RC). The impedance of
the sensor is approximately 650 M ohm at 1 Hz. The active sensor element is electrically
shielded, although care should be taken in the PCB design to keep unshielded traces as short as
possible.
15
16
Off-Axis Sensitivity
The sensitivity of the Minisense 100 follows a cosine law, when rotated horizontally around its
axis,or vertically around its mid-point. At 90 degrees rotation in either plane, both baseline
sensitivity andsensitivity at resonance are at a minimum. In theory, sensitivity should be zero in
this condition. It is likely that some sensitivity around the resonance frequency will still be
observed but this may be unpredictable and is likely to be at least -16 dB with reference to the
on-axis response. Note that the sensitivity at 30 degrees rotation is -1.25 dB (87% of on-axis
response), at 60 degrees, it falls to -6 dB (50%).
The plots below show the change in sensitivity observed for either:
1) Rotation about major axis of sensing element
17
Chapter 4
GPS MODULE
4.1 Overview
The FGPMMOPA6B is an ultra-compact POT (Patch On Top) GPS Module. This POT GPS
receiverprovides a solution that is high in position and speed accuracy performances, with high
sensitivityand tracking capabilities in urban conditions. The GPS chipset inside the module is
powered byMediaTek Inc., the world's leading digital media solution provider and the largest
fab-less ICcompany in Taiwan. The module can support up to 66 channels, and is designed for
small-formfactordevice. It is suitable for every GPS-related application, such as:
Fleet Management/Asset Tracking
LBS (location base service) and AVL system
Security system
18
19
Mechanical dimension
Dimension: (Unit: mm, Tolerance: +/- 0.1mm)
20
21
22
23
Pin Assignment
Pin
1
2
3
4
5
6
7
8
9
10
Name
VCC
ENABLE
GND
VBACKUP
3D-FIX
DPLUS
DMINUS
GND
TX
RX
I/O
PI
I
P
PI
O
I/O
I/O
P
O
I
Description
Main DC power input
High active, or keep floating for normal working
Ground
Backup power input
3D-fix indicator
USB port D+
USB port DGround
Serial data output of NMEA
Serial data input for firmware update
24
After 2D or 3D Fix
The pin should continuously output low-level signal.
DPLUS (Pin6)
25
26
MTK MT3329
L1, 1575.42MHz
1.023 MHz
66 channels
WAAS, EGNOS,MSAS ,GAGAN Supported(Default: Enable)
WGS84(Default), Tokyo-M, Tokyo-A, User Define
ARM7EJ-S
Performance Characteristics
Position Accuracy
Velocity Accuracy
Acceleration Accuracy
Timing Accuracy
Sensitivity
Update Rate
Hot start
1.0s (Typical)
Warm start
Cold start
34s (Typical)
35s (Typical)
27
Dynamic
Altitude
Velocity
Acceleration
Maximum 18,000m
Maximum 515m/s
Maximum 4G
Input/Output
8 data bits, no parity, 1 stop bit
Signal Output
Available Baud Rates Default:9600bps
(4800/9600/38400/57600/115200 bps by customization)
NMEA 0183 v3.01 (Default: GGA,GSA,GSV,RMC,VTG)
Protocols
MTK NMEA Command
Environment
Operating Temperature
Storage Temperature
Operating Humidity
Mounting
-40 C to 85 C
-50 C to 90 C
5% to 95% (no condensing)
SMD Type ,10 Pin
28
DC Characteristics
Condition
Min.
Typ. Max. Unit
3.3
5.0
V
3.2
50 mVpp
2.0
3.0
4.3
V
VCC=3.2~5.0V
2.1
2.8
V
VCC=3.2~5.0V
0
0.9
V
VCC=3.2~5.0V
2.1
2.8
V
VCC=3.2~5.0V
0
0.8
V
VCC=3.2~5.0V (D+)-(D)
mV
>200
VCC=3.2~5.0V (D-)(D+)
mV
>200
Acquisition
43
48
53
mA
Power Consumption @ 3.3V,
Tracking
32
37
42
mA
1Hz Update Rate
25C
10
uA
Backup Power Consumption@ 3.0V
25C
15
uA
Shut-down Power Consumption
Parameter
Operation supply Voltage
Operation supply Ripple Voltage
Backup Battery Voltage
RX TTL H Level
RX TTL L Level
TX TTL H Level
TX TTL L Level
Differential 1
USB
Differential 0
Description
Time, position and fix type data.
GPS receiver operating mode, active satellites used in the
Position solution and DOP values.
The number of GPS satellites in view satellite ID numbers,
elevation, azimuth, and SNR values.
Time, date, position, course and speed data. Recommended
Minimum Navigation Information.
Course and speed information relative to the ground.
29
In this project we use RMCRecommended Minimum Navigation Information type data for
extracting the values required.
The following table contains the values for the following example
$GPRMC,064951.000,A,2307.1256,N,12016.4438,E,0.03,165.48,260406, 3.05,W,A*55
Name
Example
Units
Message ID
$GPRMC
UTC Time
064951.000
Status
A
Latitude
2307.1256
N/S Indicator
N
Longitude
12016.4438
E/W Indicator
E
Speed overGround
0.03
knots
CourseoverGround
165.48
degrees
Date
260406
MagneticVariation
3.05,W
degrees
A
Mode
Checksum
<CR><LF>
Description
RMC protocol header
hhmmss.sss
A=data valid or V=data not valid
ddmm.mmmm
N=north or S=south
dddmm.mmmm
E=east or W=west
True
Ddmmyy
E=east or W=west
A= Autonomous mode
D= Differential mode
E= Estimated mode
*55
End of message termination
30
Chapter 5
SIM 900 -TTL UART
GSM Modem
5.1 Overview
GSM/GPRS TTL Modem is built with SIMCOM Make SIM900 Quad-bandGSM/GPRS
engine, works on frequencies 850 MHz, 900 MHz, 1800 MHz and 1900 MHz. It is verycompact
in size and easy to use as plug in GSM Modem. The Modem is designed with 3V3/5V
TTLinterfacing circuitry, which allows you to directly interface to 5V microcontrollers(
PIC,Arduino,AVR ect)as well as 3V3 Microcontrollers ( ARM,ARM Cortex XX, ect) .The baud
rate can be configurable from9600-115200 through AT command. Initially Modem is in
Autobaud mode. This GSM/GPRS TTL Modem ishaving internal TCP/IP stack to enable you to
connect with internet via GPRS. It is suitable for SMS aswell as DATA transfer application in
M2M interface.
The modem needed only two wires (Tx,Rx) except Power supply to interface
withmicrocontroller/Host. The built in Low Dropout Linear voltage regulator allows you to
connect wide range ofunregulated power supply (4.2V -13V). Yes, 5 V is in between !! .Using
this modem, you will be able to send& Read SMS, connect to internet via GPRS through simple
AT commands.
5.2 Features
31
5.3 Specifications
32
Dimensions
33
IN/OUT
Input
--Input
Minimum
4.2
40
2.5
Maximum
13
590
6
Unit
V
mA
V
PIN NAME
Power Supply
DIR DETAILS
PWR Power Supply Input (4.2-13V DC,1A)
GND
Ground
PWR Ground Level of Power Supply
V_Interface InterfacingVoltage PWR Interfacing Voltage Input for on board
voltage level conversion (3V3 or 5V).
If the modem has to be interfaced with a 5V
microcontroller, the input to this pin
should be 5V DC and if the modem has to be
interfaced with a 3V3 microcontroller,
the input to this pin should be 3.3V DC.
TXD
Transmit
OUT Outputs data bytes at voltage Level same as
the V_Interface Pin
Usually connected to the Rx pin of the
microcontroller
RXD
Receive
IN Receives data bytes at voltage Level same as
the V_Interface Pin
Usually connected to the TX pin of the
microcontroller
GND
Ground
34
Getting Started
1) Insert SIM card
Open the SIM cardholder by sliding it as per the arrow mark and lift up. Insert the SIM card , so
as to alignthe chamfered corner suits in card holder .After inserting the SIM card, lock the holder
by sliding it to theopposite direction of arrow mark.
2) Connect The Antenna
Fix the Supplied RF antenna to the SMA Antennae connector and tighten it by Rotating the Nut
(Never rotate the antennae for tightening ).
3) Connect the Pins
Connect the GSM modem as per the circuit diagram provided
4) Power the Modem
Power the modem from suitable power supply, which is having enough current capacity (>1A).
5) Check the Status of the LEDs
PWR LED - Red LED will lit immediately
STS LED - Green LED will lit after 1-2 seconds
NET LED -Blue LED will starts to blink in fast for few seconds(Searching For Network)
andbecomes slow blinking once the Modem registers with the Network.
35
6) Network LED
The Network LED indicates the various status of GSM module eg. Power on, Network
registration &GPRS connectivity. When the modem is powered up, the status LED will blink
every second. After theModem registers in the network (takes between 10-60 seconds), LED will
blink in step of 3 seconds. Atthis stage you can start using Modem for your application.
7) Baud rate
The Baud rate supported by the modem is between 9600 and 115200. Make sure the host system
is setto the supported baud rate.
The modem automatically sets to the baud rate of the first command sent by the host
system afterit is powered up. User must first send A to synchronize the baud rate. It is
recommended to wait 2 to 3seconds before sending AT character. After receiving the
OK response, Your Device and GSM Modemare correctly synchronized. So there is no
need for setting the baud rate using commands.
Before You Start using the modem, please make sure that the SIM card you inserted
support theneeded features and there is enough balance in SIM.!!!
36
Chapter 6
6.1 Block Diagram
Connecting the hardware
Vibration sensor
ARDUINO
GPS module
GSM module
The vibration sensor is connected to the A0 pin of the Arduino. The output of vibration sensor is
analog signal so it is connected to the analog inputs of the Arduino.
The GPS module is connected to the Rx and Tx pins of Arduino. Here we only take values from
GPS module so there is no need of connecting Tx pin.
The GSM module is connected to 4 and 5 pins of Arduino which are assigned as Rx and Tx
using sofwareserial. Here we are only transmitting to gsm module so there is no need of
connecting Rx pin.
Power to all these components will be taken from arduino 5v power supply.
37
Read vibration
sensor
If
threshold
>50
Send SMS
If SMS
sent
END
38
6.3 PROGRAM
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include "SIM900.h"
#include "sms.h"
SMSGSM sms;
boolean started= false;
// GPS parser for 406a
#define BUFFSIZ 45 // plenty big
int ledpin = 13;
int knockSensor = A0; // the piezo is connected to analog pin 0
int threshold = 30; // threshold value to decide when the detected sound is a knock or not
int sensorReading = 0;
char buffer[BUFFSIZ];
char *parseptr;
char buffidx;
uint8_t hour, minute, second, year, month, date;
int latitude, longitude;
uint8_t groundspeed, trackangle;
char latdir, longdir;
char status;
void setup()
{
if (ledpin)
{
pinMode(ledpin, OUTPUT);
}
pinMode(13, OUTPUT);
Serial.begin(9600); // prints title with ending line break
Serial.println("GPS parser");
digitalWrite(ledpin, LOW); // pull low to turn on!
}
void loop()
{
int tmp;
sensorReading = analogRead(knockSensor);
39
// groundspeed
parseptr = strchr(parseptr, ',')+1;
groundspeed = parsedecimal(parseptr);
// track angle
parseptr = strchr(parseptr, ',')+1;
trackangle = parsedecimal(parseptr);
// date
parseptr = strchr(parseptr, ',')+1;
tmp = parsedecimal(parseptr);
date = tmp / 10000;
month = (tmp / 100) % 100;
year = tmp % 100;
Serial.print("\nTime: ");
Serial.print(hour, DEC); Serial.print(':');
Serial.print(minute, DEC); Serial.print(':');
Serial.println(second, DEC);
Serial.print("Date: ");
Serial.print(month, DEC); Serial.print('/');
Serial.print(date, DEC); Serial.print('/');
Serial.println(year, DEC);
Serial.print("Lat: ");
if (latdir == 'N')
Serial.print('+');
41
else
if (latdir == 'S')
Serial.print('-');
Serial.print(latitude/1000000, DEC); Serial.print('\'); Serial.print(' ');
Serial.print((latitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');
Serial.print((latitude%10000)*6/1000, DEC); Serial.print('.');
Serial.print(((latitude%10000)*6/10)%100, DEC); Serial.println('"');
Serial.print("Long: ");
if (longdir == 'E')
Serial.print('+');
else
if (longdir == 'W')
Serial.print('-');
Serial.print(longitude/1000000, DEC); Serial.print('\'); Serial.print(' ');
Serial.print((longitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');
Serial.print((longitude%10000)*6/1000, DEC); Serial.print('.');
Serial.print(((longitude%10000)*6/10)%100, DEC); Serial.println('"');
Serial.print(latitude);
Serial.print(longitude);
latitude=lati[10];
longitude=longi[10];
Serial.print(lati);
Serial.print(longi);
Serial.println(buffer);
delay(1000);
Serial.println("GSM Testing to send SMS");
if (gsm.begin(9600))
{
Serial.println("\nstatus=READY");
started=true;
}
else
{
Serial.println("\nstatus=IDLE");
}
42
if(started)
{
if (sms.SendSMS("+919052378836", "accident has occured at"))
if (sms.SendSMS("+919052378836", buffer))
Serial.println("\nSMS sent OK");
}
}
}
}
uint32_t parsedecimal(char *str)
{
uint32_t d = 0;
while (str[0] != 0)
{
if ((str[0] > '9') || (str[0] < '0'))
return d;
d *= 10;
d += str[0] - '0';
str++;
}
return d;
}
void readline(void)
{
char c;
buffidx = 0; // start at begninning
while (1)
{
c=Serial.read();
if (c == -1)
continue;
Serial.print(c);
if (c == '\n')
continue;
if ((buffidx == BUFFSIZ-1) || (c == '\r'))
{
buffer[buffidx] = 0;
return;
43
}
buffer[buffidx++]= c;
}
}
44
BIBLIOGRAPHY
i.
ii.
iii.
iv.
45