ESP32-Based Environmental Monitoring and Access Control System with RFID and Servo Actuation
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit is designed to interface various sensors and input devices with an ESP32 microcontroller for monitoring and control purposes. It includes environmental sensors (DHT22 for temperature and humidity, MQ-3 and MQ-5 for gas detection), a servo motor for actuation, RFID reader for identification, pushbuttons for user input, and an LCD display for output. The ESP32 serves as the central processing unit, running embedded code to interact with the connected devices, process sensor readings, and control the servo based on predefined conditions.
Component List
DHT22
- Description: A sensor for measuring temperature and humidity.
- Pins:
+,Out,-
MQ-3 Breakout
- Description: A gas sensor for detecting alcohol vapors.
- Pins:
VCC,GND,DO,AO
ESP32 - 38 pins Expansion Board
- Description: A microcontroller with WiFi and Bluetooth capabilities.
- Pins:
EN,SVP,SVN,P34,P35,P32,P33,P25,P26,P27,P14,P12,P13,SD2,SD3,CMD,5V,P23,P22,TX,RX,P19,P18,P5,P17,P16,P4,P0,P2,P15,SD1,SD0,CLK,VCC,G,D22,D21,3V,V,+,-
MQ-5
- Description: A gas sensor for detecting LPG, natural gas, and coal gas.
- Pins:
VCC,GND,Digi Out,Analog out
Servo
- Description: A motor capable of precise position control.
- Pins:
GND,VCC,PWM
Pushbutton
- Description: A momentary switch that can be used to trigger actions.
- Pins:
Pin 2,Pin 1,Pin 3,Pin 4
Resistor
- Description: A passive two-terminal electrical component that implements electrical resistance.
- Properties:
Resistance: 1000 Ohms
LCD I2C Display
- Description: A display module for showing text and numbers.
- Pins:
GND,VCC,SDA,SCL
RFID-RC522
- Description: An RFID reader/writer module.
- Pins:
VCC (3.3V),RST,GND,IRQ,MISO,MOSI,SCK,SDA
Wiring Details
DHT22
+to ESP32VCCOutto ESP32P4-to ESP32G
MQ-3 Breakout
VCCto ESP325VGNDto ESP32GAOto ESP32P14
MQ-5
VCCto ESP325VGNDto ESP32GAnalog outto ESP32P15
Servo
GNDto ESP32GVCCto ESP325VPWMto ESP32P13
Pushbuttons
Pin 2to ESP325VPin 1to ESP32P27,P26,P25(one button per pin)Pin 4to respective Resistorpin1
Resistor
pin1to PushbuttonPin 4pin2to ESP32G
LCD I2C Display
GNDto ESP32GVCCto ESP325VSDAto ESP32P23SCLto ESP32P22
RFID-RC522
VCC (3.3V)to ESP323VRSTto ESP32P16GNDto ESP32GMISOto ESP32P19MOSIto ESP32P23SCKto ESP32P18SDAto ESP32P5
Documented Code
The embedded code for the ESP32 microcontroller is written in C++ and is used to control the circuit's functionality. The code includes libraries for interfacing with the LCD, RFID, DHT sensor, and servo motor. It defines pin assignments, initializes devices, and contains the main loop that handles RFID card reading, button debouncing, and mode selection. The code also includes functions for handling RFID card detection, checking authorized UIDs, running modes based on the detected chemical, adjusting the servo position, and handling button presses.
// Code is omitted for brevity. Please refer to the provided code input for the full source.
The code is structured into functions to improve readability and maintainability. It uses conditional statements to make decisions and control the flow of the program based on sensor readings and user inputs. The servo's position is adjusted according to the current mode and chemical detected, demonstrating a simple control system that could be expanded for more complex applications.