MQ-3 Alcohol Ethanol Gas Sensor Module


This is an Arduino Alcohol sensor. It uses a MQ3 probe which can be used in a Breathalyser. It has a high sensitivity to alcohol and less sensitivity to Benzine.

The sensitivity is able to be adjusted by the potentiometer. The output is proportional to the density of gas. You can use analog reading to read the data from this sensor.

To ease the difficulty of using this sensor, a Gravity Interface is adapted to allow plug&play. The Arduino IO expansion shield is the best match for this senor connecting to your Arduino microcontrollers.


  • Standard assembling structure (Times-of-5mm Center distance between four 3mm(0.12") mounting holes)
  • Easily recognitive interfaces of sensors ("A" for analog and "D" for digital)
  • Icons to simplely illustrate sensor function
  • High quality connector & potentiometer
  • Immersion gold surface


  • Power supply: 5V
  • Interface type: Analog
  • High sensitivity to alcohol and small sensitivity to Benzine
  • Fast response and High sensitivity
  • Stable and long life
  • Simple drive circuit
  • Size: 36.4x26.6mm(1.43"x1.05")


MQ-3 Alcohol Sensor Circuit Built with an Arduino

In this project, we will go over how to build an alcohol sensor with an arduino.
The alcohol sensor we will use is the MQ-3 sensor. This is a sensor that is not only sensitive to alcohol, particularly ethanol, which is the type of alcohol which is found in wine, beer, and liquor.
This type of sensor circuit can be used as a breathalyzer to check a person's blood alcohol level. Just as we exhale carbon dioxide when we breathe out, we also will breathe out some alcohol if we have alcohol in our blood. Any alcometer device can measure this alcohol content.
The more ethanol in your blood, the more there is in the air on exhalation. This alcohol content gives a good indication for if a person is drunk and how drunk they are.
The amount of alcohol exhaled into the air is proportional to the amount of alcohol which will be found in a person's blood. Alcometers use a built-in formula to estimate blood alcohol content from exhaled air alcohol content.
For different countries, the level of alcohol in the blood that defines a person as over the limit for driving varies. The range ranges from 0.01 to 0.10. Most countries have a limit of about 0.05. For example, Greece, Greenalnd, and Iceland all have limits of 0.05. Canada has a higher limit set at 0.08. In the United States, it is also 0.08. This means that if the alcometer reading measures above this, the person can receive a DUI.
For our circuit, it can function as an alcometer so that we get an estimate of a person's blood alcohol level.
Disclaimer: You don't have to drink alcohol in order to test this sensor. Mouthwash, such as Listerine, contains alcohol. If you gargle mouthwash for a few seconds and then breathe into the sensor, the readings should jump and register. This is all that's needed to test. I take no responsibility for any drunkenness.

Components Needed

  • MQ-3 alcohol sensor
  • Arduino
  • LED

The MQ-3 can be obtained very cheaply, just a few bucks. A good place to look for it is on ebay, which always has auctions on them for the $2-$3 range.
Important, it is recommended that you do not obtain the standalone sensor but the whole MQ-3 board. This is because if you buy the standalone sensor, you will have to finish building the whole schematic before you can connect it to the arduino. So that less work is required for integrating it with the arduino, it is recommended that you buy the complete MQ-3 sensor circuit. This you can see below.
If you buy the complete board, there are 4 leads which need to be connected.

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). How the sensor works is the terminal AOUT gives an analog voltage output in proportion to the amount of alcohol the sensor detects. The more alcohol it detects, the greater the analog voltage it will output. Conversely, the less alcohol it detects, the less analog voltage it will output. If the analog voltage reaches a certain threshold, it will send the digital pin DOUT high. Once this DOUT pin goes high, the arduino will detect this and will trigger the LED to turn on, signaling that the alcohol threshold has been reached and is now over the limit. How you can change this threshold level is by adjusting the potentiometer to either raise or lower the level.

MQ-3 Alcohol Sensor Circuit Schematic
The alcohol sensor circuit we will build with an MQ-3 sensor integrated with an arduino is shown below.
The connections are pretty basic.
To connect the sensor, there are 4 leads. 2 of them are for power. The +5V terminal of the sensor connects into the 5V terminal of the arduino board. The GND terminal of the sensor connects into the GND terminal of the arduino. This establishes power for the sensor.
The other 2 connections are the analog and digital output of the sensor. These connect to analog pin A0 and digital pin D8, respectively.

The code which we need to upload to the arduino so that it can measure alcohol levels is shown below.

/* MQ-3 Alcohol Sensor Circuit with Arduino */
const int AOUTpin=0;//the AOUT pin of the alcohol sensor goes into analog pin A0 of the arduino
const int DOUTpin=8;//the DOUT pin of the alcohol sensor goes into digital pin D8 of the arduino
const int ledPin=13;//the anode of the LED connects to digital pin D13 of the arduino
int limit;
int value;
void setup() {
Serial.begin(115200);//sets the baud rate
pinMode(DOUTpin, INPUT);//sets the pin as an input to the arduino
pinMode(ledPin, OUTPUT);//sets the pin as an output of the arduino
void loop()
value= analogRead(AOUTpin);//reads the analaog value from the alcohol sensor's AOUT pin
limit= digitalRead(DOUTpin);//reads the digital value from the alcohol sensor's DOUT pin
Serial.print("Alcohol value: ");
Serial.println(value);//prints the alcohol value
Serial.print("Limit: ");
Serial.print(limit);//prints the limit reached as either LOW or HIGH (above or underneath)
if (limit == HIGH){
digitalWrite(ledPin, HIGH);//if limit has been reached, LED turns on as status indicator
digitalWrite(ledPin, LOW);//if threshold not reached, LED remains off

The first block of code defines all the pin connections of the sensor and the LED. Since the AOUTpin connects to analog pin A0, it is initialized to 0. Since the DOUTpin connects to digital pin D8, it is initialized to 8. Since the LED connects to digital pin D13, it is initialized to 13. 2 variables, limit and value, are also declared. These will be used to store the value of the analog pin AOUT and digital pin DOUT.
The next block of code sets the baud rate and declares the DOUTpin as input and the ledPin as output. This is because the sensor is an input to the arduino for the arduino to read and process the sensor value. And the LED is an output will serves an indicator if the sensor has detected alcohol.
The next block of code reads the sensor pin AOUT and stores the value in the integer value. It also reads the sensor pin DOUT and stores the value in the integer limit. We then print the alcohol value, which will be a numeric value ranging from either 0 (no alcohol detected) to 1023 (maximum level of alcohol that can be read). We will aslo print the limit which will either be HIGH or LOW. If the alcohol detected is under the threshold level, the value of limit returned will be low. If the alcohol detected is above the threshold, the value of limit returned will be HIGH.
If the value is HIGH, the LED will turn on. If the value is low, the LED will remain off.

Connection between MQ-2 and Raspberry Pi

In this example, we use a 5V voltage as output. This is too much for the GPIOs, which is why we use a logic level converter (TTL) that cuts down the voltage. If you use a sensor other than the MQ-2 and it has a different voltage, the setup must of course be adjusted.
After the MCP3008 is correctly connected, we use port 0 and connect it to RX0 of the TTL. On the opposite side is RX1, which is connected to the analog pin (A0) of the MQ2 sensor. Also connect 3.3V from the Raspberry Pi (LV) and 5V (HV) to the TTL. And also 5V to the VCC pin of the gas sensor and GND from the Raspberry Pi comes to GND on the LV and HV side of the TTL, as well as to GND of the MQ2.
Schematically the whole looks as follows:


I use the 5V of the Raspberry Pi’s. However, an external power supply is recommended if other sensors and modules or input devices (keyboard, mouse, touchscreen) are used. For this, the sensor is simply supplied with current from the external source (HV side of the TTL) and the ground connection (Minus / GND) is connected to GND of the Raspberry Pi.

Configuration of the Raspberry Pi Gas Sensor – Preparation
The concentration of a gas is given in PPM (parts per million). One difficulty of the MQ-2 is that a single analog value is given with which the gas content in the air has to be calculated for the various supported gases. However, the sensor must be configured for this purpose. Since this manual is also applicable to another Raspberry Pi gas sensor, the procedure is as follows:
First, we have to see the data sheet of the respective module, which contains a diagram:


The specified values are in logarithmic scale
However, the scaling of the values is not linear but logarithmic to the base 10 (log). so, the first stroke on the X axis is 200, then 300, etc. The first stroke after 1000 is 2000, etc. The distance between is linear. The idea behind this script for calibration and reading is to create a straight line and calculate the amount of gas (in ppm). To do this, we need two points to calculate the slope.
Let us take the example of LPG. We therefore take the point P1 (x = 200, y = ~ 1.62) and P2 (x = 10000, y = ~ 0.26). To calculate the “real” values, we apply the ten logarithm. Using the two-point form, we can calculate the slope, which in our case is -0.47 (link to the calculation). With the slope and the calculated logarithm from the left point (x = 2.3, y = 0.21), we can now determine the straight line.
For the remaining gases the calculation is equivalent and can be carried out in the same way. Anyone who wants to have more reading material can do this here.

Calibration of the Raspberry Pi Gas Sensor – Code

Enough of the theory – we want to use the sensor now. For this purpose you can use the code I have customized, which is located in a GitHub repository. Also included is a class for reading the MCP3008. First we clone the directory:

git clone

Then we change to the directory and run the existing Python test file.
cd Raspberry-Pi-Gas-Sensor-MQ
sudo python

The calibration is started automatically during initialization. It is important that the sensor is in good / fresh air as smoke / other gases would falsify the calibration. The process takes a few seconds, but the gas content can already be measured thereafter (see video). Some sensors are quite hot, but this should not be a cause for concern.

Mrunali Bawankar

Mrunali Bawankar