Arduino-Based Alcohol Detection and Location Sharing System with SIM800L and GPS NEO 6M
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
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.
Component List
Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
SIM800L
- Description: GSM/GPRS module for communication.
- Pins: NFT, RING, VCC, DTR, RST, MIC +, RXD, MIC-, TXD, SPK+, GND, SPK-
GPS NEO 6M
- Description: GPS module for location tracking.
- Pins: VCC, RX, TX, GND
LCD 16x2 (Wokwi Compatible)
- Description: 16x2 character LCD display.
- Pins: VSS, VDD, V0, RS, RW, E, D0, D1, D2, D3, D4, D5, D6, D7, A, K
MQ-3 Breakout
- Description: Alcohol sensor module.
- Pins: VCC, GND, DO, AO
Potentiometer
- Description: Variable resistor for adjusting LCD contrast.
- Pins: GND, Output, VCC
Buzzer
- Description: Sound alert device.
- Pins: PIN, GND
LED: Two Pin (red)
- Description: Indicator LED.
- Pins: cathode, anode
Wiring Details
Arduino UNO
- 3.3V: Connected to VCC of GPS NEO 6M
- 5V: Connected to VCC of SIM800L, VCC of Potentiometer, VCC of MQ-3 Breakout, VDD and A of LCD 16x2
- GND: Connected to GND of GPS NEO 6M, cathode of LED, GND of SIM800L, GND of MQ-3 Breakout, VSS, K, and RW of LCD 16x2, GND of Potentiometer, and GND of Buzzer
- A0: Connected to AO of MQ-3 Breakout
- D13: Connected to anode of LED
- D12: Connected to RS of LCD 16x2
- D11: Connected to E of LCD 16x2
- D8: Connected to PIN of Buzzer
- D7: Connected to RST of SIM800L
- D5: Connected to D4 of LCD 16x2
- D4: Connected to DO of MQ-3 Breakout and D5 of LCD 16x2
- D3: Connected to RX of GPS NEO 6M and D6 of LCD 16x2
- D2: Connected to TX of GPS NEO 6M and D7 of LCD 16x2
- D1: Connected to RXD of SIM800L
- D0: Connected to TXD of SIM800L
SIM800L
- VCC: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- RST: Connected to D7 of Arduino UNO
- RXD: Connected to D1 of Arduino UNO
- TXD: Connected to D0 of Arduino UNO
GPS NEO 6M
- VCC: Connected to 3.3V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- RX: Connected to D3 of Arduino UNO
- TX: Connected to D2 of Arduino UNO
LCD 16x2 (Wokwi Compatible)
- VSS: Connected to GND of Arduino UNO
- VDD: Connected to 5V of Arduino UNO
- V0: Connected to Output of Potentiometer
- RS: Connected to D12 of Arduino UNO
- RW: Connected to GND of Arduino UNO
- E: Connected to D11 of Arduino UNO
- D4: Connected to D5 of Arduino UNO
- D5: Connected to D4 of Arduino UNO
- D6: Connected to D3 of Arduino UNO
- D7: Connected to D2 of Arduino UNO
- A: Connected to 5V of Arduino UNO
- K: Connected to GND of Arduino UNO
MQ-3 Breakout
- VCC: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- DO: Connected to D4 of Arduino UNO
- AO: Connected to A0 of Arduino UNO
Potentiometer
- GND: Connected to GND of Arduino UNO
- Output: Connected to V0 of LCD 16x2
- VCC: Connected to 5V of Arduino UNO
Buzzer
- PIN: Connected to D8 of Arduino UNO
- GND: Connected to GND of Arduino UNO
LED: Two Pin (red)
- cathode: Connected to GND of Arduino UNO
- anode: Connected to D13 of Arduino UNO
Code Documentation
/*
* 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.