πSensor & Circuit (ESP32 + MQ3 )
π― Objective of This Lesson
In this lesson, students will learn:
-
How to connect MQ3 gas sensor to ESP32
-
How to use Analog Output (AO)
-
How ESP32 reads gas concentration
-
Basic hardware setup and safety precautions
This is the foundation before writing code.
π§ͺ Components Required
-
ESP32 Development Board
-
MQ3 Gas Sensor Module
-
Breadboard
-
Jumper wires
-
USB cable
No buzzer.
No LED.
Only sensor and microcontroller.
π§ About MQ3 Sensor (Quick Revision)
MQ3 is mainly used to detect:
-
Alcohol vapor
-
Ethanol gas
-
Smoke (moderate sensitivity)
It provides:
-
Analog output (continuous value)
-
Digital output (HIGH/LOW threshold)
For this project, we will use:
π Analog Output (AO)
Because ESP32 has built-in ADC (Analog to Digital Converter).
π MQ3 Pin Description
Most MQ3 modules have 4 pins:
| Pin | Function |
|---|---|
| VCC | 5V power |
| GND | Ground |
| AO | Analog Output |
| DO | Digital Output |
In this lesson, we use only:
-
VCC
-
GND
-
AO
π Circuit Connections (ESP32 + MQ3)
π Connection Table
| MQ3 Pin | ESP32 Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| AO | GPIO 34 |
π§ Why GPIO 34?
-
GPIO 34 is input-only
-
Supports analog reading
-
Perfect for sensor input
-
ADC range: 0 β 4095
β‘ Power Considerations
Important points for students:
1οΈβ£ MQ3 must be powered with 5V
2οΈβ£ ESP32 analog pins work at 3.3V logic
3οΈβ£ MQ3 module AO output is safe for ESP32
4οΈβ£ Do NOT connect MQ3 VCC to 3.3V
π¬ How the Circuit Works
1οΈβ£ MQ3 sensor heats its internal element
2οΈβ£ Gas interacts with sensing material
3οΈβ£ Sensor resistance changes
4οΈβ£ Output voltage changes
5οΈβ£ ESP32 reads analog value from GPIO 34
6οΈβ£ Higher gas concentration β Higher ADC value
So internally:
Gas β β Voltage β β ADC value β
π What ESP32 Will Read
ESP32 ADC gives values between:
0 to 4095
Example readings:
| Condition | Approx ADC Value |
|---|---|
| Clean Air | 200β400 |
| Mild Gas | 800β1200 |
| High Gas | 2000+ |
(Values may vary depending on environment.)
β³ Warm-Up Requirement
Before taking readings:
-
Wait 30β60 seconds after power ON
-
Sensor needs heating time
-
For best stability β 24-hour initial burn-in
Explain this clearly to students.
β Safety Instructions
When testing:
-
Use small alcohol vapor
-
Do not pour liquid directly on sensor
-
Keep room ventilated
-
Avoid high flame near sensor
π Learning Outcomes
After completing this lesson, students will understand:
-
Analog sensor interfacing
-
ESP32 ADC concept
-
Gas sensing basics
-
Hardware connection principles
-
Importance of power stability