ESP8266-Based Smart Alcohol Detection System with RFID and LCD Display
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit integrates an ESP8266 NodeMCU microcontroller with an MQ-3 alcohol sensor, an RFID-RC522 module, a buzzer, and a 16x2 I2C LCD display. The ESP8266 NodeMCU reads data from the alcohol sensor and the RFID module, displays information on the LCD, and activates the buzzer based on the alcohol level detected.
Component List
ESP8266 NodeMCU
- Description: A low-cost Wi-Fi microcontroller with GPIO, ADC, and other features.
- Pins: D0, D1, D2, D3, D4, 3V3, GND, D5, D6, D7, D8, RX, TX, A0, RSV, SD3, SD2, SD1, CMD, SD0, CLK, EN, RST, VIN
MQ-3 Breakout
- Description: An alcohol sensor module used to detect alcohol levels in the air.
- Pins: VCC, GND, DO, AO
RFID-RC522
- Description: An RFID reader module used for reading RFID tags.
- Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA
Buzzer
- Description: A simple buzzer used for audio alerts.
- Pins: PIN, GND
16x2 I2C LCD
- Description: A 16x2 character LCD display with I2C interface.
- Pins: GND, VCC, SDA, SCL
Wiring Details
ESP8266 NodeMCU
- D0: Connected to MQ-3 Breakout VCC
- D1: Connected to 16x2 I2C LCD SDA
- D2: Connected to 16x2 I2C LCD SCL
- D3: Connected to RFID-RC522 RST
- D4: Connected to RFID-RC522 SDA
- 3V3: Connected to MQ-3 Breakout DO
- GND: Connected to MQ-3 Breakout GND, RFID-RC522 GND, Buzzer GND, 16x2 I2C LCD GND
- D5: Connected to RFID-RC522 SCK
- D6: Connected to RFID-RC522 MISO
- D7: Connected to RFID-RC522 MOSI
- D8: Connected to Buzzer PIN
- VIN: Connected to 16x2 I2C LCD VCC
MQ-3 Breakout
- VCC: Connected to ESP8266 NodeMCU D0
- GND: Connected to ESP8266 NodeMCU GND
- DO: Connected to ESP8266 NodeMCU 3V3
- AO: Not connected
RFID-RC522
- VCC (3.3V): Connected to ESP8266 NodeMCU 3V3
- RST: Connected to ESP8266 NodeMCU D3
- GND: Connected to ESP8266 NodeMCU GND
- IRQ: Not connected
- MISO: Connected to ESP8266 NodeMCU D6
- MOSI: Connected to ESP8266 NodeMCU D7
- SCK: Connected to ESP8266 NodeMCU D5
- SDA: Connected to ESP8266 NodeMCU D4
Buzzer
- PIN: Connected to ESP8266 NodeMCU D8
- GND: Connected to ESP8266 NodeMCU GND
16x2 I2C LCD
- GND: Connected to ESP8266 NodeMCU GND
- VCC: Connected to ESP8266 NodeMCU VIN
- SDA: Connected to ESP8266 NodeMCU D1
- SCL: Connected to ESP8266 NodeMCU D2
Code Documentation
ESP8266 NodeMCU Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN D3
#define SS_PIN D4
#define ALCOHOL_SENSOR_PIN D0
#define BUZZER_PIN D8
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 rfid(SS_PIN, RST_PIN);
void setup() {
lcd.begin();
lcd.backlight();
SPI.begin();
rfid.PCD_Init();
pinMode(ALCOHOL_SENSOR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(BUZZER_PIN, LOW);
}
void loop() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
return;
}
int alcoholLevel = analogRead(ALCOHOL_SENSOR_PIN);
lcd.clear();
if (alcoholLevel > 512) { // Adjust threshold as needed
lcd.setCursor(0, 0);
lcd.print("Closed");
digitalWrite(BUZZER_PIN, HIGH);
} else {
lcd.setCursor(0, 0);
lcd.print("Open");
digitalWrite(BUZZER_PIN, LOW);
}
delay(2000); // Wait for 2 seconds before next read
rfid.PICC_HaltA();
}
16x2 I2C LCD Code
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
This documentation provides a comprehensive overview of the circuit, including the components used, their wiring details, and the code running on the microcontrollers.