Arduino UNO R4 - MQ3 Alcohol Sensor

This guide will show you how to use Arduino UNO R4 and MQ3 alcohol sensor to detect alcohol vapor and ethanol in the air. This sensor is commonly used in breathalyzer projects and alcohol detection systems.

Arduino UNO R4 with MQ3 alcohol gas sensor module

Overview of MQ3 Alcohol Sensor

The MQ3 alcohol sensor is a MOS (Metal Oxide Semiconductor) sensor, also known as a Chemiresistor, because it detects alcohol based on the change in resistance of the sensing material when exposed to alcohol vapor. It is specifically designed to detect alcohol vapor (ethanol) in the air and is highly sensitive to alcohol concentrations.

The sensor uses a Tin Dioxide (SnO2) coating on an Aluminum Oxide ceramic substrate as its sensing element. When heated, the SnO2 becomes sensitive to alcohol. The sensor is covered with a stainless steel mesh (anti-explosion network) that protects the internal heating element and filters out suspended particles while allowing gaseous elements to reach the sensing chamber.

Common applications include breath analyzers, drunk driving detection systems, alcohol presence alarms, and projects that require monitoring alcohol concentration in the environment.

Technical Specifications

  • Operating Voltage: 5V DC
  • Load Resistance: 200 KΩ
  • Heater Resistance: 33Ω ± 5%
  • Heating Consumption: < 800mW
  • Sensing Resistance: 1 MΩ – 8 MΩ
  • Detection Range: 25 – 500 ppm (parts per million)
  • Preheat Time: 24-48 hours for first use

What does ppm mean? Parts-per-million (ppm) is the unit for measuring gas concentration. For example, 500 ppm of alcohol means that out of one million gas molecules, 500 are alcohol and 999,500 are other gases.

Pinout

The MQ3 alcohol sensor has four pins:

  • VCC pin: Connect this pin to VCC (5V).
  • GND pin: Connect this pin to GND (0V).
  • DO pin: This is a digital output pin. It shows LOW when alcohol is detected and HIGH if not. You can adjust the alcohol detection threshold using the onboard potentiometer.
  • AO pin: This is an analog output pin. It produces a voltage that changes depending on the alcohol concentration. Higher alcohol concentration makes the voltage go up.
MQ3 alcohol sensor module pinout diagram

It also has two LED lights:

  • One PWR-LED light shows power is on.
  • One DO-LED light shows alcohol detection status based on DO pin value: it lights up when alcohol is detected and turns off when there is none.

How It Works

The MQ3 sensor works based on changes in electrical resistance of the Tin Dioxide (SnO2) sensing element:

In clean air: When the SnO2 semiconductor is heated, oxygen molecules are adsorbed on the surface, creating an electron depletion layer. This forms a potential barrier that makes the material highly resistive, preventing current flow.

In the presence of alcohol: The alcohol vapor reacts with the adsorbed oxygen, reducing the surface oxygen density and lowering the potential barrier. This releases electrons into the tin dioxide, allowing current to flow freely. The more alcohol present, the lower the resistance.

The sensor provides two types of outputs:

For the DO pin (Digital Output):

  • The module includes a potentiometer to adjust the sensitivity threshold for alcohol detection.
  • If the alcohol concentration exceeds the set threshold, the sensor's output pin turns LOW and the DO-LED light turns on.
  • If the alcohol concentration is below the threshold, the sensor's output pin turns HIGH and the DO-LED light turns off.

For the AO pin (Analog Output):

  • The output voltage is proportional to the alcohol concentration.
  • Higher alcohol vapor concentration produces higher voltage.
  • Lower alcohol vapor concentration produces lower voltage.
  • The potentiometer does not affect the AO pin value.

The MQ3 Sensor Warm-up and Calibration

Warm-up Time

The MQ3 alcohol sensor must be heated before use to get accurate readings:

  • First-time use or after long storage (over a month): Warm it up for 24-48 hours to get stable and accurate results.
  • Recent use: It requires only 5-10 minutes to warm up. At first, the readings might be high, but they will stabilize after a short while.

To heat up the MQ3 sensor, connect its VCC and GND pins to a power source or to the VCC and GND on an Arduino UNO R4, and leave it connected for the warm-up period.

Calibration for Threshold Values

Because the MQ3 is a heater-driven sensor, calibration may drift if left in storage for an extended period. To calibrate the sensor and find threshold values for your breathalyzer project:

  1. Record baseline values: Run the sensor in clean air and record the analog readings (typically around 100-150).
  2. Test with alcohol: Use isopropyl alcohol or hand sanitizer (do not get liquid on the sensor - only vapors). Squeeze the bottle near the sensor to release vapors and record the readings (typically 400-900 depending on concentration).
  3. Set thresholds: Based on your readings, you can define threshold levels:
  • Sober: Below baseline + 20 (e.g., < 120)
  • Within legal limits: Between baseline and moderate level (e.g., 120-400)
  • Above legal limits: Above moderate level (e.g., > 400)

Note: These values vary depending on your specific sensor and environment. Always calibrate with your own sensor before use.

Adjusting Digital Output Threshold

To set the threshold for the DO pin using the onboard potentiometer:

  1. Expose the sensor to alcohol vapors.
  2. Turn the potentiometer clockwise until the Status LED turns on.
  3. Turn the potentiometer counterclockwise just until the LED turns off.
  4. Your threshold is now set.

Wiring Diagram

The MQ3 alcohol sensor module has two outputs. You can use one or both, depending on your needs.

MQ3 Alcohol SensorArduino UNO R4
VCC5V
GNDGND
DOPin 2
AOA0
The wiring diagram between Arduino UNO R4 and MQ3 alcohol sensor  showing pin connections

This image is created using Fritzing. Click to enlarge image

See The best way to supply power to the Arduino Uno R4 and other components.

Arduino UNO R4 Code - Read value from DO pin

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-mq3-alcohol-sensor */ #define DO_PIN 2 // The Arduino UNO R4 pin connected to DO pin of the MQ3 sensor void setup() { // initialize serial communication Serial.begin(9600); // initialize the Arduino's pin as an input pinMode(DO_PIN, INPUT); Serial.println("Warming up the MQ3 sensor"); delay(20000); // wait for the MQ3 to warm up } void loop() { int alcoholState = digitalRead(DO_PIN); if (alcoholState == HIGH) Serial.println("Alcohol is NOT detected"); else Serial.println("Alcohol is detected"); }

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
  • Connect the Arduino Uno R4 board to the MQ3 alcohol sensor according to the provided diagram.
  • Connect the Arduino Uno R4 board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
  • Copy the code above and open it in Arduino IDE.
  • Click the Upload button in Arduino IDE to upload the code to Arduino UNO R4.
  • Expose the MQ3 sensor to alcohol vapor (you can use hand sanitizer or rubbing alcohol on a cotton ball near the sensor).
  • Check the result on the Serial Monitor.
COM6
Send
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
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Note: If the sensor output does not reflect the actual alcohol presence (e.g., it detects alcohol when there is none, or doesn't detect when alcohol is present), you need to adjust the trigger threshold by turning the potentiometer on the sensor module. Turn it clockwise to increase sensitivity or counterclockwise to decrease sensitivity until the detection matches reality.

Arduino UNO R4 Code - Read value from AO pin

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-mq3-alcohol-sensor */ #define AO_PIN A0 // The Arduino UNO R4 pin connected to AO pin of the MQ3 sensor void setup() { // initialize serial communication Serial.begin(9600); Serial.println("Warming up the MQ3 sensor"); delay(20000); // wait for the MQ3 to warm up } void loop() { int alcoholValue = analogRead(AO_PIN); Serial.print("MQ3 sensor AO value: "); Serial.println(alcoholValue); delay(500); }

Detailed Instructions

  • Copy the code above and open it in Arduino IDE
  • Click the Upload button in Arduino IDE to upload the code to Arduino UNO R4
  • Expose the MQ3 sensor to alcohol vapor (you can use hand sanitizer or rubbing alcohol)
  • Check the result on the Serial Monitor.
COM6
Send
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
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Based on the values from DO or AO, you can set threshold levels for alcohol detection and trigger an alarm, activate a warning LED, or log the data for breathalyzer applications.

Arduino UNO R4 Code - Simple Breathalyzer with Thresholds

This advanced example uses the analog output to estimate the level of alcohol intoxication based on calibrated threshold values.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-mq3-alcohol-sensor */ #define AO_PIN A0 // The Arduino UNO R4 pin connected to 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); // 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(AO_PIN); // 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

  • Important: Before using this code, run the calibration sketch above to find your sensor's threshold values in clean air and with alcohol present.
  • Replace the threshold values in the code (SOBER_THRESHOLD and DRUNK_THRESHOLD) with your calibrated values.
  • Upload the code to Arduino UNO R4.
  • Test by exposing the sensor to alcohol vapor (hand sanitizer or isopropyl alcohol).
  • Check the result on the Serial Monitor.
COM6
Send
Sensor Value: 115 | Status: Stone Cold Sober Sensor Value: 118 | Status: Stone Cold Sober Sensor Value: 350 | Status: Drinking but within limits Sensor Value: 480 | Status: DRUNK Sensor Value: 520 | Status: DRUNK Sensor Value: 290 | Status: Drinking but within limits Sensor Value: 125 | Status: Stone Cold Sober
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Note: This is for educational purposes only. Do not use this as a legal breathalyzer or for determining fitness to drive.

Video Tutorial

※ 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!