MQ3 Alcohol Sensor with Arduino, programming, and circuit diagram
Last Updated on September 21, 2025 by Engr. Shahzada Fahad
Table of Contents
MQ3 Alcohol Sensor:
MQ3 Alcohol Sensor with Arduino, programming, and circuit diagram- In today’s article, I am going to walk you through how to use the MQ3 Alcohol Sensor with Arduino.
The MQ3 is one of the most commonly used gas sensors for detecting alcohol levels in the air, and it works particularly well when used to measure alcohol on a person’s breath. When placed close to someone who has consumed alcohol, the sensor can quickly detect the vapors and give us a reading that we can use for monitoring or triggering actions in a project.
Let’s start with the basics of the sensor itself. The MQ3 alcohol sensor module typically comes with four pins:
VCC (+5V): This pin is used to power the sensor. It operates on 5 volts supplied by the Arduino.
DOUT (Digital Output): This pin provides a digital signal (HIGH or LOW). When the alcohol concentration reaches a certain threshold, the module pulls this pin HIGH, which can be directly read by one of Arduino’s digital pins.
AOUT (Analog Output): This pin gives an analog voltage that varies depending on the concentration of alcohol in the air. By connecting this pin to one of Arduino’s analog input pins, you can measure more precise values instead of just HIGH/LOW.
GND (Ground): This pin is connected to Arduino ground to complete the circuit.
The advantage of having both digital and analog outputs is flexibility. If you just need a simple yes/no output; for example, to trigger a buzzer or LED when alcohol is detected, you can use the digital pin. But if you want to measure the exact concentration level and display it on an LCD, send it to a serial monitor, or log it for analysis, the analog output is the better choice.
So these are the four pins of the MQ3 sensor, and now let’s look at them one by one to understand what they actually do.
The first pin is VCC, which is simply the +5V supply pin. It takes power from our circuit or Arduino to run the sensor.
The second pin is DOUT, which stands for Digital Output. This pin works in a very simple way: it either goes HIGH (1) or LOW (0). In other words, the output is binary. When the alcohol concentration in the air crosses a certain threshold, the sensor outputs HIGH; if the concentration is below that threshold, it outputs LOW. You can think of it as an ON/OFF signal, which is very useful if you just want to know whether alcohol is detected or not.
The third pin is AOUT, which stands for Analog Output. Unlike the digital pin, this one doesn’t just give you ON or OFF. Instead, it produces a variable voltage that depends on the intensity of alcohol present in the surrounding air. The higher the concentration of alcohol, the higher the output voltage. By connecting this pin to Arduino’s analog input, you can measure the exact alcohol level and even display or log the readings for analysis.
Now, the main difference between digital and analog output is:
Digital Output (DOUT): Goes HIGH or LOW when alcohol content crosses the sensor’s preset limit.
Analog Output (AOUT): Provides a smooth range of voltage values representing all levels of alcohol concentration, so you can set your own limits in the code depending on the application.
The fourth pin is GND, which is the ground connection and completes the circuit.
To better understand how this works, imagine spraying some perfume or sanitizer near the sensor. Since many of these sprays contain alcohol, the sensor immediately detects the vapors. The analog output voltage will rise according to how strong the alcohol concentration is around the sensor. If there’s just a little alcohol, the reading may stay closer to zero on the ADC scale (0–1023 on Arduino). But if the concentration is higher, the reading will climb toward the upper end of that range, close to 1023.
On the digital side, the module will simply switch from LOW to HIGH once the concentration reaches the manufacturer’s set threshold, otherwise it stays LOW.
In simple words, the MQ3 alcohol sensor works by converting the alcohol vapors in the air into a measurable voltage. With analog output, you get detailed readings of alcohol levels, and with digital output, you get a quick yes/no indication.
Feature:
- High quality double panel design, with power indicator and TTL output signal.
2. Have DO switch signal(TTL) output and AO analog signal output.
3. TTL output signal for low level effectively. (When the low output electric signal lights at ordinary times, can be directly connect single chip microcomputer or relay module)
4. Analog output voltage with concentration, the higher concentration, the higher voltage.
5. Has better sensitivity with the liquefied petroleum gas, natural gas, city gas, smoke.
6. Has long service life and reliable stability
7. Rapid response recovery features
Specification:
Input voltage: DC5V
Power consumption (current) : 150 mA
DO output: TTL digital 1 and 0 (0.1 and 5 V)
AO output: 0.1-0.3 V (pollution-free)
Highest concentration of voltage: Approx 4 V
Detection range of alcohol: detection range of 10 ~ 1000 PPM
Connection mode:
- VCC: Positive (5 v)
2. GND: Connect power negative
3. DO: TTL switch signal output
4. AO: Analog signal output
Alcohol sensor with Arduino:
Now that we understand how the MQ3 alcohol sensor works, let’s move on to building a simple project.
In this project, we will turn ON an LED and a buzzer whenever the alcohol level goes above a certain threshold. This is a basic but very practical demonstration of how alcohol detection systems are made.
Circuit Connections
Follow these steps to connect the components properly:
- Connect the VCC pin of the MQ3 sensor to the 5V pin of the Arduino. This powers up the sensor.
- Connect the GND pin of the sensor to the GND pin of the Arduino.
- Connect the DOUT pin of the MQ3 sensor to digital pin 2 of the Arduino. This will allow us to detect when the alcohol concentration has crossed the threshold.
- Connect the AOUT pin of the MQ3 sensor to analog pin A0 of the Arduino. This will give us more detailed readings of alcohol levels.
LED Connections:
- Connect the anode (longer leg) of the LED to digital pin 7 of the Arduino.
- Connect the cathode (shorter leg) of the LED to the Arduino’s GND (through a 220Ω resistor for safety).
5V Buzzer Connections:
- Connect the positive terminal of the buzzer to digital pin 12 of the Arduino.
- Finally, connect the negative terminal of the buzzer to the GND of the Arduino.
Tip: If your buzzer doesn’t turn ON when connected directly to the Arduino, don’t worry. Some buzzers draw more current than the Arduino pin can safely provide. In that case, you should use a 2N2222 NPN transistor as a driver.
Connect the emitter of the transistor to GND.
Connect the collector to the negative terminal of the buzzer.
Connect the positive terminal of the buzzer to +5V.
Finally, connect the base of the transistor to digital pin 12 of the Arduino through a 1kΩ resistor.
This way, the transistor acts as a switch. The Arduino only needs to provide a tiny current at the base, while the transistor handles the higher current required by the buzzer.
Once all the wiring is complete, your circuit will be ready for programming.
The idea is simple:
The MQ3 sensor continuously monitors the alcohol level.
If the concentration crosses the defined limit, the Arduino will turn ON the LED and the buzzer to give both visual and audible alerts.
If the alcohol level falls below the limit, the LED and buzzer will turn OFF again.
Arduino MQ3 Sensor Code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#define dsensor 2 #define LED 7 #define buzzer 12 #define asensor A0 void setup() { pinMode(dsensor, INPUT); pinMode(LED, OUTPUT); pinMode(buzzer, OUTPUT); Serial.begin(9600); } void loop() { bool digital = digitalRead(dsensor); intanalog = analogRead(asensor); Serial.print("Analog value : "); Serial.print(analog); Serial.print("t"); Serial.print("Digital value :"); Serial.println(digital); if (digital == 0) { digitalWrite(LED, HIGH); digitalWrite(buzzer, HIGH); } else { digitalWrite(LED, LOW); digitalWrite(buzzer, LOW); } } |
Alcohol sensor with Arduino and OLED:
Now, suppose we don’t just want to trigger an LED or a buzzer, but we also want to see the live alcohol sensor readings displayed on an OLED screen.
For that, we will connect both the MQ3 sensor and an OLED display to the Arduino. This will allow us to visualize the analog values from the sensor in real time.
Circuit Connections
Follow these steps carefully:
- Connect the VCC pin of the MQ3 alcohol sensor to the 5V pin of the Arduino.
- Connect the GND pin of the MQ3 sensor to the GND pin of the Arduino.
- Connect the DOUT pin of the MQ3 sensor to digital pin 2 of the Arduino.
- Connect the AOUT pin of the MQ3 sensor to analog pin A0 of the Arduino.
Now, for the OLED display SSD1306 I2C OLED:
- Connect the VCC of the OLED to the 3.3V pin of the Arduino UNO (most small OLEDs work safely on 3.3V).
- Connect the GND of the OLED to the Arduino’s GND.
- Connect the SDA pin of the OLED to A4 (SDA) on the Arduino UNO.
- Connect the SCL pin of the OLED to A5 (SCL) on the Arduino UNO.
Once all the connections are made, the MQ3 sensor will continue to provide alcohol level readings, and the Arduino will display those readings directly on the OLED in real time. This is very useful for projects where you want a neat, portable display instead of relying only on the Serial Monitor.
MQ3 Sensor Value on OLED display Code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
#include <SPI.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 #define LOGO16_GLCD_HEIGHT 16 #define LOGO16_GLCD_WIDTH 16 staticconst unsigned char PROGMEM logo16_glcd_bmp[] = { B00000000, B11000000, B00000001, B11000000, B00000001, B11000000, B00000011, B11100000, B11110011, B11100000, B11111110, B11111000, B01111110, B11111111, B00110011, B10011111, B00011111, B11111100, B00001101, B01110000, B00011011, B10100000, B00111111, B11100000, B00111111, B11110000, B01111100, B11110000, B01110000, B01110000, B00000000, B00110000 }; #if (SSD1306_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif constintAOUTpin=0;//the AOUT pin of the alcohol sensor goes into analog pin A0 of the arduino constintledPin=13;//the anode of the LED connects to digital pin D13 of the arduino int limit; int value; void setup() { Serial.begin(9600); // by default, we'll generate the high voltage from the 3.3v line internally! (neat!) display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) // init done // Show image buffer on the display hardware. // Since the buffer is intialized with an Adafruit splashscreen // internally, this will display the splashscreen. display.display(); delay(2000); // Clear the buffer. display.clearDisplay(); } void loop() { value= analogRead(AOUTpin);//reads the analaog value from the alcohol sensor's AOUT pin Serial.println(value); // text display tests display.clearDisplay(); display.setCursor(0,0); display.setTextSize(2); display.setTextColor(WHITE); display.println(value); if(value<200) { Serial.println("You are sober."); display.println("Sober"); } if (value>=200 && value<280) { Serial.println("Alcohol detected"); display.println("Alcohol Detected"); } if (value>=280 && value<350) { Serial.println("More than one drink going on here...."); display.println("Many Drinks"); } if (value>=350 && value <450) { Serial.println("Serious Booze here! "); display.println("Huge Booze"); } if(value>450) { Serial.println("You are drunk!"); display.println("Too Much!"); } display.display(); delay (500); } |
Discover more from Electronic Clinic
Subscribe to get the latest posts sent to your email.






