This document provides a detailed overview of a circuit designed to detect alcohol levels and send GPS coordinates via SMS when a threshold is exceeded. The circuit includes an Arduino UNO, an alcohol sensor (MQ-3), a SIM800L GSM module, a Neo 6M GPS module, an LCD display, a buzzer, an LED, a rocker switch, and a 3.7V battery. The Arduino UNO reads the alcohol sensor data, displays it on the LCD, and if the alcohol level exceeds a predefined threshold, it sends an SMS with the GPS coordinates and activates a buzzer and LED.
Buzzer
LED: Two Pin (red)
MQ-3 Breakout
3.7V Battery
Rocker Switch (SPST)
SIM800L
Neo 6M GPS Module
LCD 16x2 (Wokwi Compatible)
5k Preset
Arduino UNO
#include <SoftwareSerial.h>
SoftwareSerial sim(8, 9);
#include <TinyGPS++.h>
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
float lattitude, longitude;
SoftwareSerial gpsSerial(0, 1); // rx, tx
TinyGPSPlus gps; // create gps object
int value; // variable to hold the value of alcohol
#define motor 10
#define buzzer 13
#define led 7
String number = "+919889342918"; // -> change with your number
int a;
void setup()
{
pinMode(motor, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
a = 700;
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Subscribe");
lcd.setCursor(0, 1);
lcd.print(" AEROTECH INDIA");
sim.begin(9600);
gpsSerial.begin(9600); // connect gps sensor
delay(6000);
lcd.clear();
}
void loop()
{
value = analogRead(A0); // reading value from Arduino analog pin which is receiving value from sensor pin
lcd.setCursor(0, 0); // setting cursor on LCD's 0th row and 0th column
lcd.print("value of alcohol"); // writing string on LCD
lcd.setCursor(0, 1); // setting cursor on 0th column of 1st row
lcd.print(value); // printing value on LCD
delay(100); // waiting for 100 milliseconds
digitalWrite(motor, HIGH);
digitalWrite(buzzer, LOW);
digitalWrite(led, LOW);
if (value > a)
{
SendMessage();
}
}
void SendMessage()
{
digitalWrite(motor, LOW);
digitalWrite(buzzer, HIGH);
boolean newData = false;
for (unsigned long start = millis(); millis() - start < 2000;)
{
while (gpsSerial.available() > 0)
{
if (gps.encode(gpsSerial.read()))
{
newData = true;
}
}
}
if (newData)
{
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
newData = false;
delay(300);
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); // ASCII code for ctrl-26
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);
while (1)
{
digitalWrite(led, HIGH