Arduino UNO Based Drunk Driving Detection System with GPS Tracking and SMS Alert
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to monitor alcohol levels using an MQ-3 alcohol sensor and a GPS module for location tracking. It interfaces with an Arduino UNO microcontroller, which controls a buzzer, an LED, and a SIM800L GSM module to send SMS alerts. The circuit also includes a 16x2 LCD for displaying messages, a motor driver to control DC motors, and a 12V battery for power supply.
Component List
SIM800L GSM Module
- Description: A GSM/GPRS module for mobile communication.
- Pins: NFT, RING, VCC, DTR, RST, MIC+, RXD, MIC-, TXD, SPK+, GND, SPK-
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
Ground (GND)
- Description: Common ground for the circuit.
Vcc
- Description: Power supply for the circuit components.
L293D Motor Driver
- Description: A motor driver IC capable of driving two DC motors.
- Pins: B1, B2, A1, EN_B, EN_A, A2, GND, VCC, +, -, MPIN_1-4
DC Motor
- Description: An electric motor that runs on direct current (DC) electricity.
- Pins: pin 1, pin 2
12V Battery
- Description: A power source for the circuit.
- Pins: +, -
16X2 LCD
- Description: A liquid crystal display capable of displaying 16 characters per line in 2 lines.
- Pins: VSS, VDD, V0, RS, RW, E, D0-D7, A, K
Neo 6M GPS Module
- Description: A GPS receiver module for location tracking.
- Pins: GND, TX, RX, VCC
Buzzer
- Description: An audio signaling device.
- Pins: PIN, GND
LED: Two Pin (red)
- Description: A red light-emitting diode.
- Pins: cathode, anode
MQ-3 Alcohol Sensor
- Description: A sensor for detecting alcohol gas concentrations.
- Pins: VCC, GND, DO, AO
Wiring Details
SIM800L GSM Module
- RXD connected to Arduino UNO D9
- TXD connected to Arduino UNO D8
- GND connected to common ground
Arduino UNO
- 5V connected to MQ-3 VCC
- GND connected to 16X2 LCD RW
- A0 connected to MQ-3 AO
- D12 connected to 16X2 LCD RS
- D11 connected to 16X2 LCD E
- D10 connected to LED anode
- D9 connected to SIM800L RXD
- D8 connected to SIM800L TXD
- D6 connected to buzzer PIN
- D5 connected to 16X2 LCD D4
- D4 connected to 16X2 LCD D5
- D3 connected to 16X2 LCD D6
- D2 connected to 16X2 LCD D7
- D1 connected to Neo 6M GPS Module RX
- D0 connected to Neo 6M GPS Module TX
L293D Motor Driver
-
- connected to 12V Battery +
-
- connected to 12V Battery -
- MPIN_1 connected to DC Motor pin 2
- MPIN_2 connected to DC Motor pin 1
- MPIN_3 connected to DC Motor pin 1
- MPIN_4 connected to DC Motor pin 2
16X2 LCD
- RW connected to Arduino UNO GND
- RS connected to Arduino UNO D12
- E connected to Arduino UNO D11
- D4 connected to Arduino UNO D5
- D5 connected to Arduino UNO D4
- D6 connected to Arduino UNO D3
- D7 connected to Arduino UNO D2
- VSS connected to common ground
- VDD connected to Vcc
Neo 6M GPS Module
- RX connected to Arduino UNO D1
- TX connected to Arduino UNO D0
- GND connected to common ground
- VCC connected to Vcc
Buzzer
- PIN connected to Arduino UNO D6
- GND connected to common ground
LED: Two Pin (red)
- Anode connected to Arduino UNO D10
- Cathode connected to common ground
MQ-3 Alcohol Sensor
- VCC connected to Arduino UNO 5V
- GND connected to common ground
- AO connected to Arduino UNO A0
Documented Code
#include <SoftwareSerial.h>
SoftwareSerial sim(8,9); // SIM800L GSM Module communication
#include <TinyGPS++.h> // GPS Module
#include <LiquidCrystal.h> // LCD Display
// LCD pin assignments
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// GPS variables
float latitude, longitude;
SoftwareSerial gpsSerial(0,1); // RX, TX
TinyGPSPlus gps;
// Sensor reading
int val;
// Output pin assignments
#define motor 7
#define buzzer 6
#define led 10
// Phone number for SMS
String number = "+918421041408";
int threshold = 700;
void setup() {
pinMode(motor, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
Serial.begin(9600); // Start serial communication
lcd.begin(16,2); // Initialize LCD
lcd.setCursor(0,0);
lcd.print("Mini Project 1");
lcd.setCursor(0,1);
sim.begin(9600); // Start SIM800L communication
gpsSerial.begin(9600); // Start GPS communication
delay(6000);
lcd.clear();
}
void loop() {
val = analogRead(A0); // Read alcohol sensor value
lcd.setCursor(0,0);
lcd.print("Value of Alcohol");
lcd.setCursor(0,1);
lcd.print(val);
delay(100);
digitalWrite(motor, HIGH); // Turn on motor
digitalWrite(buzzer, LOW); // Turn off buzzer
digitalWrite(led, LOW); // Turn off LED
if(val > threshold) {
send_message(); // Send SMS if alcohol level is high
}
}
void send_message() {
digitalWrite(motor, LOW); // Turn off motor
digitalWrite(buzzer, HIGH); // Turn on buzzer
boolean newData = false;
// Attempt to get new GPS data
for(unsigned long start = millis(); millis() - start < 2000;) {
while(gpsSerial.available() > 0) {
if(gps.encode(gpsSerial.read())) {
newData = true;
}
}
}
// If new GPS data is available, send an SMS
if(newData) {
Serial.print("Latitude");
Serial.print(gps.location.lat(), 6);
Serial.print("Longitude");
Serial.print(gps.location.lng(), 6);
newData = false;
delay(300);
sim.println("AT+CMGF=1"); // Set SMS mode
delay(200);
sim.println("AT+CMGS=\"" + number + "\"\r");
delay(200);
sim.print("http://maps.google.com/maps?q=loc:");
sim.print("Latitude");
sim.print(gps.location.lat(), 6);
sim.print("Longitude");
sim.print(gps.location.lng(), 6);
delay(100);
sim.println((char)26); // Send SMS
Serial.println("GPS location SMS sent successfully");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Sending....");
lcd.setCursor(0,1);
lcd.print("Your Location");
delay(5000);
lcd.clear();
delay(100);
digitalWrite(buzzer, LOW);
// Indicate drunk driving and lock engine
while(1) {
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
lcd.setCursor(0,0);
lcd.print("Driver Drunked");
lcd.setCursor(0,1);
lcd.print("Engine Locked");
}
}
}
This code is responsible for reading the alcohol sensor data, displaying it on the LCD, and controlling the motor, buzzer, and LED based on the sensor's readings. If the alcohol level exceeds the threshold, it sends an SMS with the current GPS coordinates using the SIM800L module.