ESP32 C3 Super Mini - MQ3 Alcohol Sensor

TITLE: ESP32 C3 Super Mini - MQ3 Alcohol Sensor

This tutorial shows you how to use the ESP32 C3 Super Mini with an MQ3 alcohol sensor to detect ethanol and alcohol vapor in the air. Perfect for building DIY breathalyzer projects and alcohol detection systems!

In this tutorial, you will learn:

  • What the MQ3 alcohol sensor is and how it detects alcohol vapor
  • How to wire the MQ3 sensor module to ESP32 C3 Super Mini
  • How to program ESP32 C3 Super Mini to read alcohol concentration data
  • How to calibrate the sensor for accurate breathalyzer readings
  • How to build threshold-based alcohol detection systems
ESP32 C3 Super Mini with MQ3 alcohol gas sensor module

Hardware Preparation

1×ESP32 C3 Super Mini
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×MQ3 Alcohol Sensor
1×Breadboard
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of MQ3 Alcohol Sensor

The MQ3 is a gas sensor that detects alcohol vapor and ethanol by measuring resistance changes in its sensing element.

  • Operating Voltage: 5V DC
  • Detection Range: 25-500 ppm (parts per million)
  • Load Resistance: 200 KΩ
  • Heater Resistance: 33Ω ± 5%
  • Heating Consumption: < 800mW
  • Sensing Resistance: 1 MΩ – 8 MΩ
  • Preheat Time: 24-48 hours for first use, 5-10 minutes for subsequent uses
  • Output Types: Both digital (DO) and analog (AO) outputs
  • Sensor Type: Metal Oxide Semiconductor (MOS) chemiresistor
  • Sensing Material: Tin Dioxide (SnO2) on ceramic substrate
  • Perfect for: DIY breathalyzers, alcohol vapor alarms, air quality monitors, drunk driving detectors

The MQ3 alcohol sensor module uses a heated metal oxide semiconductor to detect alcohol molecules in the air. When alcohol vapor contacts the sensor surface, it changes the electrical resistance, which the ESP32 C3 Super Mini can measure.

Pinout

The MQ3 alcohol sensor module has four pins for easy connection to your ESP32 C3 Super Mini:

  • VCC pin: Power supply pin - connect to 5V
  • GND pin: Ground pin - connect to GND (0V)
  • DO pin: Digital output pin - outputs HIGH or LOW based on threshold setting
  • AO pin: Analog output pin - outputs voltage proportional to alcohol concentration
MQ3 alcohol sensor module pinout diagram

The module also includes two LED indicators:

  • PWR-LED: Power indicator - lights up when module is powered
  • DO-LED: Detection indicator - lights up when alcohol is detected above threshold

How It Works

The MQ3 sensor detects alcohol through resistance changes in its Tin Dioxide (SnO2) semiconductor material:

Clean air operation:

  • Oxygen molecules stick to the SnO2 surface when heated
  • Trapped electrons create high electrical resistance
  • Sensor outputs low voltage on analog pin

Alcohol vapor detection:

  • Alcohol molecules react with surface oxygen
  • Releases trapped electrons back into the material
  • Electrical resistance drops significantly
  • Sensor outputs higher voltage on analog pin
  • More alcohol = lower resistance = higher voltage output

Digital Output (DO pin):

  • Use the onboard potentiometer to set detection threshold
  • DO pin goes LOW when alcohol exceeds threshold (LED turns ON)
  • DO pin stays HIGH when alcohol is below threshold (LED stays OFF)
  • Perfect for simple yes/no alcohol detection

Analog Output (AO pin):

  • Provides continuous voltage reading from 0-4095 (ESP32 ADC range)
  • Higher voltage = more alcohol vapor detected
  • Lower voltage = less alcohol vapor
  • Ideal for measuring actual concentration levels
  • Not affected by the potentiometer setting

Warm-up and Calibration

Pre-heating Requirements

The MQ3 alcohol sensor requires proper heating before accurate measurements:

  • First time use or after 30+ days storage: Heat continuously for 24-48 hours to stabilize sensor readings
  • Regular use: Warm up for 5-10 minutes before taking measurements
  • During warm-up: Initial readings may be higher than normal but will stabilize quickly
  • How to warm up: Simply connect VCC to 5V and GND to ground via USB power or external supply

Finding Your Threshold Values

Every MQ3 sensor is slightly different, so calibration is essential for breathalyzer projects:

  • Clean air baseline test:
    • Run sensor in fresh air without any alcohol present
    • Record the analog value (typically 100-150)
    • This is your "sober" baseline reading
  • Alcohol vapor test:
    • Hold isopropyl alcohol or hand sanitizer near (not touching) the sensor
    • Let vapor reach the sensor element
    • Record the higher readings (typically 400-900 depending on vapor concentration)
    • This establishes your "detection" range
  • Set detection zones:
    • Sober range: Below baseline + 20 (example: readings < 120)
    • Moderate range: Mid-level readings (example: 120-400)
    • High range: Above moderate threshold (example: > 400)
  • Important notes: Individual sensors vary, environmental conditions affect readings, always calibrate your specific sensor before real use

Setting the Digital Threshold

Adjust the onboard potentiometer to set when the DO pin triggers:

  • Expose sensor to alcohol vapor (use hand sanitizer or rubbing alcohol)
  • Turn potentiometer clockwise until DO-LED lights up
  • Slowly turn counterclockwise until LED just turns off
  • Digital threshold is now calibrated for your desired sensitivity level
  • Test by exposing to alcohol vapor again - LED should light reliably

Wiring Diagram

The MQ3 sensor module connects easily to the ESP32 C3 Super Mini using both digital and analog outputs.

  • Note: The MQ3 sensor requires 5V power for proper heating. Connect VCC to the 5V pin, not 3.3V.
The wiring diagram between ESP32 C3 Super Mini MQ3 alcohol sensor

This image is created using Fritzing. Click to enlarge image

MQ3 Alcohol SensorESP32 C3 Super Mini
VCC5V
GNDGND
DOD7
AOA5

ESP32 C3 Super Mini Code - Digital Output Reading

This code reads the digital output from the MQ3 sensor to detect alcohol presence:

  • Checks DO pin status every second
  • Prints detection status to Serial Monitor
  • Uses threshold set by onboard potentiometer
  • Simple yes/no alcohol detection
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-mq3-alcohol-sensor */ #define PIN_DO D7 // The Arduino Nano ESP32's pin connected to the DO pin of the MQ3 sensor void setup() { // Initialize serial communication Serial.begin(9600); // Initialize the Arduino Nano ESP32's pin as an input pinMode(PIN_DO, INPUT); // Warm-up message Serial.println("Warming up the MQ3 sensor"); delay(20000); // 20 seconds warm-up time for recently used sensor } void loop() { int gasState = digitalRead(PIN_DO); if (gasState == HIGH) { Serial.println("Alcohol is NOT detected"); } else { Serial.println("Alcohol is detected"); } delay(1000); }

Detailed Instructions

  • New to ESP32 C3 Super Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Open Arduino IDE: Launch the Arduino IDE on your computer
  • Copy the code: Copy the code above and paste it into Arduino IDE
  • Select your board: Choose ESP32 C3 Super Mini from Tools > Board menu
  • Select your port: Choose the correct COM port from Tools > Port menu
  • Upload the code: Click the Upload button to program your ESP32 C3 Super Mini
  • Open Serial Monitor: Click the Serial Monitor icon (top-right) or press Ctrl+Shift+M
  • Set baud rate: Select 9600 baud in the Serial Monitor dropdown
  • Test with alcohol: Bring hand sanitizer or rubbing alcohol near the MQ3 sensor
  • View results: Watch the detection status change in Serial Monitor
  • Adjust sensitivity: If LED stays always on or off, turn the potentiometer to adjust threshold
  • Pro Tip: Use a cotton ball soaked in isopropyl alcohol for consistent testing without touching the sensor.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Alcohol is NOT detected Alcohol is NOT detected Alcohol is NOT detected Alcohol is detected Alcohol is detected Alcohol is detected Alcohol is detected Alcohol is NOT detected Alcohol is NOT detected
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

ESP32 C3 Super Mini Code - Analog Output Reading

This code reads analog voltage values from the MQ3 sensor to measure alcohol concentration:

  • Reads analog value from AO pin every second
  • Shows raw ADC values (0-4095 range)
  • Higher values indicate more alcohol vapor
  • Displays readings in Serial Monitor
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-mq3-alcohol-sensor */ #define PIN_AO A5 // The Arduino Nano ESP32's pin connected to the AO pin of the MQ3 sensor void setup() { // Initialize serial communication Serial.begin(9600); // Set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); // Warm-up message Serial.println("Warming up the MQ3 sensor"); delay(20000); // 20 seconds warm-up time for recently used sensor } void loop() { int gasValue = analogRead(PIN_AO); Serial.print("MQ3 sensor AO value: "); Serial.println(gasValue); delay(1000); }

Detailed Instructions

  • New to ESP32 C3 Super Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Copy the code: Paste the code above into Arduino IDE
  • Upload to board: Click Upload button to program ESP32 C3 Super Mini
  • Open Serial Monitor: Set baud rate to 9600
  • Note baseline value: Observe the reading in clean air (typically 100-150)
  • Test with alcohol: Introduce hand sanitizer or rubbing alcohol vapor near sensor
  • Watch values increase: Readings will jump significantly when alcohol is detected
  • Record values: Note the range for calibration purposes
  • Pro Tip: Write down your clean air baseline and alcohol vapor readings to calculate accurate thresholds for breathalyzer projects.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
MQ3 sensor AO value: 120 MQ3 sensor AO value: 125 MQ3 sensor AO value: 128 MQ3 sensor AO value: 450 MQ3 sensor AO value: 620 MQ3 sensor AO value: 850 MQ3 sensor AO value: 920 MQ3 sensor AO value: 980 MQ3 sensor AO value: 950 MQ3 sensor AO value: 680 MQ3 sensor AO value: 420 MQ3 sensor AO value: 245 MQ3 sensor AO value: 135
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

ESP32 C3 Super Mini Code - Breathalyzer with Threshold Detection

This code creates a simple breathalyzer by interpreting analog readings with calibrated thresholds:

  • Reads analog alcohol concentration values
  • Compares readings against calibrated thresholds
  • Classifies sobriety levels (Sober, Drinking, Drunk)
  • Displays status and sensor value in Serial Monitor
  • Updates readings every second
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-mq3-alcohol-sensor */ #define PIN_AO A5 // The Arduino Nano ESP32's pin connected to the AO pin of the MQ3 sensor // Threshold values - REPLACE THESE with your calibrated values! // Run calibration first to find these values for your sensor #define SOBER_THRESHOLD 120 // Below this = sober #define DRUNK_THRESHOLD 400 // Above this = drunk, between = drinking but within limits void setup() { // Initialize serial communication Serial.begin(9600); // Set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); // Warm-up message Serial.println("MQ3 Alcohol Sensor - Breathalyzer"); Serial.println("Warming up sensor..."); delay(20000); // 20 second warm-up for recently used sensor Serial.println("Sensor ready!"); Serial.println(); } void loop() { int gasLevel = analogRead(PIN_AO); // Read the analog value from sensor // Print sensor value Serial.print("Sensor Value: "); Serial.print(gasLevel); Serial.print(" | Status: "); // Determine status based on thresholds if (gasLevel < SOBER_THRESHOLD) { Serial.println("Stone Cold Sober"); } else if (gasLevel >= SOBER_THRESHOLD && gasLevel < DRUNK_THRESHOLD) { Serial.println("Drinking but within limits"); } else { Serial.println("DRUNK"); } delay(1000); // Wait 1 second between readings }

Detailed Instructions

  • New to ESP32 C3 Super Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Calibrate first: Run the analog reading code to find your sensor's baseline and alcohol detection values
  • Update thresholds: Replace SOBER_THRESHOLD and DRUNK_THRESHOLD with your calibrated values
  • Example calibration: If your clean air reads 130 and alcohol vapor reads 500+, use SOBER_THRESHOLD = 150 and DRUNK_THRESHOLD = 400
  • Upload code: Click Upload button to program ESP32 C3 Super Mini
  • Open Serial Monitor: Set baud rate to 9600
  • Test system: Breathe normally near sensor first (should read "Stone Cold Sober")
  • Test with alcohol: Use hand sanitizer or isopropyl alcohol vapor to simulate alcohol breath
  • Observe status changes: Watch the system classify different concentration levels
  • Pro Tip: For more accurate readings, wait 30 seconds after each test to let the sensor return to baseline before testing again.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Sensor Value: 115 | Status: Stone Cold Sober Sensor Value: 118 | Status: Stone Cold Sober Sensor Value: 122 | Status: Stone Cold Sober Sensor Value: 350 | Status: Drinking but within limits Sensor Value: 420 | Status: Drinking but within limits Sensor Value: 480 | Status: DRUNK Sensor Value: 520 | Status: DRUNK Sensor Value: 495 | Status: DRUNK Sensor Value: 380 | Status: Drinking but within limits Sensor Value: 290 | Status: Drinking but within limits Sensor Value: 165 | Status: Stone Cold Sober Sensor Value: 125 | Status: Stone Cold Sober
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

Educational Use Only: This is strictly an educational project for learning about gas sensors and the ESP32 C3 Super Mini. Never use this device as a legal breathalyzer, for assessing driving safety, or for any official alcohol testing purposes.

※ NOTE THAT:

This tutorial uses the analogRead() function to read values from an ADC (Analog-to-Digital Converter) connected to a sensor or component. The ESP32 C3 Super Mini's ADC is suitable for projects that do not require high accuracy. However, for projects needing precise measurements, keep the following in mind:

  • The ESP32 C3 Super Mini's ADC is not perfectly accurate and might require calibration for correct results. Each ESP32 C3 Super Mini board can vary slightly, so calibration is necessary for each individual board.
  • Calibration can be challenging, especially for beginners, and might not always yield the exact results you want.

For projects requiring high precision, consider using an external ADC (e.g ADS1115) with the ESP32 C3 Super Mini or using another Arduino, such as the Arduino Uno R4 WiFi, which has a more reliable ADC. If you still want to calibrate the ESP32 C3 Super Mini's ADC, refer to the ESP32 ADC Calibration Driver.

Project Ideas and Applications

Here are some practical projects you can build using the ESP32 C3 Super Mini with MQ3 alcohol sensor:

  • DIY breathalyzer system: Build an educational breath analyzer to demonstrate alcohol detection principles
  • Alcohol vapor alarm: Create a warning system that triggers when alcohol vapors exceed safe levels
  • Bar or brewery monitoring: Monitor alcohol vapor concentrations in fermentation or brewing areas
  • Home safety detector: Alert when alcohol-based cleaning products reach unsafe vapor levels
  • Laboratory gas monitor: Track ethanol vapor in chemistry labs or research facilities
  • Vehicle safety system: Prototype an alcohol interlock concept for educational demonstrations
  • Air quality station: Include alcohol detection as part of a multi-sensor air quality monitor

Video Tutorial

Watch the video below for a visual walkthrough of this project with the ESP32 C3 Super Mini and MQ3 alcohol sensor.

Challenge Yourself

Ready to take your ESP32 C3 Super Mini alcohol sensor project further? Try these challenges:

  • Easy: Add an LED that lights up when alcohol is detected above your sober threshold
  • Easy: Add a buzzer that beeps when the sensor detects high alcohol concentrations
  • Medium: Create a traffic light system (Green/Yellow/Red LEDs) showing sober, moderate, and drunk levels
  • Medium: Log sensor readings to an SD card with timestamps for data analysis
  • Advanced: Add WiFi connectivity to send alcohol detection alerts to your smartphone via Blynk or MQTT
  • Advanced: Build a complete breathalyzer with OLED display showing real-time readings and status messages

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!