How to Build a Smart Helmet with Accident Detection for Engineering and University Projects

A smart helmet with accident detection is a safety project that watches the rider's motion, detects a crash, and sends an SMS with the location to an emergency contact. It is a popular choice for school and university students in Pakistan who want a final year project that combines sensors, Arduino, GSM and GPS in one working system.

This guide builds the full system: an MPU6050 accelerometer watches for a sudden impact, a vibration sensor confirms the crash, the Arduino reads the GPS coordinates, and a SIM800L GSM module sends an SMS with a Google Maps link. The HC-05 Bluetooth module is optional and is not needed for the alert to work.

This is a student demonstration model, not a certified safety device. Always wear a proper certified helmet on the road - this project shows how the detection and alert system works, it does not make an ordinary helmet crash-proof.

Wiring connections of the Smart Helmet accident detection project.

How the System Works

The helmet uses five parts that each do one job:

  • MPU6050 accelerometer and gyroscope - watches acceleration in all directions and detects a sudden impact or a fall.
  • SW-420 vibration sensor - confirms that a real physical shock happened, so a small bump does not trigger a false alarm.
  • Arduino UNO or Nano - reads both sensors and decides whether a crash happened.
  • NEO-6M GPS module - gives the latitude and longitude of the crash location.
  • SIM800L GSM module - sends the SMS with the location link to the emergency number.

When a crash is detected, the Arduino waits 10 seconds, reads the GPS position, and sends one SMS: "Accident detected! Rider may need help" plus a Google Maps link. The SMS needs a SIM card with balance and mobile network coverage, and the GPS needs a clear view of the sky to get a fix.

Main Components Needed

ComponentPrice / link
Arduino UNO R3 DIPArduino UNO R3 DIP ATmega328P with USB Cable - Rs 1,200
Arduino Nano V3 (smaller, better fit inside a helmet)Arduino Nano V3 ATmega328P with USB Cable - Rs 650 (without cable) / Rs 750 (with cable)
MPU6050 accelerometer + gyroscope moduleNo QKZEE listing - available at the Hall Road shop on request
SW-420 vibration sensor moduleNo QKZEE listing - available at the Hall Road shop on request
SIM800L GSM moduleNo QKZEE listing - available at the Hall Road shop on request
NEO-6M GPS module with antennaNo QKZEE listing - available at the Hall Road shop on request
HC-05 Bluetooth module (optional)No QKZEE listing - available at the Hall Road shop on request
18650 Li-ion cell 2000mAh18650 Lithium-Ion Rechargeable Cell 2000mAh - Lot Rs 200 / New Rs 250
Single cell 18650 battery holderSingle Cell 18650 Battery Holder - Rs 45
MB102 breadboard (for testing on the bench)MB102 Breadboard 830 Points - Rs 250
40-pin jumper wires40-Pin Jumper Wires 30cm - Rs 180
A helmet, foam padding, a SIM card with balanceFrom a local shop

Use the UNO on the bench and the Nano for the final helmet build - the Nano is much smaller and the code and wiring are the same. Do not drill through the helmet shell or cut its protective foam to fit the electronics; mount the modules on the inner padding with foam and cable ties.

Circuit Diagram Overview

Wire the modules to the Arduino as follows. The MPU6050 uses the I2C pins (A4 and A5 on the UNO and Nano). The three serial modules share SoftwareSerial - the Arduino UNO has only one hardware serial port, which is used for the USB connection to the computer, so the sketch switches between the GPS and GSM modules with .listen().

MPU6050 Accelerometer - Arduino

MPU6050 pinArduino pin
VCC5V
GNDGND
SDAA4
SCLA5

SW-420 Vibration Sensor - Arduino

Vibration sensor pinArduino pin
VCC5V
GNDGND
DO (digital output)D3

SIM800L GSM Module - Arduino

SIM800L pinArduino pin
TXD7
RXD8
VCC3.7-4.2V from a separate source (a Li-ion cell or a buck converter that can give 2A)
GNDGND (common ground with the Arduino)

Do not power the SIM800L from the Arduino 5V pin. The module draws up to 2A in short bursts when it sends an SMS, which the Arduino regulator cannot supply - the board will reset or the regulator can be damaged.

NEO-6M GPS Module - Arduino

GPS pinArduino pin
TXD4
RXD5
VCC5V
GNDGND

HC-05 Bluetooth Module - Arduino (optional)

HC-05 pinArduino pin
TXD10
RXD11 (through a 1k + 2k voltage divider - the HC-05 RX pin is 3.3V logic)
VCC5V
GNDGND

Power

Power the Arduino from a 5V power bank through the USB port, or feed 7-12V into the VIN pin (the wiring diagram shows a 12V feed into VIN). The SIM800L always needs its own 3.7V source as shown above - it is the only module that must not share the Arduino supply.

Required Libraries

Install these from the Arduino IDE Library Manager (Sketch - Include Library - Manage Libraries):

  • Adafruit MPU6050 by Adafruit
  • Adafruit Unified Sensor by Adafruit
  • TinyGPS++ by Mikal Hart

SoftwareSerial and Wire are built into the Arduino IDE - no install needed.

Complete Arduino Code

/*
  Smart Helmet with Accident Detection
  Board: Arduino UNO (or Nano - same pins, same code).
  MPU6050 (I2C) + SW-420 vibration sensor detect a crash,
  NEO-6M GPS gives the location, SIM800L sends an SMS with a
  Google Maps link. The HC-05 Bluetooth module is optional
  and is NOT used by this sketch.
*/

#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <math.h>

Adafruit_MPU6050 mpu;
TinyGPSPlus gps;

SoftwareSerial gsmSerial(7, 8);   // SIM800L: TX -> D7, RX -> D8
SoftwareSerial gpsSerial(4, 5);   // NEO-6M: TX -> D4, RX -> D5

const int vibPin = 3;              // SW-420 digital output -> D3

// <-- APNA EMERGENCY NUMBER YAHAN LIKHAIN (country code ke saath) -->
const char* EMERGENCY_NUMBER = "+92XXXXXXXXXX";

// At rest the acceleration is about 9.8 m/s^2 (gravity).
// A crash spikes above 25 m/s^2 (about 2.5 g); a free fall drops below 2.
const float CRASH_HIGH = 25.0;
const float CRASH_LOW  = 2.0;
const unsigned long COOLDOWN_MS = 60000;  // 60 seconds between alerts

unsigned long lastAlert = 0;

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

  pinMode(vibPin, INPUT);

  if (!mpu.begin()) {
    Serial.println("MPU6050 not found! Check SDA -> A4, SCL -> A5.");
    while (1) { delay(10); }
  }
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);

  Serial.println("Smart Helmet ready.");
  Serial.println("Shake the helmet hard to test, or wait for a real impact.");
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  float mag = sqrt(a.acceleration.x * a.acceleration.x
                 + a.acceleration.y * a.acceleration.y
                 + a.acceleration.z * a.acceleration.z);
  int vibration = digitalRead(vibPin);

  // Keep the GPS parser fed while we monitor
  gpsSerial.listen();
  while (gpsSerial.available()) {
    gps.encode(gpsSerial.read());
  }

  bool crash = (mag > CRASH_HIGH || mag < CRASH_LOW) && (vibration == HIGH);

  if (crash && (millis() - lastAlert > COOLDOWN_MS)) {
    lastAlert = millis();
    sendAlertSMS();
    delay(5000);
  }

  delay(100);
}

void sendAlertSMS() {
  Serial.println("Crash suspected! Reading GPS, then sending SMS in 10 seconds...");
  delay(10000);

  // Give the GPS up to 8 seconds to deliver a fresh fix
  gpsSerial.listen();
  unsigned long start = millis();
  while (millis() - start < 8000) {
    while (gpsSerial.available()) {
      gps.encode(gpsSerial.read());
    }
    if (gps.location.isUpdated()) break;
  }

  String message = "Accident detected! Rider may need help. ";
  if (gps.location.isValid()) {
    message += "Location: https://maps.google.com/?q=";
    message += String(gps.location.lat(), 6);
    message += ",";
    message += String(gps.location.lng(), 6);
  } else {
    message += "GPS fix not available yet. Check the rider's last known location.";
  }

  gsmSerial.listen();
  gsmSerial.println("AT+CMGF=1");
  delay(500);
  gsmSerial.print("AT+CMGS=\"");
  gsmSerial.print(EMERGENCY_NUMBER);
  gsmSerial.println("\"");
  delay(500);
  gsmSerial.print(message);
  gsmSerial.write(26);  // Ctrl+Z sends the SMS
  delay(2000);

  Serial.println("SMS sent:");
  Serial.println(message);
}

What This Code Does

  • Reads the MPU6050 acceleration every 100 ms and works out the total magnitude.
  • Treats it as a crash only when the acceleration spikes above 25 m/s2 (or drops below 2 m/s2 in a free fall) AND the vibration sensor also reads HIGH - both conditions together stop small bumps from sending false alarms.
  • Waits 10 seconds after a suspected crash, then reads the GPS for up to 8 seconds.
  • Sends one SMS with a Google Maps link when the GPS has a fix, or an honest "GPS fix not available yet" message when it does not.
  • Sends at most one alert per minute (60-second cooldown).
  • Does not use the HC-05 Bluetooth module - the old version created it but never used it, so it is left out of the sketch and listed as optional above.

The 10-second wait is a pause before the SMS goes out. This simple build has no cancel button - adding a push button that cancels the alert inside those 10 seconds is a good extension for your own version.

How to Make the Smart Helmet

Step 1: Test on the Bench First

Wire everything on the breadboard and upload the sketch before putting anything in a helmet. Open the Serial Monitor at 9600 baud and check that it prints "Smart Helmet ready."

Step 2: Mount the Sensors

Fix the MPU6050 and the vibration sensor firmly inside the helmet on the inner padding, with the MPU6050 flat. A loose sensor rattles and gives false readings.

Step 3: Fix the Modules

Place the SIM800L, GPS and Arduino in foam casing so nothing shorts against the helmet shell. Keep the GPS antenna facing up and the SIM800L antenna clear of metal.

Step 4: Wiring and Soldering

Replace the breadboard jumper wires with soldered connections for the final build - loose jumpers fall out inside a helmet. Keep the SIM800L on its own 3.7V supply as wired above.

Step 5: Upload the Code

Put your real emergency number in EMERGENCY_NUMBER at the top of the sketch, then upload with the Arduino IDE.

Step 6: Test the System

Shake the helmet hard while it sits on a table and check that the SMS arrives with a Maps link. Do not wear the helmet during the crash test - test it on a cushion, not on your head.

Testing the System

  1. Test the MPU6050 first. The Serial Monitor should print "Smart Helmet ready." If it prints "MPU6050 not found", check SDA to A4 and SCL to A5, and that the module has power.
  2. Test the vibration sensor. Tap the sensor - a crash alert should only fire when a hard shake and a vibration happen together.
  3. Test the GPS. Take the helmet outside with a clear view of the sky. The first fix (cold start) can take 2-5 minutes. Indoors, under a roof, or between tall buildings the GPS may never get a fix.
  4. Test the SMS. Trigger one alert and check that the phone receives the SMS with a working Maps link. If no SMS arrives, check the SIM balance, the 3.7V supply, and that the SIM800L antenna is attached.
  5. Test the full crash. Drop the helmet onto a cushion from a small height and confirm one SMS is sent, then no more for 60 seconds.

Troubleshooting

  • "MPU6050 not found": check SDA to A4, SCL to A5, and that VCC is on 5V. Some MPU6050 boards have the AD0 pin pulled so the address is 0x69 instead of 0x68 - the Adafruit library uses 0x68 by default.
  • No SMS arrives: check the SIM has balance, the SIM800L has its own 3.7V supply (not the Arduino 5V pin), and the antenna is attached. Watch the Serial Monitor - "SMS sent" with the message text means the Arduino did its part.
  • GPS never gets a fix: go outside with a clear sky view and wait up to 5 minutes on the first run. GPS does not work indoors.
  • False alarms on small bumps: raise CRASH_HIGH from 25 to 30, or mount the vibration sensor more firmly so it only triggers on a real shock.
  • Garbled replies from the SIM800L: its TX pin is 2.8V logic. Most UNO boards read it fine, but if replies look garbled, add a level shifter between the SIM800L TX and Arduino D7.
  • Two SMS for one crash: that is the 60-second cooldown working as written - a second crash inside the cooldown is ignored, which is correct.

Applications

  • School and college projects - a complete sensor + GSM + GPS system in one build.
  • Final year projects - accident detection with a live SMS and map link is easy to demonstrate to judges.
  • IoT and safety-awareness demos - shows how embedded systems, wireless modules and location services work together.
  • A base for your own version - add a cancel button, a buzzer alarm, or a fall log on an SD card.

Where to Buy the Components

The Arduino UNO, Nano, jumper wires, breadboard, 18650 cell and holder are available at QKZEE Technologies, Shop 20, 1st Floor, Al-Khalil Center, Hall Road, Lahore, and online at qkzeetech.com with delivery all over Pakistan - see the links above. The MPU6050, vibration sensor, SIM800L, NEO-6M GPS and HC-05 modules are available at the Hall Road shop on request.

Still Stuck?

If the SMS does not arrive, or the GPS never gets a fix, message us - tell us what the Serial Monitor shows and which step you are on, and we will help you find the fault.

Chat on WhatsAppWatch on YouTube

FAQs

Can I use an Arduino Nano instead of the UNO?

Yes. The Nano is smaller and fits inside a helmet much better. The pins are the same (A4/A5, D3, D4/D5, D7/D8) and the code is identical.

Does the SMS really include the location?

Yes - when the GPS has a fix, the SMS contains a Google Maps link with the latitude and longitude. If there is no fix yet, the SMS says so honestly instead of sending a wrong location.

Why does the GPS take minutes the first time?

That is a cold start: the GPS module has to download satellite data first. It needs a clear view of the sky and can take 2-5 minutes. Later fixes are much faster.

Can the SIM800L run from the Arduino 5V pin?

No. It draws up to 2A in short bursts when sending an SMS. Use a separate 3.7V Li-ion cell or a buck converter that can give 2A, with a common ground to the Arduino.

Will it work without the HC-05 Bluetooth module?

Yes. The Bluetooth module is optional and the sketch does not use it. It is only useful if you want to add a mobile app later.

Is this a real safety device I can rely on in a crash?

No. This is a student demonstration model for learning and for final year project demos. It can miss a crash and it can send a false alarm. Always wear a proper certified helmet on the road.

Conclusion

Building a smart helmet with accident detection brings together motion sensing, vibration confirmation, GPS location and GSM alerts in one project. Follow the wiring above, put your real emergency number in the sketch, and test the SMS on the bench before the helmet goes anywhere near the road. With the code in this guide, students in Pakistan can build and demonstrate a working system and explain every part of it to their teachers and judges.