Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based Alcohol Detection and Vehicle Control System with GPS and GSM

Image of Arduino UNO Based Alcohol Detection and Vehicle Control System with GPS and GSM

Circuit Documentation

Summary

This circuit is designed to incorporate a variety of components including an Arduino UNO, sensors like the MQ-3 alcohol sensor and MPU-6050 accelerometer/gyroscope, a GPS module (GPS NEO 6M), a GSM module (Sim800l), a motor driver (L298N), and actuators such as a DC motor, buzzer, and LED. The circuit is powered by a Polymer Lithium Ion Battery and a 12v Battery. The Arduino UNO serves as the central microcontroller unit, interfacing with the sensors, GPS, GSM, and motor driver to perform tasks such as alcohol detection, location tracking, and motor control. The embedded code handles data acquisition, processing, and communication tasks.

Component List

  • Arduino UNO: A microcontroller board based on the ATmega328P, with digital and analog I/O pins.
  • MQ-3 Breakout: An alcohol gas sensor module capable of detecting alcohol concentration in the air.
  • MPU-6050: A motion-tracking device with a 3-axis gyroscope and a 3-axis accelerometer.
  • Sim800l: A GSM/GPRS module for cellular communication.
  • Polymer Lithium Ion Battery - 850mAh: A rechargeable battery providing power to the circuit.
  • Resistor: A passive two-terminal electrical component used to limit current or divide voltages.
  • GPS NEO 6M: A GPS module for receiving location data from satellites.
  • L298N DC motor driver: A module for controlling DC motors with direction and speed control.
  • 12v Battery: A power source for the motor driver and connected motors.
  • DC Motor: An electric motor that runs on direct current electricity.
  • Buzzer: An audio signaling device.
  • LED (yellow): A yellow light-emitting diode used as an indicator.
  • Electrolytic Capacitor: A capacitor used for filtering or noise reduction in power supplies.

Wiring Details

Arduino UNO

  • 5V: Connected to VCC of MPU-6050, GPS NEO 6M, and MQ-3 Breakout.
  • GND: Common ground with MPU-6050, GPS NEO 6M, MQ-3 Breakout, Sim800l, buzzer, and the negative side of the Electrolytic Capacitor.
  • A0: Connected to AO of MQ-3 Breakout.
  • A4 (SDA): Connected to SDA of MPU-6050.
  • A5 (SCL): Connected to SCL of MPU-6050.
  • D3: Connected to RX of GPS NEO 6M.
  • D4: Connected to TX of GPS NEO 6M.
  • D7: Connected to TXD of Sim800l.
  • D8: Connected to one end of a Resistor, which is connected to the PIN of the buzzer.
  • D9: Connected to the anode of the LED.
  • D10: Connected to IN1 of L298N DC motor driver.
  • D11: Connected to IN2 of L298N DC motor driver.
  • D12: Connected to ENA of L298N DC motor driver.

MQ-3 Breakout

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Common ground with Arduino UNO.
  • AO: Connected to A0 of Arduino UNO.

MPU-6050

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Common ground with Arduino UNO.
  • SDA: Connected to A4 (SDA) of Arduino UNO.
  • SCL: Connected to A5 (SCL) of Arduino UNO.

Sim800l

  • VCC: Connected to VCC of Polymer Lithium Ion Battery and the positive side of the Electrolytic Capacitor.
  • GND: Common ground with Arduino UNO, Resistor, and the negative side of the Electrolytic Capacitor.
  • TXD: Connected to D7 of Arduino UNO.
  • RXD: Connected to one end of a Resistor.

Polymer Lithium Ion Battery - 850mAh

  • VCC: Connected to VCC of Sim800l and the positive side of the Electrolytic Capacitor.
  • GND: Connected to one end of a Resistor.

Resistor

  • Various resistors are used for current limiting and voltage division in the circuit.

GPS NEO 6M

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Common ground with Arduino UNO.
  • RX: Connected to D3 of Arduino UNO.
  • TX: Connected to D4 of Arduino UNO.

L298N DC motor driver

  • GND: Common ground with Arduino UNO and the negative side of the 12v Battery.
  • 5V: Connected to the positive side of the 12v Battery.
  • ENA: Connected to D12 of Arduino UNO.
  • IN1: Connected to D10 of Arduino UNO.
  • IN2: Connected to D11 of Arduino UNO.
  • OUT1/OUT2: Connected to the DC Motor.

12v Battery

  • +: Connected to 5V of L298N DC motor driver.
  • -: Common ground with Arduino UNO and L298N DC motor driver.

DC Motor

  • Pin 1: Connected to OUT2 of L298N DC motor driver.
  • Pin 2: Connected to OUT1 of L298N DC motor driver.

Buzzer

  • PIN: Connected to one end of a Resistor, which is connected to D8 of Arduino UNO.
  • GND: Common ground with Arduino UNO.

LED (yellow)

  • Anode: Connected to D9 of Arduino UNO.
  • Cathode: Connected to one end of a Resistor.

Electrolytic Capacitor

  • +: Connected to VCC of Polymer Lithium Ion Battery.
  • -: Common ground with Sim800l.

Documented Code

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <MPU6050.h>

TinyGPSPlus gps;      // GPS object
MPU6050 mpu;          // MPU6050 object
SoftwareSerial gpsSerial(4, 3);    // RX, TX for GPS
SoftwareSerial gsmSerial(7, 8);    // RX, TX for GSM

const int alcoholPin = A0;        // Alcohol sensor pin
const int buzzerPin = 8;          // Buzzer pin
const int ledPin = 9;             // LED pin
const int in1 = 10;               // Motor driver IN1
const int in2 = 11;               // Motor driver IN2
const int enA = 12;               // Motor driver ENA

void setup() {
  Serial.begin(9600);             // Initialize serial communication
  gpsSerial.begin(9600);          // GPS module
  gsmSerial.begin(9600);          // GSM module

  pinMode(alcoholPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(enA, OUTPUT);
  
  digitalWrite(enA, HIGH);        // Enable motor
  
  // MPU6050 Initialization
  Wire.begin();
  mpu.initialize();
  
  // GSM Initialization
  sendSMS("System initialized and ready.");
}

void loop() {
  // Alcohol detection
  int alcoholValue = analogRead(alcoholPin);
  
  // Alcohol detection threshold (adjust as needed)
  if (alcoholValue > 400) {
    Serial.println("Alcohol detected!");
    stopMotor();
    alertDriver();
    sendLocation();  // Send GPS location via SMS
  }
  
  // GPS Data
  while (gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
    if (gps.location.isValid()) {
      Serial.print("Latitude: "); Serial.println(gps.location.lat(), 6);
      Serial.print("Longitude: "); Serial.println(gps.location.lng(), 6);
    }
  }
  
  delay(1000);
}

void stopMotor() {
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
}

void alertDriver() {
  digitalWrite(buzzerPin, HIGH);
  digitalWrite(ledPin, HIGH);
  delay(2000);    // Sound the alarm for 2 seconds
  digitalWrite(buzzerPin, LOW);
  digitalWrite(ledPin, LOW);
}

void sendLocation() {
  if (gps.location.isValid()) {
    String message = "Emergency! Alcohol detected. Location: ";
    message += "Lat: " + String(gps.location.lat(), 6);
    message += ", Lon: " + String(gps.location.lng(), 6);
    sendSMS(message);
  } else {
    sendSMS("GPS signal not available.");
  }
}

void sendSMS(String text) {
  gsmSerial.print("AT+CMGF=1\r");            // Set SMS mode
  delay(1000);
  gsmSerial.print("AT+CMGS=\"+1234567890\"\r");  // Replace with recipient's number
  delay(1000);
  gsmSerial.print(text);    // Message body
  delay(1000);
  gsmSerial.write(26);      // Send Ctrl+Z to indicate end of message
  delay(1000);
}

This code is designed to run on the Arduino UNO