Accident Detection Using It Sensor
Accident Detection Using It Sensor
STUDY ON
Vehicle Accident Alert System
SUBMITTED BY
Mr. B. YASHWANTH REDDY
A PROJECT REPORT ON
“Vehicle Accident Alert System”
Submitted by
NAME OF THE STUDENT HALL TICKET NO
Mr. B. YASHWANTH REDDY 115720474004
CERTIFICATE
This is to certify that the project report entitled “Vehicle Accident Alert
System” submitted by Mr. B.Yashwanth Reddy– with bearing ID no : =
115720474004 of PRAGATI MAHAVIDYALA DEGREE COLLEGE –
Koti in final year studying in Faculty of Science B.Sc (MECs) has been
satisfactorily completed project during the academic year 2020-23
Signature of Principal
Certificate
Department of Science
Certified that this is a true Bonafide Project work
“Vehicle Accident Alert System” done By
Mr. B.Yashwanth Reddy Bearing Roll No: 115720474004
Studying in B.sc (M.E.Cs) VI Semester.
This is submitted as the Project work fulfilment for department
of science for the academic year of 2022 -2023
Name :
Roll Number :
ACKNOWLEDGEMENT
I take this opportunity to express my deep sense of
gratitude and heartfelt thanks to several key personalities
whose constant support and encouragement have helped
me to transfer my effort into the completion of this project.
I am grateful to the Department of science, GPRDC for
giving me the opportunity to execute this project, which is
an integral part of the curriculum
I express my deepest gratitude to my project guide whose
guidance, encouragement and support from the initial to
the final level enabled me to develop and understanding of
the subject. Finally, I would like to express my deepest
appreciation to my parents, family members and friends
the most precious people in my life for their confidence in
me and for the support, love and understanding that they
have provided me throughout my life.
TABLE OF CONTENTS
PAGE NO
ABSTRACT i
BLOCK DIAGRAM ii
CHAPTER : 1 INTRODUCTION 1-2
1.1 VEHICLE ACCIDENT DETECTION
1.2 EMBEDDED C LANGUAGE
1.3 LIMITATIONS OF VEHICLE ACCIDENT DETECTION
CHAPTER : 2 DESIGN & IMPLEMENTATION 3-8
2.1 CIRCUIT DIAGRAM
2.2 WORKING PRINCIPLE
2.3 PIN DESCRIPTION
CHAPTER: 3 ARDUINO UNO 9 - 16
3.1 INTRODUCTION
3.2 ATMEGA328
3.3 F EATURES OF ATMEGA328P
3.4 PIN CONFIGURATION
3.5 ARDUINO UNO
3.6 FEATURES OF ARDUINO UNO
3.7 PIN DIAGRAM OF ARDUINO UNO
CHAPTER : 4 HARDWARE REQUIREMENTS 17 - 34
4.1 IR SENSOR 17 - 21
4.1.1 IR SENSOR WORKING PRINCIPLE
4.1.2 SPECIFICATION OF IR SENSOR
4.2 GPS MODULE 22 - 25
4.2.1 WORKING PRINCIPLE OF GPS MODULE
4.2.2 How GPS Receiver Calculates its Position and Time
4.2.3 PIN DIAGRAM OF GPS MODULE
4.3 GSM MODULE 26 - 32
4.3.1 WORKING PRINCIPLE OF GSM MODULE
4.3.2 SPECIFICATION OF GSM MODULE
4.3.3 PIN DIAGRAM OF GSM MODULE
4.4 LM2596 MODULE DC – DC BUCK CONVERTER 33 - 34
4.4.1 WORKING PRINCIPLE OF LM2596 MODULE
4.4.2 SPECIFICATION OF LM2596 MODULE
4.4.3 PIN DIAGRAM OF LM2596 Module DC-DC Buck Converter
CHAPTER : 5 POWER SUPPLY 35 - 37
CHAPTER : 6 SOFTWARE REQUIREMENTS 38 - 49
6.1 ARDUINO IDE
6.2 CODING
CHAPTER : 7 RESULTS 50 - 51
SCOPE OF THE PROJECT 52 - 53
ADVANTAGES AND DISADVANTAGES 54 - 55
OF THE PROJECT
CONCLUSION 56
APPINDEX 45 - 47
BIBLIOGRAPHY 48
LIST OF FIGURES
PAGE NO:
1. Block diagram of GSM-based accident ii
detection system using Arduino UNO
2. Vehicle accident detection with gps and gsm modem 1
3. Circuit diagram of accident detection system 3
4. Vehicle accident detection 6
5. Pin diagram of atmega328p 10
6. Pin diagram of arduino uno 12
7. (a) IR Transmitter 16
(b) IR Receiver
8. Pin diagram of ir sensor 17
9. GPS satellites transmit 18
10. GPS Distance Calculation 19
11. GPS Receiver Module 20
12. GSM SIM800L module 21
13 SIM800L GSM chip (a) 22
SIM800L GSM chip(b)
14. (a) Blink every 1s(a) 24
(b) Blink every 2s(b)
(c) Blink every 3s
15. Antenna 25
16. SIM800L gsm module pin diagram 26
17. Wiring a SIM800L GSM Module 1200mAh Li-Po battery 27
18. Pin diagram of DC-DC Buck Convert 28
19. Operation of the buck converter 29
20. Working principle of battery 30
21.Lithium-ion battery 31
22. (a) IDE software window 34-37
(b) Arduino library manager window
(c) serial monitor window
(d) Board Manager window
23 (a) location of the vehicle 39-40
(b) the system sends an SMS message to
a pre-programmed number
Vehicle Accident Alert System 115720474004
ABSTRACT
One of the basic reasons for road accidents is speed. Road accidents
are rising suddenly today and are one of the key causes of human
deaths. Human life is more important than anything else, and timely
assistance is more important than lending a helping hand. If emergency
service could get accident reports and reach it in time, more lives could
have been saved. In saving human lives, the time between the accident
and when the ambulance reaches the site of the accident plays an
important role. If we reduce the time between when an accident
happens and when a medical ambulance is dispatched to the area, we
can save human lives by reducing mortality rates. GPS has become an
integral part of a vehicle system nowadays. An infrared proximity
sensor or IR Sensor is an electronic device that emits infrared lights to
sense some aspect of the surroundings and can be employed to detect
the motion of an object. It will be tested by Arduino . The Arduino
sends the warning message via the GSM module to the police control
room or a rescue team, including the location. So, after receiving the
information, the police can automatically track the location via the GPS
module. Then, the appropriate action will be taken after verifying the
venue. The advancing technology has made our day to day lives easier.
Since every coin has two sides similarly technology has its benefits as
well as its disadvantages. The rise in technology has increased the rate
of road accidents which causes huge loss of life. The poor emergency
facilities available in our country just add to this problem. Our project
is going to provide a solution to this problem
BLOCK DIAGRAM
This is the block diagram of vehicle tracking and accident alert system. This
shows the overall view of the vehicle accident alert system circuit. The blocks
connected here are GPS, GSM, IR Sensor, Power supply and LM2596 Module
DC-DC Buck Converter to arduino uno.
TX RX(02) TX(07) RX
TX (03) RX(06)
RX Out(08) TX
IR SENSOR
1.1 INTRODUCTION
The high demand of automobiles has also increased the traffic hazards and the
road accidents. Life of the people is under high risk. This is because of the lack of
best emergency facilities available in our country. An automatic alarm device for
vehicle accidents is introduced in this paper. This design is a system which can
detect accidents in significantly less time and sends the basic information to first
aid centre within a few seconds covering geographical coordinates, the time and
angle in which a vehicle accident had occurred. This alert message is sent to the
rescue team in a short time, which will help in saving the valuable lives. A Switch
is also provided in order to terminate the sending of a message in rare case
where there is no casualty, this can save the precious time of the medical rescue
team. When the accident occurs the alert message is sent automatically to the
rescue team and to the police station. The message is sent through the GSM
module and the location of the accident is detected with the help of the GPS
module. The accident can be detected precisely with the help of ir
Sensor (infrared proximity sensor) This application provides the optimum
solution to poor emergency facilities provided to the roads accidents in the
most feasible way. The usage of auto mobiles has improved linearly over the
past decade, which increased in the risk of human life. This is because due to
the insufficient emergency facilities.
1.2 EXPLANATION
An accident happens at night or in areas where no individuals are heard in that
particular setting and victims are not saved at the right time. Many of them are
losing their lives because of this. This device solves the above problem by
submitting data directly after an accident to the emergency team by using GSM
modem which helps to detect accident by ir sensor.
Ir sensor (infrared proximity sensor) comes in handy when you need to detect
an accident by sending infrared lights to sense some aspect of the car front parts
and scene. ir sensor helps to send the signal to Arudino controller. Arudino
controllers send the alert message through GSM modem with location. If the
person meets a small accident, the driver can inform attention is not required
by terminating the message using switch. This is to avoid wasting the time of the
medical and police team. GSM modem is similar to mobile phone without any
display, keypad and speakers. This accepts a SIM card, and operates over a
subscription to a mobile operator This idea proposal has been introduced at the
start of the modern age of mobile phones. With the introduction of GPS sensors
in the mobile, security applications based on GPS were proposed. Then they
proposed special hardware devices which can be linked with mobile phones.
Though, it had the disadvantage of actually buying extra hardware with more
money. With the massive development of mobile phones in the last decade and
new sensors added with the development, the extra hardware can be avoided.
The present application of this paper is present in a very few countries and
providing the information with the relatives and friends with the emergency
services the efficiency of the application can be increased massively.
laptop running Linux or a desktop running Windows. The "target" is where the
executable code generated by the C compiler will run -- the CPU in the
embedded system, often without any underlying operating system.
The GCC compiler is the most popular C compiler for embedded systems. GCC
was originally developed for 32-bit Princeton architecture CPUs. So it was
relatively easily ported to target ARM core microcontrollers such as X Scale and
Atmel AT91RM9200; Atmel AVR32 AP7 family; MIPS core microcontrollers such
as the Microchip PIC32; and Free scale 68k/Cold Fire processors.
The people who write compilers have also (with more difficulty) ported GCC to
target the Texas Instruments MSP430 16-bit MCUs; the Microchip PIC24 and
dsPIC 16-bit Microcontrollers; the 8-bit Atmel AVR microcontrollers; the 8-bit
Free scale 68HC11 microcontrollers.
Other microcontrollers are very different from a 32-bit Princeton architecture
CPU. Many compiler writers have decided it would be better to develop an
independent C compiler rather than try to force the round peg of GCC into the
square hole of 8-bit Harvard architecture microcontroller targets:
SDCC - Small Device C Compiler for the Intel 8051, Maxim 80DS390, Zilog Z80,
Motorola 68HC08, Microchip PIC16, Microchip PIC18
There are some highly respected companies that sell commercial C compilers.
You can find such a commercial C compiler for practically every microcontroller,
including the above-listed microcontrollers. Popular microcontrollers not
already listed (i.e., microcontrollers for which the only known C compiler is a
commercial C compiler) include the Cypress M8C MCUs; Microchip PIC10 and
Microchip PIC12 MCUs; etc.
3.1 ATmega328P
The ATmega328 is a microcontroller board is the Arduino Uno. a single-
chip microcontroller created by Atmel in the megaAVR family (later Microchip
Technology acquired Atmel in 2016). It has a modified Harvard architecture 8-
bit RISC processor core. The Atmel 8-bit AVR RISC-based microcontroller
combines 32 KB ISP flash memory with read-while-write capabilities,
1 KB EEPROM, 2 KB SRAM, 23 general-purpose I/O lines, 32 general-purpose
working registers, 3 flexible timer/counters with compare modes, internal and
external interrupts, serial programmable USART, a byte-oriented 2-wire serial
interface, SPI serial port, 6-channel 10-bit A/D converter (8 channels
in TQFP and QFN/MLF packages),programmable
watchdog timer with internal oscillator, and 5 software-selectable power-saving
modes. The device operates between 1.8 and 5.5 volts. The device achieves
throughput approaching 1 MIPS/MHz.
Outputs: Finally, the output is the signal the arduino sends to a component.
As with the input, output can be an on/off, variable voltage*, or
communication signal.
Power Supply:
The Arduino Uno power supply can be done with the help of a USB cable or an
external power supply. The external power supplies mainly include AC to DC
adapter otherwise a battery. The adapter can be connected to the Arduino Uno
by plugging into the power jack of the Arduino board. Similarly, the battery ,
leads can be connected to the Vin pin and the GND pin of the POWER
connector. The suggested voltage range will be 7 volts to 12 volts.
Input & Output:
The 14 digital pins on the Arduino Uno can be used as input & output with the
help of the FIG: 5 PIN diagram of arduino uno functions like pinMode(),
digitalWrite(), & Digital Read().
Memory:
The memory of this Atmega328 Arduino microcontroller includes flash memory-
32 KB for storing code, SRAM-2 KB EEPROM-1 KB.
Communication:
The Arduino Uno ATmega328 offers UART TTL-serial communication, and it is
accessible on digital pins like TX (1) and RX (0). The software of an Arduino has a
serial monitor that permits easy data. There are two LEDs on the board like RX &
TX which will blink whenever data is being broadcasted through the USB.
IR Transmitter or IR LED:
Infrared Transmitter is a light emitting diode (LED) which emits infrared
radiations called as IR LED’s. Even though an IR LED looks like a normal LED, the
radiation emitted by it is invisible to the human eye.
Where,
Speed = Speed of Radio signal which is approximately equal to the speed of light
i.e.
Time = Time required for a signal to travel from the satellite to the receiver.
By subtracting the sent time from the received time, we can determine the
travel time.
All the necessary data pins of the SIM800L GSM chip are broken out to a 0.1″
pitch headers, including the pins required for communication with the
microcontroller over the UART. The module supports baud rates ranging from
1200 bps to 115200 bps and features automatic baud rate detection.
There’s a SIM socket on the back! Any 2G Micro SIM card will work perfectly.
The proper way to insert the SIM card is typically engraved on the surface of the
SIM socket.
Transmit Power
Class 4 (2W) for GSM850
Class 1 (1W) for DCS1800
Serial-based AT Command Set
FL connectors for cell antennae
Accepts Micro SIM Card
The SIM800L module has an LED that indicates the status of your cellular
network. It will blink at different rates depending on the state it is in.
4.3.4 ANTENNA :-
The SIM800L module requires an external antenna in order to connect to the
network, so choosing the right antenna is very important. There are two options
available.
The first is a helical antenna that comes with the module and can be soldered
directly to the PCB. This antenna is very useful for space-constrained projects.
However, be aware that you may face difficulties establishing a connection,
particularly if your project is indoors.
Fig : 15 antenna
The SIM800L module has 12 pins in total. The following is the pinout:
NET :- pin is where you can solder the helical antenna that comes with the
module.
VCC :- is the power supply pin. Keep in mind that the SIM800L chip has an
operating voltage range of 3.4 V to 4.4 V, so connecting this module to the
Arduino’s 5V output is probably going to cause damage to the module. It
doesn’t even run on 3.3 V! Use a Li-Po battery or a DC-DC buck converter
instead.
RST (Reset) :- is the reset pin. If you got the module in an absolutely bad
space, pull this pin LOW for 100ms to perform a hard reset.
RxD (Receiver) :-pin is used to send commands to the module. This pin is
auto-baud so the baud rate at which you send the “AT” command after reset
is the baud rate used.
TxD (Transmitter):- pin transmits data from the module to the
microcontroller.
GND:- is the ground pin.
The efficient power conversion in bulk converter extends battery life and
reduces the heat produced. So, it is mostly preferred for the production of
smaller gadgets. It can be used in lots of cool applications. It is widely used in
SMPS (switched-mode power supply) where the output dc voltage required is
less than the input dc voltage. The operation of the buck converter is based on
the principle of storing energy in an inductor. The voltage drop across an
inductor is proportional to the change in the electric current flowing through
the device. A switching transistor is used in between input and output for
continuous switches on and off at high frequency. To maintain a continuous
output, the circuit uses the energy stored in the inductor.
4.4.1 Applications :-
Buck converter is basically used for conversion of high dc voltage to low dc
voltage.
It is mostly used in the following applications:
It is used in battery power systems such as battery chargers for mobile
phones, laptops, and power banks
It is used in self-regulating power systems such as SMPS
It is used point of load converters for PCs and motherboards
It is used in solar chargers
It is used in adaptive control applications
It is used in power audio amplifier applications
Warnings
You must be very careful not to disconnect GND before VCC and to always
connect GND before VCC. Otherwise, the module may use the low voltage
serial pins as ground, causing damage to the module.
Also, ensure that your circuit and Arduino share a common ground.
IDE 2.0 :-
On September 14, 2022, the Arduino IDE 2.0 was officially released as stable.
Previously, on October 18, 2019 the initial alpha preview was released as the
Arduino Pro IDE. On March 1, 2021, the beta preview was released, renamed
IDE 2.0. The system still uses Arduino CLI (Command Line Interface), but
improvements include a more professional development environment,
autocompletion support, and Git integration.The application frontend is based
on the Eclipse Theia Open Source IDE. The main features available in the new
release are:
• Modern, fully featured development environment
• Dual Mode, Classic Mode (identical to the Classic Arduino IDE) and Pro
Mode (File System view)
• New Board Manager
• New Library Manager
• Board List
• Basic Auto-Completion (Arm targets only)
• Git Integration
• Serial Monitor
• Dark Mode
Sketch :-
A sketch is a program written with the Arduino IDE. Sketches are saved on the
development computer as text files with the file extension .ino. Arduino
Software (IDE) pre-1.0 saved sketches with the extension.ide.
A minimal Arduino C/C++ program consists of only two functions:
• setup(): This function is called once when a sketch starts after power-up or
reset. It is used to initialize variables, input and output pin modes, and other
libraries needed in the sketch. It is analogous to the function main().
• loop(): After setup() function exits (ends), the loop() function is executed
repeatedly in the main program. It controls the board until the board is
powered off or is reset. It is analogous to the function while(1).
The open-source nature of the Arduino project has facilitated the publication of
many free software libraries that other developers use to augment their
projects.
Code Editor :-
The IDE comes with a code editor that provides syntax highlighting and auto-
completion for the Arduino programming language. The code editor in the
Arduino IDE is designed to be simple and easy to use, even for beginners.
It provides syntax highlighting, auto-indentation, and auto-completion features
to help make coding easier and more efficient. These features help highlight
keywords, functions, and variables in different colors, making it easier to read
and understand the code. The code editor in the Arduino IDE is based on the
open-source Code Mirror editor, which is a highly customizable and extensible
editor that is used by many other programming tools and platforms. This means
that users can customize the code editor to suit their specific needs and
preferences.
Library Manager :-
The IDE has a library manager that allows you to easily install and manage
libraries that you need for your project. The Arduino library manager is a feature
built into the Arduino IDE (Integrated Development Environment) that allows
users to easily download, install, and manage libraries that can be used in their
Arduino projects. Libraries are collections of pre-written code that can be used
to perform specific functions or tasks in an Arduino project, such as controlling a
motor or reading a sensor.
They are designed to save time and effort by providing ready-made code that
can be easily incorporated into your project.
Here are some key features of the Arduino library manager:
Serial Monitor:-
The IDE has a built-in serial monitor that allows you to send and receive data
between your Arduino board and your computer. The Arduino Serial Monitor is
a tool built into the Arduino IDE (Integrated Development Environment) that
allows you to communicate with your Arduino board over a serial connection. It
provides a way to send and receive data between your Arduino board and your
computer.
The Serial Monitor is useful for debugging and testing your Arduino projects. It
allows you to view the output of your code, send commands to your board, and
monitor the values of variables in real-time.
Here are some key features of the Arduino Serial Monitor:
Real-Time Data Display:- The Serial Monitor provides real-time display of data
that is sent from your Arduino board to your computer. This can be helpful
when you need to monitor sensor readings or other data in real-time.
Command Input:- The Serial Monitor allows you to send commands to your
Arduino board from your computer. This can be useful for controlling motors
or other devices connected to your board.
Variable Monitoring:- The Serial Monitor allows you to monitor the values of
variables in your code as they change in real-time. This can be helpful when
you need to debug your code or troubleshoot issues with your project.
Data Visualization:- The Serial Monitor allows you to plot data from your
Arduino board on a graph. This can be useful when you need to visualize
changes in sensor readings or other data.
Board Manager :-
The IDE has a board manager that allows you to easily select the type of
Arduino board you are using. The Arduino Board Manager is a feature built into
the Arduino IDE (Integrated Development Environment) that allows users to add
and manage different types of boards that can be used with Arduino.
Here are some key features of the Arduino Board Manager:
Board Support :- The Board Manager allows you to add support for a wide
range of boards that are compatible with Arduino, including official Arduino
boards and third-party boards.
Easy Installation :- The Board Manager makes it easy to install board support
packages. Simply select the board you want to add, and the Board Manager
will automatically download and install the required files.
Board Configuration :- The Board Manager also allows you to configure the
settings for each board. This can include things like selecting the board type,
setting the processor frequency, and choosing the upload method.
Multiple Board Support :- The Board Manager allows you to manage support
for multiple boards in the same IDE, making it easy to switch between
different boards when working on different projects.
Automatic Updates :- The Board Manager provides automatic updates for
board support packages. When a new version of a board package is available,
the Board Manager will notify you and give you the option to update.
Upload :-
The IDE allows you to easily compile and upload your code to your Arduino
board. The Arduino code uploader, also known as the Arduino bootloader, is a
small piece of code that is preloaded onto the microcontroller of an Arduino
board. The boot loader enables the microcontroller to receive new firmware
(i.e., the code for your project) through a serial connection from a computer,
without the need for an external programmer.
Here are some key features of the Arduino code uploader:
Easy Firmware Upload:- The code uploader allows you to easily upload your
code to the microcontroller on the Arduino board, without the need for an
external programmer
Serial Communication:- The code uploader communicates with your
computer over a serial connection. This allows you to send your code to the
microcontroller from the Arduino IDE.
Automatic Reset:- When you upload new firmware to the microcontroller,
the code uploader automatically resets the board. This puts the board in
programming mode, allowing the new firmware to be uploaded
Boot loader Size:- The Arduino boot loader takes up a small amount of space
on the microcontroller, leaving plenty of room for your project code.
Overwrite Protection:- The boot loader includes protection to prevent
accidental overwrite of the boot loader code, ensuring that the board
remains in programming mode for firmware uploads.
We used an Arduino Uno board to interface GPS, IR sensor, and GSM module.
The GPS module was used to obtain the location of the vehicle,
while the IR sensor was used to detect collisions. The GSM module was used to
send an alert message to a designated phone number in the event of an
accident.
The system was designed to continuously monitor the vehicle's movement using
GPS and compare it with a predefined safe route. If the vehicle deviates from
the safe route or if the IR sensor detects a collision, the system sends an SMS
message containing the location of the accident to a pre-programmed number.
The system also turns on the hazard lights to alert nearby vehicles.
Overall, there are many ways to upgrade a vehicle accident detection system,
depending on your specific requirements and the level of safety you want to
achieve.
CONCLUSION
Vehicle tracking system makes better fleet management and which in turn
brings large profits. 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-to-day living.
Main motto of the accident alert system project is to decrease the chances of
losing life in such accident which we can’t stop from occurring. Whenever
accident is alerted the paramedics are reached to the particular location to
increase the chances of life. This device invention is much more useful for the
accidents occurred in deserted places and midnights. This vehicle tracking and
accident alert feature plays much more important role in day to day life in
future The vehicle accident detection System is an essentially a tool anticipated
by the present work used to prevent the drivers lifetime, whore main constantly
driving the vehicle (car) and aren't ready to get sufficient sleep. Several
accidents happen especially within the developing countries such as India
everywhere the quantity of the on road vehicles rises per annum. The
anticipated scheme defends the driving force from misfortune moment which
may happen due to fatigue of the driving force. The anticipated scheme is
reasonable as related to former schemes existing in the luxurious cars.
Habitually, one among the foremost essential and active feature of the system is
to create the practical readiness to identify as the attention is shut or open,
whenever vehicle driver lonely closing the eyes and that point sound alert
system is activated.
APPINDEX
#include <SoftwareSerial.h>
SoftwareSerial sim(2, 3);
int _timeout;
int ir = 8;
String _buffer;
String number = "+919640198259"; //-> change with your number
void setup() {
//delay(3000); //delay for 7 seconds to make sure the modules get the signal
pinMode(ir, INPUT);
Serial.begin(9600);
_buffer.reserve(50);
Serial.println("System Started...");
sim.begin(9600);
delay(1000);
Serial.println("Type s to send an SMS, r to receive an SMS, and c to make a
call");
}
void loop() {
int o = digitalRead(ir);
if(o == LOW){
SendMessage();
}
if (Serial.available() > 0)
switch (Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
break;
case 'c':
callNumber();
break;
}
if (sim.available() > 0)
Serial.write(sim.read());
}
void SendMessage()
{
//Serial.println ("Sending Message");
sim.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(200);
//Serial.println ("Set SMS Number");
sim.println("AT+CMGS=\"" + number + "\"\r"); //Mobile phone number to send
message
delay(200);
String SMS = "Accident Happened, Location is....
https://www.google.com/maps/place/17.388967,78.481788";
sim.println(SMS);
delay(100);
sim.println((char)26);// ASCII code of CTRL+Z
delay(200);
_buffer = _readSerial();
}
void RecieveMessage()
{
Serial.println ("SIM800L Read an SMS");
sim.println("AT+CMGF=1");
delay (200);
sim.println("AT+CNMI=1,2,0,0,0"); // AT Command to receive a live SMS
delay(200);
Serial.write ("Unread Message done");
}
String _readSerial() {
_timeout = 0;
delay(13);
_timeout++;
}
if (sim.available()) {
return sim.readString();
}
}
void callNumber() {
sim.print (F("ATD"));
sim.print (number);
sim.print (F(";\r\n"));
_buffer = _readSerial();
Serial.println(_buffer);
}
BIBLIOGRAPHY
CHROME :-
https://www.google.com/search?q=goo
gle&oq=google&aqs=chrome..69i57j69i6
0l3.14788j0j7&sourceid=chrome&ie=UTF
-8
WIKIPEDIA :-
https://www.wikipedia.org/
CIRCUIT DESIGN :-
https://www.circuito.io/