ad space

MQ3 Alcohol Analyzer with Arduino

Welcome to this tutorial on using an MQ3 Alcohol Analyzer with an Arduino. In this tutorial, we will be discussing the MQ3 Alcohol Analyzer, its features, and how to interface it with an Arduino. We will also be discussing the programming and wiring necessary to make the MQ3 Alcohol Analyzer work with an Arduino. By the end of this tutorial, you will have a basic understanding of how the MQ3 Alcohol Analyzer works and how to use it with an Arduino. So, let's get started!

Here MQ3 sensor is used with Arduino to make alcohol concentration analyzer. This alcohol analyzer can be used to make breath analyzer to find out whether a person has taken alcohol or not and to what extent. Similarly this analyzer can be used in industry where alcohol are used such as wine industry. In wine factory it can be used to find out alcohol concentration in wine. It can be used in security agency or traffic police to detect whether a person is drunk.

arduino mq3 alcohol analyzer

MQ3 sensor module

The MQ3 sensor module is shown below. The module has MQ3 sensor build onto it which is the cylindrical object on the module. The MQ3 sensor is sensitive to alcohol, ethanol, Benzine, Hexane, LPG and CO is built on it along with potentiometer, LM393 comparator IC, power and status LED and resistor. It has four pins- Vcc, ground, DO(Digital output) and AO(Analog output). The Vcc is the positive power supply pin which can support 5V supply. Ground pin is the ground pin. The DO is the digital output pin which can be used to detect whether there is alcohol gas nearby or not. The threshold can be controlled using the potentiometer on the board. The AO is the analog output pin which outputs 0V to 5V according to the intensity of the alcohol gas near it.

MQ3 module

Circuit Diagram

The following shows the schematic diagram of the alcohol analyzer system with Arduino, MQ3 and LCD.

alcohol analyzer circuit diagram

In the circuit diagram, the MQ3 sensor analog pin AO is connected to analog input pin 1 of the Arduino. The MQ3 is supplied with 5V supply on Vcc. The ground is common to both Arduino and MQ3. A 16x2 LCD is connected to the Arduino pins from 8 to 13 as shown.

Source Code

The program of the alcohol analyzer is provided below.

#include <LiquidCrystal.h>

#define MQ3pin 1                  

float mq3Value;

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);            //16x2 LCD Pin configuration

void setup () {
  //send to serial port
  Serial.begin(9600);                               //setup UART baudrate 9600bps
  Serial.print("Warming Up...\n");
  //send to LCD
  lcd.begin(16, 2);
  lcd.print("Warming Up...");
  delay(5000); // 5 second warming up time
  
  //send to serial port
  Serial.print("Warming done...\n");

  //send to LCD
  lcd.clear();
  lcd.print("Warming done...");
  lcd.clear();
}

void loop() {

  mq3Value = analogRead(MQ3pin); // read analog input pin

  Serial.print("Alcohol Level: ");
  Serial.println(mq3Value);
  Serial.print("\n");
   if (mq3Value < 200) { // If value read is less than 200, you are sober
      Serial.println("Sober");
      }
      if (mq3Value >= 200 && mq3Value < 280) {
      Serial.println("One beer");
      }
      if (mq3Value >= 280 && mq3Value < 350) {
      Serial.println("Two or more beers.");
      }
      if (mq3Value >= 350 && mq3Value < 450) {
      Serial.println("VODKA Level");
      }
      if (mq3Value > 450) {
      Serial.println("Drunk");
      }
   Serial.print("\n");

  //send to LCD
  lcd.setCursor(0, 0);
  lcd.print("Alcohol:");
  lcd.print(mq3Value);
  lcd.setCursor(0, 1);
  if (mq3Value < 200) { // If value read is less than 200, you are sober
      lcd.print("Sober");
      }
      if (mq3Value >= 200 && mq3Value < 280) {
      lcd.print("One beer");
      }
      if (mq3Value >= 280 && mq3Value < 350) {
      lcd.print("Two or more beers");
      }
      if (mq3Value >= 350 && mq3Value < 450) {
      lcd.print("VODKA Level");
      }
      if (mq3Value > 450) {
      lcd.print("Drunk");
      }
    delay(200);
    lcd.clear();
}

 In this we setup, we have used the LiquidCrystal library for the 16x2 LCD. The Arduino pin 1 as input and give it alias name mq3pin. The float variable mq3Value is used later in the program to hold the sensor value from the MQ3 AO pin. The value from the MQ3 ranges from 0V to 5V which is converted by the Arduino ADC to 0 to 1023. The higher the value of mq3Value the more the alcohol concentration is sensed by the MQ3 sensor. Next we have used the LiquidCrystal instance to configure the 16x2 LCD pins.

In the setup() function, we have set up the serial monitor with 9600 baud rate. This is for viewing the value read by the sensor on the Arduino IDE monitor. The MQ3 sensor requires some warming in order to function properly and more accurately. So we print that information to the Arduino serial monitor and also to the LCD display. We wait for 5 seconds for this warming delay.

In the main loop() function, we read the analog value sent by the MQ3 sensor AO pin. We send the read value to the serial monitor and also to the LCD. If the read value in less than 200 then we conclude that there is no alcohol detected. If the value read fall within the range of 200 and 280 then we conclude that slight alcohol is detected and assume that alcohol concentration of one beer equivalent is there. Similarly when the value read is within the range of 280 and 350 then there is alcohol concentration of two or more beer, when the value is within range of 350 and 450 then alcohol concentration is level of one vodka and finally if the value read is over 450 then we say that alcohol concentration detected is very high and the person is drunk.

The following shows output of the analyzer system.

alcohol analyzer with arduino

 The serial monitor display is shown below.

serial monitor alcohol

Video Demonstration

The following video shows how the MQ3 alcohol analyzer works.


Recommended Tutorials

In this tutorial we have MQ3 which is alcohol sensor. Another similar sensor is the MQ2 sensor which can be used detect various gases and smoke. The tutorial MQ-2 Gas Sensor with Arduino and LCD explains how it works with Arduino and the tutorial Gas Sensor MQ-2 with ATmega32 and LCD uses ATmega32A microcontroller.

Post a Comment

Previous Post Next Post