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

Arduino UNO Based Alcohol Detection System with GPS Tracking and SMS Alerts

Image of Arduino UNO Based Alcohol Detection System with GPS Tracking and SMS Alerts

Circuit Documentation

Summary

This circuit is designed to monitor alcohol levels using an MQ-3 sensor and provide a visual indication via an LCD display and an LED. If the alcohol level exceeds a certain threshold, the system sends a GPS location via SMS using the SIM800L module, activates a buzzer, and locks the engine by disabling a motor. The system is powered by a 3.7V battery and controlled by an Arduino UNO microcontroller. A rocker switch is used to control the power supply to the SIM800L module.

Component List

  • Arduino UNO: A microcontroller board based on the ATmega328P. It has digital input/output pins, analog inputs, and various power outputs.
  • Buzzer: An electromechanical component that emits sound when energized.
  • LED (Red): A two-pin light-emitting diode that emits red light.
  • MQ-3 Alcohol Sensor (Breakout): A gas sensor used for detecting alcohol levels in the breath.
  • 3.7V Battery: A power source for the circuit.
  • Rocker Switch (SPST): A single-pole single-throw switch used to control the power flow in the circuit.
  • SIM800L Module: A GSM/GPRS module used for mobile communication, including sending SMS.
  • Neo 6M GPS Module: A module used for obtaining geographical location data.
  • Motor and Wheels (x2): Components that provide motion to the system.
  • LCD 16x2 (Wokwi Compatible): A liquid crystal display used for showing information.
  • 5k Preset (Potentiometer): A variable resistor used to adjust LCD contrast.
  • L293D Motor Driver: A motor driver IC used to control the direction and speed of motors.

Wiring Details

Arduino UNO

  • Digital Pin 13 connected to Buzzer
  • Digital Pin 7 connected to LED (Red) anode
  • Digital Pin 5, 4, 3, 2 connected to LCD D4, D5, D6, D7 respectively
  • Digital Pin 10 connected to L293D motor driver inputs
  • Analog Pin A0 connected to MQ-3 Alcohol Sensor AO
  • Digital Pin 9 connected to SIM800L RXD
  • Digital Pin 8 connected to SIM800L TXD
  • Digital Pin 0 connected to Neo 6M GPS Module TX
  • Digital Pin 1 connected to Neo 6M GPS Module RX
  • 5V and GND pins providing power and ground to various components

Buzzer

  • PIN connected to Arduino UNO Digital Pin 13
  • GND connected to common ground

LED (Red)

  • Cathode connected to common ground
  • Anode connected to Arduino UNO Digital Pin 7

MQ-3 Alcohol Sensor (Breakout)

  • VCC connected to 5V power supply
  • GND connected to common ground
  • AO connected to Arduino UNO Analog Pin A0

3.7V Battery

  • Positive terminal connected to Rocker Switch (SPST) Pin 1
  • Negative terminal connected to common ground

Rocker Switch (SPST)

  • Pin 1 connected to 3.7V Battery positive terminal
  • Pin 2 connected to SIM800L VCC

SIM800L Module

  • VCC connected to Rocker Switch (SPST) Pin 2
  • GND connected to common ground
  • RXD connected to Arduino UNO Digital Pin 9
  • TXD connected to Arduino UNO Digital Pin 8

Neo 6M GPS Module

  • GND connected to common ground
  • TX connected to Arduino UNO Digital Pin 0
  • RX connected to Arduino UNO Digital Pin 1
  • VCC connected to 5V power supply

Motor and Wheels

  • VCC of both motors connected to L293D motor driver +v1 and +v2
  • GND of both motors connected to L293D motor driver -v1 and -v2

LCD 16x2 (Wokwi Compatible)

  • VSS, RW, K connected to common ground
  • VDD, A connected to 5V power supply
  • V0 connected to 5k Preset variable end
  • RS connected to Arduino UNO Digital Pin 12
  • E connected to Arduino UNO Digital Pin 11
  • D4, D5, D6, D7 connected to Arduino UNO Digital Pins 5, 4, 3, 2 respectively

5k Preset (Potentiometer)

  • Fixed end 1 connected to 5V power supply
  • Fixed end 2 connected to common ground
  • Variable end connected to LCD V0

L293D Motor Driver

  • GND connected to common ground
  • 9/12 volts connected to 5V power supply
  • 5volts connected to 5V power supply
  • Motor input 1 and Motor input 2 connected to Arduino UNO Digital Pin 10
  • +v1, -v1 connected to one Motor and Wheels pair
  • +v2, -v2 connected to the other Motor and Wheels pair

Documented Code

#include <SoftwareSerial.h>
SoftwareSerial sim(8, 9); // RX, TX for SIM800L
#include <TinyGPS++.h> // GPS library
#include <LiquidCrystal.h> // LCD library

// 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 for GPS
TinyGPSPlus gps; // GPS object

// Alcohol sensor reading
int value;

// Motor, buzzer, and LED pins
#define motor 10
#define buzzer 13
#define led 7

// Phone number for SMS
String number = "+919889342918";

void setup() {
  pinMode(motor, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(led, OUTPUT);
  int threshold = 700; // Alcohol threshold value
  Serial.begin(9600); // Start serial communication
  lcd.begin(16, 2); // Initialize LCD
  lcd.setCursor(0, 0);
  lcd.print("    Subscribe");
  lcd.setCursor(0, 1);
  lcd.print(" AEROTECH INDIA");
  sim.begin(9600); // Start SIM800L communication
  gpsSerial.begin(9600); // Start GPS communication
  delay(6000); // Wait for initialization
  lcd.clear();
}

void loop() {
  value = analogRead(A0); // Read alcohol sensor value
  lcd.setCursor(0, 0);
  lcd.print("value of alcohol");
  lcd.setCursor(0, 1);
  lcd.print(value);
  delay(100);
  digitalWrite(motor, HIGH); // Activate motor
  digitalWrite(buzzer, LOW); // Deactivate buzzer
  digitalWrite(led, LOW); // Deactivate LED

  if (value > threshold) {
    SendMessage(); // Send message if over threshold
  }
}

void SendMessage() {
  digitalWrite(motor, LOW); // Lock engine
  digitalWrite(buzzer, HIGH); // Activate buzzer

  boolean newData = false;
  for (unsigned long start = millis(); millis() - start < 2000;) {
    while (gpsSerial.available() > 0) {
      if (gps.encode(gpsSerial.read())) {
        newData = true; // New GPS data received
      }
    }
  }

  if (newData) {
    // Send SMS with GPS location
    sim.println("AT+CMGF=1");
    delay(200);
    sim.println("AT+CMGS=\"" + number + "\"\r");
    delay(200);
    sim.print("http://maps.google.com/maps?q=loc:");
    sim.print(gps.location.lat(), 6);
    sim.print(",");
    sim.print(gps.location.lng(), 6);
    delay(100);
    sim.println((char)26); // End SMS
    delay(200);
    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(200);
    digitalWrite(buzzer, LOW);

    // Flash LED and buzzer in a loop
    while (1) {
      digitalWrite(led, HIGH);
      delay(500);
      digitalWrite(led, LOW);
      digitalWrite(buzzer, HIGH);
      delay(500);
      digitalWrite(buzzer, LOW);

      lcd.setCursor(0, 0);
      lcd.print("  High Alcohol  ");
      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 is above the threshold, it sends the current GPS location via SMS and enters a loop that indicates a locked engine state.