This document provides a detailed overview of an Alcohol Detection and Location Sharing System. The system uses an MQ-3 alcohol sensor to detect alcohol levels, an LCD to display the readings, a buzzer to alert when the alcohol level exceeds a threshold, and a SIM800L module to send location messages using GPS data from a NEO 6M module.
Arduino UNO
SIM800L
GPS NEO 6M
LCD 16x2 (Wokwi Compatible)
MQ-3 Breakout
Potentiometer
Buzzer
LED: Two Pin (red)
/*
* Alcohol Detection and Location Sharing System
* This code reads the alcohol level from the MQ-3 sensor, displays it on the LCD,
* and if the level exceeds a threshold, it sounds a buzzer and sends a location
* message using the SIM800L module and GPS NEO 6M module.
*/
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
// Pin definitions
const int ledPin = 13;
const int buzzerPin = 8;
const int mq3Pin = A0;
const int sim800lRxPin = 1;
const int sim800lTxPin = 0;
const int gpsRxPin = 3;
const int gpsTxPin = 2;
// Threshold for alcohol level
const int alcoholThreshold = 300;
// LCD pins: RS, E, D4, D5, D6, D7
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Software serial for SIM800L
SoftwareSerial sim800l(sim800lTxPin, sim800lRxPin);
void setup() {
// Initialize serial communication
Serial.begin(9600);
sim800l.begin(9600);
// Initialize LCD
lcd.begin(16, 2);
lcd.print("Alcohol Level:");
// Initialize pins
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(mq3Pin, INPUT);
}
void loop() {
// Read alcohol level
int alcoholLevel = analogRead(mq3Pin);
// Display alcohol level on LCD
lcd.setCursor(0, 1);
lcd.print(alcoholLevel);
// Check if alcohol level exceeds threshold
if (alcoholLevel > alcoholThreshold) {
// Sound the buzzer
digitalWrite(buzzerPin, HIGH);
// Send location message
sendLocationMessage();
} else {
digitalWrite(buzzerPin, LOW);
}
delay(1000);
}
void sendLocationMessage() {
// Get GPS data
String gpsData = getGPSData();
// Send SMS with location
sim800l.print("AT+CMGF=1\r");
delay(100);
sim800l.print("AT+CMGS=\"+1234567890\"\r");
delay(100);
sim800l.print("Alcohol level exceeded! Location: ");
sim800l.print(gpsData);
sim800l.print((char)26);
delay(100);
}
String getGPSData() {
// Dummy GPS data for now
return "Lat: 0.0000, Lon: 0.0000";
}
This code initializes the necessary components and continuously reads the alcohol level from the MQ-3 sensor. If the alcohol level exceeds a predefined threshold, it sounds a buzzer and sends a location message using the SIM800L module. The location data is currently a placeholder and should be replaced with actual GPS data from the NEO 6M module.