Alcohol Detection using Arduino

The alcohol detector sensor is specially referred to as a MQ3 sensor which detects alcohol in the air. When a drunk person breathes near the alcohol sensor it detects the alcohol in his breathe and provides an output based on alcohol concentration. If there is more alcohol concentration more LED’s would glow. If there is less alcohol concentration less LED’s would glow. Hence you can get to know about the concentration and thus detect alcohol.


Arduino is the main controlling unit of the robot. Out of the 19 available digital and analog I/O pins, 7 pins are used in this project design.

MQ3 alcohol sensor is made by using SnO2 material which has less conductivity in clean air. Whenever it comes nearby alcohol gas its starts conducting highly according to the gas concentration. So user can sense the signal in form of output voltage using Arduino and can detect the presence of Alcohol concentration.

MQ3 alcohol sensor have 4 pins: Vcc, DO, AO and Gnd. Vcc and Gnd are connected to the +5v and GND pins of the Arduino. DO is a short form of digital output it can use to get digital output from this pin, by setting a threshold value using the potentiometer.  AO is a short form of analog output this pin outputs 0-5V analog voltage based on the concentration of the alcohol.

A light-emitting diode (LED) is a semiconductor device that emits light when passed through an electric current. LEDs are mainly used in this project as indicator lights (such as power on/off lights) on alcohol detector devices.

About Component


Arduino Uno is an ATmega 328p Microcontroller based prototyping board. It is an open source electronic prototyping platform that can be used with various sensors and actuators.

Out of the 19 available digital and analog I/O pins, 7 pins are used in this project design.

Arduino Uno


There 4 leads are +5V, AOUT, DOUT, and GND.

The +5V and GND leads establishes power for the alcohol sensor. The other 2 leads are AOUT (analog output) and DOUT (digital output).



LED (Light Emitting Diode) is basically a small light emitting device that comes under semiconductor electronic components. It has two terminals (anode and cathode) of a LED when connected to a voltage source in the correct polarity, may produce lights of different colours, as per the semiconductor substance used inside it.

5 mm led

RGB LED means red, blue and green LEDs. RGB LED products combine these three colours to produce over 16 million hues of light

Components needed for this Arduino Project

  • Arduino Uno
  • MQ3 Sensor Module
  • Male and Female jumper wire

Circuit Schematics

Building Connection

Step 1

First of all, connect the Arduino board with laptop or computer.


Step 2

Install the Arduino software on the computer.

Step 3

Open the Arduino software. The following screen will appear.

Step 4

You can see the Main page of the software.

Step 5

Then, open the new page on the software.

Then select the File→ New.

A new page opens on the Arduino software.

Step 6

I have given a source code that you can use or you can use your own source code.

Then, select File → open → select written program →open the program.

Open the program folder.

Select the program and open it.

Step 7

Click TOOL-  Select BOARD – then press ARDUINO/GENUINO UNO.

Again Select TOOL >> Select a PORT >> COM3 ARDUINO UNO

Step 8

Verify the program or compile the program

Step 9

Then connect the Arduino to the laptop and upload the code in Arduino

Step 10

Connect the hardware as per the connection diagram given for the Alcohal Detector Sensor.

Step 11

Then the Alcohal Detector Sensor will start working.

Interpretation of Code

const int AOUTpin=A0;
const int ledPin=13;

The analog output (AOUT) pin to use as an input of the alcohol sensor goes into analog pin A0 of the arduino.

The anode of the LED connects to digital pin 13 of the Arduino which is working as an output signal.

Source Code

const int AOUTpin=A0;
const int ledPin=13;

int i,alcohol_high,alcohol_low,mapped,data[200];

void setup() {
pinMode(AOUTpin, INPUT);

void loop()
  alcohol_low = 1023; 

        for(i=200; i>0; i--){
        data[i] = data[i-1]; 
      if(data[i]> alcohol_high)
data[0]= analogRead(AOUTpin);
Serial.print("Alcoholhol value: ");
Serial.println(mapped);//prints the alcoholhol value

  if(data[0] > (alcohol_high-.95*(alcohol_high-alcohol_low)))//this is true if the read is greater than 95% of the span
  digitalWrite(2, HIGH);
  if(data[0] > (alcohol_high-.9*(alcohol_high-alcohol_low)))
  digitalWrite(3, HIGH);
    if(data[0] > (alcohol_high-.8*(alcohol_high-alcohol_low)))
  digitalWrite(4, HIGH);
    if(data[0] > (alcohol_high-.7*(alcohol_high-alcohol_low)))
  digitalWrite(5, HIGH);