Arduino Projects

Arduino Breathalyzer using MQ3 alcohol Detection Sensor and SSD1306 Oled Display

Arduino Breathalyzer using MQ3 alcohol Sensor:

An Arduino-based breathalyzer using an MQ3 Alcohol detection sensor and an SSD1306 OLED display is a simple yet effective device for measuring the alcohol content in a person’s breath. The MQ3 sensor is a metal oxide semiconductor (MOS) sensor that changes its electrical resistance based on the concentration of alcohol in the air. The Arduino microcontroller reads the sensor’s output and converts it into a digital reading. This digital reading is then displayed on the SSD1306 OLED display in terms of estimated blood alcohol content (BAC) level.

Arduino Breathalyzer using MQ3 alcohol Sensor

The SSD1306 OLED display provides a clear, easy-to-read interface for the user, and it is also easy to interface with Arduino. The SSD1306 OLED display is small, low-power, and lightweight, making it ideal for portable applications.




Required Components

To create an Arduino-based project using an MQ3 alcohol detection sensor, you will need the following components you can purchase from amazon:

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

About mq3 Alcohol Detection sensor:

Arduino Breathalyzer using MQ3 alcohol Sensor

The MQ3 Alcohol detection sensor is a semiconductor sensor that is used to detect the presence of alcohol in the air. It is highly sensitive to the presence of ethanol, which is the main component of alcoholic beverages. The sensor works by measuring the resistance of a metal oxide film on its surface. When alcohol is present in the air, the film’s resistance changes and this change is measured by the sensor.

The MQ3 Alcohol detection sensor is a metal oxide semiconductor gas sensor, which is a type of gas sensor that uses a metal oxide film to detect the presence of gases. The sensor has a heating element that is used to heat the metal oxide film, and an analog output pin that is used to provide a voltage output that is proportional to the concentration of the target gas.

The MQ3 sensor is typically used in breathalyzer, air quality monitoring devices and other applications requiring the detection of alcohol. It is also commonly used in industrial and commercial settings, as well as in personal projects. The sensor has a low cost, high sensitivity and fast response time, making it a popular choice for alcohol detection applications.

The MQ3 Alcohol detection sensor requires a power supply and a microcontroller to process the data it collects. The sensor output is an analog signal, so it needs to be converted to digital using an analog-to-digital converter (ADC) before it can be read by the microcontroller. The microcontroller can then use the sensor data to calculate the alcohol concentration in the air and display the results on a screen or through a serial connection to a computer.

Overall, the MQ3 Alcohol detection sensor is a reliable and affordable solution for detecting the presence of alcohol in the air. It is easy to use and can be integrated into a variety of projects and devices, making it a popular choice for alcohol detection applications.



MQ3 Alcohol sensor on Board Components:

Arduino Breathalyzer using MQ3 alcohol Sensor

Power Led:

The MQ3 alcohol sensor has a built-in power LED indicator that shows when the device is receiving power and functioning properly. The LED will light up when the sensor is powered on.

DOUT Led:

The MQ3 alcohol sensor may have a built-in DOUT (digital output) LED that indicates the detection of alcohol. The LED lights up when the sensor detects alcohol in the air, and the brightness of the LED varies depending on the concentration of alcohol detected.

Comparator Op Amp:

The MQ3 alcohol sensor typically has a built-in comparator operational amplifier (op-amp) that compares the output voltage of the sensor with a reference voltage to determine the presence and concentration of alcohol in the air. The comparator op-amp outputs a digital signal that indicates the presence of alcohol, and the signal level can be read by a microcontroller or other device for further processing.

variable resistor (potentiometer)

The MQ3 alcohol sensor may have a built-in variable resistor (potentiometer) that is used to adjust the sensitivity of the sensor. The potentiometer allows the user to fine-tune the threshold voltage at which the sensor outputs a signal, which can be useful in various applications where the sensor is being used to detect different levels of alcohol in the air. By adjusting the potentiometer, the user can set the sensitivity of the sensor to the desired level.

Vcc Pin:

The MQ3 alcohol sensor has a Vcc (power supply) pin that is used to supply power to the device. The Vcc pin is typically connected to Arduino 5v pin.

GND (ground) pin:

The MQ3 alcohol sensor has a GND (ground) pin that is used as a reference voltage for the device. The GND pin is typically connected to the ground of the Arduino pin.

DO pin:

The MQ3 alcohol sensor has a D0 (digital output) pin that provides a digital signal indicating the presence and concentration of alcohol in the air. The D0 pin outputs a high or low voltage level depending on the concentration of alcohol detected by the sensor. When the alcohol concentration exceeds a certain threshold, the D0 pin outputs a high voltage level. When the alcohol concentration is below the threshold, the D0 pin outputs a low voltage level. The D0 pin can be connected to a microcontroller digital output pins.

AO pin:

The MQ3 alcohol sensor has an A0 (analog output) pin that provides an analog voltage proportional to the concentration of alcohol in the air. The A0 pin outputs a voltage level that can be read by an analog-to-digital converter (ADC) to convert the analog signal to a digital value. The AO pin of the mq3 sensor can be connected with any of the Arduino Analog pin.



Types and Functions of Gas Sensors

Gas sensors of the MQ type consist of several types according to their respective designations. The list below shows the function of each type of gas sensor.

  • MQ-2: LPG/smoke detection sensor
  • MQ3: Alcohol detection sensor
  • MQ-4: Methane gas detection sensor
  • MQ-5: LPG liquefied petroleum gas sensor (natural gas, city gas)
  • MQ-6: LPG liquefied petroleum gas sensor (propane, butane)
  • MQ-7: Carbon monoxide gas detection sensor
  • MQ-8: Hydrogen gas detection sensor
  • MQ-9: Gas detection sensor (carbon monoxide, coal gas, liquefied natural gas)
  • MQ-135: Air Quality detection sensor (Benzene, Alcohol, Smoke)

Gas Sensor Construction

The most frequently used gas sensors are metal oxide based gas sensors ( Metal Oxide Based Gas Sensors ). In general, gas sensors are composed of several parts, including: 

Gas sensing layer

The sensing layer is the main component of a sensor to detect differences in gas concentration and produce differences in resistance. Basically, the sensing layer is a chemiresistor whose value will change if there is a difference in the chemical structure of the gas somewhere.

The sensing element is made of Dioxide (SnO2) which has an excess of electrons (donor element). So, if there is a change in gas concentration, the resistance of the element will change and the flowing current will also change according to the change in gas concentration.

Heating coil

The heating coil functions to increase the temperature of the sensing element so that the sensitivity and efficiency increase. The heating coil is made of Nickel-Chromium which has a high melting point, so it can work to heat the sensing element and not melt.

Electrode line

The sensing element generates a very small current when it detects a difference in gas concentration. Therefore, the efficiency of the path to carry the current must be considered. Usually used platinum conductor to pass the current efficiently.

Ceramic tube

Between the heating coil and the sensing layer, there is a ceramic tube made of Aluminum Oxide (Al2O3). This ceramic tube has a high melting point so that it can survive when the sensing layer is heated.

Electrodes

The electrode here is a junction that connects the sensing layer with the output. The electrodes are made of gold (Au) which is an excellent conductor.

The electrodes are also used as a wire mesh to protect the sensing element from dust particles and prevent damage by corrosive particles.



Specifications of the MQ3 Alcohol Sensor

The MQ3 Alcohol detection sensor module is a gas sensor that is used to detect the presence of alcohol in the air. Some of the specific specifications of the MQ3 sensor include:

  • Detection Range: The sensor can detect alcohol concentrations between 0.04 mg/L and 10 mg/L.
  • Sensitivity: The sensor has a high sensitivity to alcohol and a low sensitivity to other gases.
  • Heating Time: The sensor has a heating time of about 20 seconds.
  • Response Time: The sensor has a response time of less than 10 seconds.
  • Operating Voltage: The sensor operates at a voltage range of 3.3V to 5V.
  • Operating Temperature: The sensor operates within a temperature range of -20°C to 50°C.
  • Output: The sensor module typically provides an analog output voltage that varies with the concentration of alcohol in the air.

How Arduino based Mq3 Breathalyzer works?

An Arduino-based breathalyzer works by using a sensor to measure the alcohol content in a person’s breath. The sensor, typically a metal oxide semiconductor (MOS) sensor, changes its electrical resistance based on the concentration of alcohol in the air. The Arduino microcontroller reads the sensor’s output and converts it into a digital reading. This digital reading is then processed by the Arduino to estimate the blood alcohol content (BAC) level.

The Arduino uses the information from the sensor and applies some calculations on it, like a simple resistance measurement or through more complex algorithms to estimate the BAC level. The calculated BAC level is then sent to a display, such as an 16×2 LCD screen or SSD1306 OLED display, to show the user the estimated BAC level.

Some breathalyzers may also include additional components such as a fan to blow air over the sensor or a temperature sensor to ensure accurate readings. The fan is used to blow fresh air over the sensor to prevent contamination of the sensor by previous breath samples. The temperature sensor is used to compensate for changes in sensor resistance due to changes in temperature.

Additionally, the breathalyzer may have a push button or switch to initiate a reading, and some may also have a warning system that activates when the BAC level exceeds a certain threshold. The device can be powered by a 9V battery or USB cable.

It is important to note that the accuracy of a breathalyzer can be affected by various factors such as the type of sensor used, the age of the sensor, and the calibration of the device. Therefore, it is essential to calibrate the device regularly and to use it only as a rough estimate of the BAC level.




Arduino MQ3 Alcohol Detection Circuit Diagram

Arduino Breathalyzer using MQ3 alcohol Sensor

I Connected the MQ3 Alcohol detection sensor to the Arduino. The sensor typically has four pins: VCC, GND, AOUT, and DOUT. I connected VCC to the 5V pin of the Arduino, GND to the GND pin of the Arduino, AOUT to an analog pin of the Arduino  A0, and DOUT to the digital pin of the Arduino D10.

Then I connected the SSD1306 OLED display to the Arduino. The SSD1306 OLED display typically has four pins: VCC, GND, SDA, and SCL. I connected the VCC to the 5V pin of the Arduino, GND to the GND pin of the Arduino, SDA to the A4 pin of the Arduino, and SCL to the A5 pin of the Arduino.

Then I connected the LED to the Arduino. The LED typically has two pins: Anode and Cathode. Connect the Anode long leg to a digital pin of the Arduino D13 and the Cathode short leg to the GND pin of the Arduino.

Then I connected the buzzer to the Arduino.  This is a 5V buzzer and it can’t be directly controlled using the Arduino; so, that’s why I am using this driver circuit to turn ON and OFF this buzzer. The base of the transistor is connected with the D4 pin of the Arduino Board. So, that’s all about the connections.



MQ3 Alcohol Detection Arduino code:

#include <SPI.h>  

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

const  int AQ0 = A0;    // output destination of MQ3 sensor module A0

const  int DQ0 = 10 ;    // output destination of MQ3 sensor module D0

const  int buzzer = 4 ;

int led = 13 ;    // LED for monitoring the status of the MQ3 sensor

#define SCREEN_WIDTH 128 // ORelay display width, in pixels

#define SCREEN_HEIGHT 64 // ORelay display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)

#define ORelay_RESET    -1

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, ORelay_RESET);

void  setup () {

  pinMode (AQ0, INPUT );

  pinMode (DQ0, INPUT );      //Specify pin 10 as INPUT

  pinMode (buzzer, OUTPUT ); //Specify pin 2 as OUTPUT

  pinMode (led, OUTPUT );     //Specify pin 13 as OUTPUT

  Serial.begin ( 9600 ); 

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

  delay(2000);

  display.clearDisplay();

  display.setTextColor(WHITE);

}

void  loop () {

  float A0_out;

  int D0_out;

  A0_out= analogRead (AQ0);

  D0_out = digitalRead(DQ0);

  Serial.print( “Sensor Status: ” );

  Serial.println(D0_out);

  Serial.print( “Value: ” );

  Serial.println(A0_out);

  display.clearDisplay();

  display.setCursor(10, 0);

  display.setTextSize(2);

  display.setTextColor(WHITE);

  display.print(“Value:”);

  display.setCursor(10,25);

  display.print(A0_out);

  display.display();

  delay(1000);

  if (D0_out == LOW ) { 

    digitalWrite (buzzer, HIGH ); //Output “HIGH” to pin 2 buzzer ON

    digitalWrite ( led, HIGH );     //output “HIGH” to pin 13 LED ON

  }

  else if(D0_out == HIGH ) { 

    digitalWrite(buzzer, LOW );   //Output Low to pin 2 buzzer OFF

    digitalWrite( led, LOW );      //output Low to pin 13 LED OFF

  }

}



Programming explanation:

This program is written in the Arduino programming language and is used to control an Arduino board and various other components such as an MQ3 sensor, an SSD1306 OLED display, and a buzzer.

#include <SPI.h>             

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

The program starts by including various libraries such as SPI, Wire, Adafruit_GFX and Adafruit_SSD1306. These libraries contain pre-defined functions and commands that the program uses later.

const  int AQ0 = A0;   

const  int DQ0 = 10 ;  

const  int buzzer = 4 ;

int led = 13 ;

The program then defines various constants such as AQ0, DQ0, and buzzer. AQ0 and DQ0 are the output destinations of the MQ3 sensor module, and buzzer is the pin number used for the buzzer. The program also defines a variable led which is used to monitor the status of the MQ3 sensor.



#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64

#define ORelay_RESET     -1

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, ORelay_RESET);

This is a block of code that defines constants and initializes an object of the Adafruit_SSD1306 class for an OLED display.

The first line, #define SCREEN_WIDTH 128, defines a constant named “SCREEN_WIDTH” and assigns it the value of 128. This constant is used to set the width of the SSD1306 OLED display.

The second line, #define SCREEN_HEIGHT 64, defines a constant named “SCREEN_HEIGHT” and assigns it the value of 64. This constant is used to set the height of the SSD1306 OLED display.

The third line, #define ORelay_RESET -1, defines a constant named “ORelay_RESET” and assigns it the value of -1. This constant is used to set the reset pin of the OLED display.

The fourth line, Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, ORelay_RESET); creates an object of the Adafruit_SSD1306 class named “display” by passing the values of the constants SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, ORelay_RESET as arguments to the class constructor.




void  setup () {

  pinMode (AQ0, INPUT );

  pinMode (DQ0, INPUT );      //Specify pin 10 as INPUT

  pinMode (buzzer, OUTPUT ); //Specify pin 4 as OUTPUT

  pinMode (led, OUTPUT );     //Specify pin 13 as OUTPUT <- OK without

Serial.begin ( 9600 );    //Specify the data transfer rate of serial communication at 9600bps

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

  delay(2000);

  display.clearDisplay();

  display.setTextColor(WHITE);

}

This code is setting up an Arduino microcontroller. The setup() function is a built-in function in Arduino that runs once when the microcontroller is powered on or reset.

The pinMode function is used to configure a pin on the microcontroller as either an INPUT or OUTPUT. In this case, the pins AQ0, DQ0 are set as INPUT, the pin buzzer is set as OUTPUT and pin led is set as OUTPUT.

The Serial.begin(9600) function sets the data rate in bits per second (baud) for serial data transmission. This is used for sending and receiving data with other devices, such as a computer.

The display.begin(SSD1306_SWITCHCAPVCC, 0x3C) function initializes the OLED display and sets the display type and I2C address.

The delay(2000) function causes the program to wait for 2000 milliseconds (2 seconds) before continuing.

The display.clearDisplay() function clears the OLED display.

The display.setTextColor(WHITE) function sets the text color on the OLED display to white.



void  loop () {

  float A0_out;

  int D0_out;

  A0_out= analogRead (AQ0);

  D0_out = digitalRead(DQ0);

  Serial.print( “Sensor Status: ” );

  Serial.println(D0_out);

  Serial.print( “Value: ” );

  Serial.println(A0_out);

  display.clearDisplay();

  display.setCursor(10, 0);

  display.setTextSize(2);

  display.setTextColor(WHITE);

  display.print(“Value:”);

  display.setCursor(10,25);

  display.print(A0_out);

  display.display();

  delay(1000);

  if (D0_out == LOW ) {  

    digitalWrite (buzzer, HIGH );

    digitalWrite ( led, HIGH );    

  }

  else if(D0_out == HIGH ) {    

    digitalWrite(buzzer, LOW );  

    digitalWrite( led, LOW );

  }

}

The loop function reads the values of the MQ3 sensor module’s AQ0 and DQ0 pins, then calculates and displays the voltage value on the SSD1306 OLED display. It also monitors the D0 pin of the sensor, if it is LOW, it turns on the buzzer and LED, indicating the presence of alcohol. If it is HIGH, it turns off the buzzer and LED, indicating no alcohol is detected.

The program uses the SSD1306 OLED display to show the alcohol level and the buzzer to give an indication of the presence of alcohol. The SSD1306 OLED display is 128×64 pixels, and it communicates with the Arduino board through the I2C protocol. The SSD1306 OLED display updates every second with the new alcohol level. The program keeps running indefinitely in a loop, taking continuous measurements of the alcohol level.



Practical Demonstration:

Arduino Breathalyzer using MQ3 alcohol Sensor

As you can see I connected all the components as per the circuit diagram.

Arduino Breathalyzer using MQ3 alcohol Sensor

As you can see, I have powered up the Arduino Nano board, an right now you can see value on the SSD1306 Oled display module. This is the value from the MQ3 Alcohol Sensor. Anyway, its ready for the testing. So, let’s go ahead and start our practical demonstration.



For the demonstration purposes, I am using Spirit.

Arduino Breathalyzer using MQ3 alcohol Sensor

For easy use, I have made a hole in the bottle cap.

Arduino Breathalyzer using MQ3 alcohol Sensor

You guys know very well, Spirit is volatile, and as it escapes through the bottle cap hole; the sensor immediately senses it. As a result, the value on the Oled display module is increased. And at the same buzzer is also activated. You might not understand the whole working mechanism, so I suggest you guys should watch video tutorial given at the end of this article.

So that’s all about Arduino-based Breathalyzer using an MQ3 Alcohol detection sensor, an SSD1306 OLED display module, 5V Buzzer, and of course an Arduino board. So, that’s all for now.




Video Tutorial:

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button