Description:
This is a simple alert system which uses ADXL335 Accelerometer sensor that detects tilts of car whenever any misery happens and then send SMS to the desired Mobile Device using GSM Module with a location using GSM Module. Everything is controlled by Arduino UNO.
Circuit Diagram:
Components:
SR. NO. | COMPONENT | PINOUT DIAGRAM | BUY |
---|---|---|---|
1 | Arduino UNO (Other Arduinos can be used too) | Arduino UNO Pinout Diagram⇗ | |
2 | Accelerometer ADXL335 Sensor | ||
3 | GPS Module SIM28ML | ||
4 | GSM Module SIM900A | ||
5 | 16×2 LCD Display | ||
6 | 10K Ohm Potentiometer | ||
7 | A Phone | ||
8 | SIM Card |
Arduino UNO
The Arduino UNO is a microcontroller board based on the ATmega328P. It is a powerful and versatile platform that is widely used in a variety of projects, including the vehicle accident alert system. The Arduino UNO can be easily programmed using the Arduino IDE, which allows users to write code in C++ and upload it to the board. In the context of a vehicle accident alert system, the Arduino UNO is used to process signals received from the ADXL335 accelerometer and GPS module, and send an emergency message via GSM module in case of an accident. The Arduino UNO has a variety of input and output pins that allow it to interface with different sensors and actuators, such as the ADXL335 accelerometer, GPS module, and GSM module. This makes it an ideal solution for creating a complete vehicle accident alert system. Additionally, its small size and low power consumption make it suitable for use in vehicles.
ADXL335 Accelerometer Sensor
The ADXL335 is a low power, triple axis MEMS (Micro-Electro-Mechanical Systems) accelerometer sensor. It is commonly used to measure acceleration and tilt in a variety of applications including in a vehicle accident alert system. The ADXL335 sensor is capable of measuring acceleration in the range of +/- 3g. It works by detecting changes in acceleration and sending signals to the Arduino UNO, which then processes the signals to determine if an accident has occurred. The ADXL335 sensor is highly sensitive and can detect even small changes in acceleration, making it an ideal solution for detecting sudden deceleration or impact in a vehicle accident. Additionally, it is also a low power consumption device, making it suitable for use in vehicles where power availability is limited. The ADXL335 sensor can communicate with the Arduino UNO via analog pins, which makes it easy to integrate with the Arduino UNO board to build the complete accident alert system.
SIM28ML GPS Module
The SIM900A GSM Module is a compact, low-cost device that is used to send and receive data via the GSM network. In the context of a vehicle accident alert system, the SIM900A GSM Module is used to send an emergency message to a pre-configured phone number in case of an accident. The SIM900A GSM Module is connected to the Arduino UNO and receives commands from it to send an SMS message or make a call to the emergency contacts. It can also receive the GPS coordinates from the GPS module connected to the Arduino and send it as a message to the emergency contact.
The SIM900A GSM Module is highly reliable, it can be used in different countries with different frequencies, and it also features a built-in TCP/IP stack which allows for internet connectivity. It can also be used for other applications such as sending and receiving SMS, making and receiving calls, and even connecting to the internet. It is a cost-effective and easy to use device for adding GSM functionality to projects, making it an ideal solution for a vehicle accident alert system. Additionally, the SIM900A GSM Module is also low power consumption and it can be powered by the car battery making it suitable for use in vehicles.
SIM900A GSM Module
The SIM28ML GPS module is a compact, high-performance device that is used to determine the location of a vehicle. In the context of a vehicle accident alert system, the SIM28ML GPS module is used to determine the location of the vehicle in case of an accident and send the coordinates to the emergency contacts via the GSM module. The SIM28ML GPS module is connected to the Arduino UNO and sends the location data to it via serial communication. It uses satellite signals to determine the location and can provide location data with high accuracy and low power consumption.
The SIM28ML GPS module is highly sensitive, it can track up to 22 satellites at a time, and it also has a built-in antenna which allows for a stable signal even in weak signal areas. It also supports AssistNow Offline, SBAS (WAAS, EGNOS, MSAS) which improves the positioning accuracy. The SIM28ML GPS module can provide location data in different formats such as NMEA, UBX, and RMC, this allows for easy integration with the Arduino UNO and the GSM module to build the complete accident alert system. Additionally, the SIM28ML GPS module is also low power consumption and it can be powered by the car battery making it suitable for use in vehicles.
Steps and Info:
1. Get correct components as given. You can buy online or offline. I buy electronics components mostly from Amazon.
2. Start connecting the components. If you are new to connecting components in an electronic circuit, then use a Breadboard or you can straight up make connections using Jumper wires but it will create problem when there will be two or more connections needed at one pin(for example two or more different sensors 5V connection to Arduino’s 5V pin). But before soldering components on a PCB or printing a PCB for your circuit, better try using breadboard so that any errors and mistakes can be observed on breadboard and not after soldering. Or do connections in your way.
3. Now after building the circuit, download the Arduino IDE from https://www.arduino.cc/ website.
4. If you are new to Arduino IDE software, then watch this video we made specially for beginners about Arduino IDE.
5. If you know Arduino IDE then straight up copy the code we given and paste it into the Arduino IDE sketch.
6. Connect the Arduino to your Computer/device. Select a proper port, proper Arduino type and whatever other settings are. Here it is Arduino UNO. (If you don’t know what this all is then watch our video: ).
7. Compile the code and Upload it.
8. If any error occurs then try to troubleshoot it by finding/copy-pasting it into our Solve Errors page https://electronicsprojects.in/solve-errors/, or you can straight up paste the error on Internet and you know the rest. Also check if there are no spelling/syntax errors in the code. Compile the code again once to check if errors are fixed. I have given proper connections and code but still nothing is perfect.
9. Once code compiles and uploads smoothly, you can start testing the working of your circuit/project.
10. For this project, take your circuit outside in open so that the satellite will detect the GPS. Also make sure that you have recharged an active SMS pack to the SIM card added in the GSM Module. Now take the accelerometer and tilt in different degrees, basically we are simulating a car tilting. When you will tilt the accelerometer within certain degrees, you will get an SMS to the phone number you added in the code. Check if all works, if doesn’t then check connections and code. You can also talk with me on discord, find problems in on our Solve Errors page https://electronicsprojects.in/solve-errors/ or find solution on Internet.
Program Code:
/* www.electronicsprojects.in Vehicle Accident Alert System using Arduino, ADXL335 Accelerometer, GPS and GSM */
#include<SoftwareSerial.h>
SoftwareSerial Serial1(8,9); /* If output not came then try this (9,8) */
SoftwareSerial gps(10,11);
#include<LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7); /* If output not came then try this (7,6,5,4,3,2) */
#define x A0
#define y A1
#define z A2
int xsample=0;
int ysample=0;
int zsample=0;
#define samples 10
#define minVal -50
#define MaxVal 50
int i=0,k=0;
int gps_status=0;
float latitude=0;
float logitude=0;
String Speed="";
String gpsString="";
char *test="$GPRMC";
void initModule(String cmd, char *res, int t)
{
while(1)
{
Serial.println(cmd);
Serial1.println(cmd);
delay(100);
while(Serial1.available()>0)
{
if(Serial1.find(res))
{
Serial.println(res);
delay(t);
return;
}
else
{
Serial.println("Error");
}
}
delay(t);
}
}
void setup()
{
Serial1.begin(9600);
Serial.begin(9600);
lcd.begin(16,2);
lcd.print("Vehicle Accident");
lcd.setCursor(0,1);
lcd.print("Alert System");
delay(2000);
lcd.clear();
lcd.print("Getting Ready");
lcd.setCursor(0,1);
lcd.print("...");
delay(1000);
Serial.println("Getting Ready");
initModule("AT","OK",1000);
initModule("ATE1","OK",1000);
initModule("AT+CPIN?","READY",1000);
initModule("AT+CMGF=1","OK",1000);
initModule("AT+CNMI=2,2,0,0,0","OK",1000);
Serial.println("System Ready");
lcd.clear();
lcd.print("System");
lcd.setCursor(0,1);
lcd.print("Ready");
delay(2000);
lcd.clear();
lcd.print("Sensing");
lcd.setCursor(0,1);
lcd.print("Accelerometer");
for(int i=0;i<samples;i++)
{
xsample+=analogRead(x);
ysample+=analogRead(y);
zsample+=analogRead(z);
}
xsample/=samples;
ysample/=samples;
zsample/=samples;
Serial.println(xsample);
Serial.println(ysample);
Serial.println(zsample);
delay(1000);
lcd.clear();
lcd.print("Getting GPS");
lcd.setCursor(0,1);
lcd.print("Ready");
delay(2000);
gps.begin(9600);
get_gps();
show_coordinate();
delay(2000);
lcd.clear();
lcd.print("GPS is Ready");
delay(1000);
lcd.clear();
lcd.print("System Ready");
Serial.println("System Ready");
}
void loop()
{
int value1=analogRead(x);
int value2=analogRead(y);
int value3=analogRead(z);
int xValue=xsample-value1;
int yValue=ysample-value2;
int zValue=zsample-value3;
Serial.print("x=");
Serial.println(xValue);
Serial.print("y=");
Serial.println(yValue);
Serial.print("z=");
Serial.println(zValue);
if(xValue < minVal || xValue > MaxVal || yValue < minVal || yValue > MaxVal || zValue < minVal || zValue > MaxVal)
{
get_gps();
show_coordinate();
lcd.clear();
lcd.print("Sending SMS ");
Serial.println("Sending SMS");
Send();
Serial.println("SMS Sent");
delay(2000);
lcd.clear();
lcd.print("System Ready");
}
}
void gpsEvent()
{
gpsString="";
while(1)
{
while (gps.available()>0)
{
char inChar = (char)gps.read();
gpsString+= inChar;
i++;
// Serial.print(inChar);
if (i < 7)
{
if(gpsString[i-1] != test[i-1])
{
i=0;
gpsString="";
}
}
if(inChar=='\r')
{
if(i>60)
{
gps_status=1;
break;
}
else
{
i=0;
}
}
}
if(gps_status)
break;
}
}
void get_gps()
{
lcd.clear();
lcd.print("Loading GPS");
lcd.setCursor(0,1);
lcd.print("...");
gps_status=0;
int x=0;
while(gps_status==0)
{
gpsEvent();
int str_lenth=i;
coordinate2dec();
i=0;x=0;
str_lenth=0;
}
}
void show_coordinate()
{
lcd.clear();
lcd.print("Lat:");
lcd.print(latitude);
lcd.setCursor(0,1);
lcd.print("Log:");
lcd.print(logitude);
Serial.print("Latitude:");
Serial.println(latitude);
Serial.print("Longitude:");
Serial.println(logitude);
Serial.print("Speed(in knots)=");
Serial.println(Speed);
delay(2000);
lcd.clear();
lcd.print("Speed(Knots):");
lcd.setCursor(0,1);
lcd.print(Speed);
}
void coordinate2dec()
{
String lat_degree="";
for(i=20;i<=21;i++)
lat_degree+=gpsString[i];
String lat_minut="";
for(i=22;i<=28;i++)
lat_minut+=gpsString[i];
String log_degree="";
for(i=32;i<=34;i++)
log_degree+=gpsString[i];
String log_minut="";
for(i=35;i<=41;i++)
log_minut+=gpsString[i];
Speed="";
for(i=45;i<48;i++)
Speed+=gpsString[i];
float minut= lat_minut.toFloat();
minut=minut/60;
float degree=lat_degree.toFloat();
latitude=degree+minut;
minut= log_minut.toFloat();
minut=minut/60;
degree=log_degree.toFloat();
logitude=degree+minut;
}
void Send()
{
Serial1.println("AT");
delay(500);
serialPrint();
Serial1.println("AT+CMGF=1");
delay(500);
serialPrint();
Serial1.print("AT+CMGS=");
Serial1.print('"');
Serial1.print("6969696969"); /*Add your Smart Phone Number here*/
Serial1.println('"');
delay(500);
serialPrint();
Serial1.print("Latitude:");
Serial1.println(latitude);
delay(500);
serialPrint();
Serial1.print(" longitude:");
Serial1.println(logitude);
delay(500);
serialPrint();
Serial1.print(" Speed:");
Serial1.print(Speed);
Serial1.println("Knots");
delay(500);
serialPrint();
Serial1.print("http://maps.google.com/maps?&z=15&mrt=yp&t=k&q=");
Serial1.print(latitude,6);
Serial1.print("+");
Serial1.print(logitude,6);
Serial1.write(26);
delay(2000);
serialPrint();
}
void serialPrint()
{
while(Serial1.available()>0)
{
Serial.print(Serial1.read());
}
}