Microcontroller Tutorials

Arduino, Raspberry Pi, PIC, Beaglebone Resources

# How to Use the MQ-3 Alcohol Sensor

The MQ-3 alcohol sensor is useful for projects that tests levels of alcohol, benzine, hexane or LPG in the air but it is most popularly used as a breathalyzer (breath analyzer) for someone who drank beer, wine or other liquor. Learn how to use this sensor in this tutorial.

### Introduction

The MQ-3 alcohol sensor is, in fact, sensitive to other gases, besides alcohol. But we found a way to determine only the alcohol levels in the air.

According to its datasheet, the MQ-3 alcohol sensor detects 25 to 500 ppm of alcohol (ethane). Here’s the graph of voltage vs. alcohol concentration:

Blood alcohol level (BAC) is normally measured in grams per deciliter (g/dL). 1 g/dL is equivalent to 10000 ppm. In the US and Canada, the minimum BAC for driving is 0.08 g/dL or 800 ppm. In most European countries, it’s 0.05 g/dL or 500 ppm.

Note that the graph was derived with a load of 4.7 kΩ. It would be difficult to replicate the results of the graph if we will be using the MQ-3 as a breathalyzer. Instead, we will be using the RS/R0 graph:

Here we see the different curves for each gas the MQ-3 can detect in a log-log plot. Rs is the resistance of the sensor at target gas while R0 is the resistance of the sensor when only 0.4 mg/L of alcohol is present in air.

#### Determining RS/R0

We can use the fact (from the graph above) that the RS/R0 ratio is a constant 60 in clean air. Also, by definition, only the RS changes when a gas is present while R0 remains constant. Therefore, if we can determine the value of RS in clean air, we can also determine R0 and ultimately RS/R0.

The MQ-3 alcohol sensor breakout board has four pins as shown:

Here’s the schematic diagram for the breakout board:

The alcohol level is readable via the AOUT pin. Since it’s a varying voltage, this pin should be connected to any of the Arduino’s or PIC’s analog pin. To use the MQ-3 alcohol sensor with the Raspberry Pi you need an external analog to digital converter.

The DOUT pin becomes high when the alcohol level exceeds a threshold value. Based on the schematic, the threshold value depends on the value of Rp which is the trimmer on the breakout board. You will need to test the device as to which BAC will trigger DOUT.

So how can we determine the RS value? If you trace the schematic, the sensor makes a voltage divider with the resistor R2:

To determine R2, we look at our board and trace the connections according to the schematic diagram. We found our board had a couple of differences in the schematic, specifically the op-am used and the number of LEDs (there were two in ours).

However, we still was able to determine the value of R2, and it was 2 kilo-ohms.

We can now use this sketch to determine the RS/R0 value of the MQ-3 sensor. Just connect the breakout board following this connection:

• VCC to 5V on Arduino
• GND to GND on Arduino
• A0 to Ao on Arduino

After running the sketch, we found that the R0 for our MQ-3 sensor is hovering around 16000.

#### RS/R0 and BAC Equation

Now that we have the value of RS in clean air, we need to determine the relationship between the RS/R0 ratio and BAC in mg/L.

The equation of a line a log-log plot is given as:

where F1, x1 and F0, x0 are two points from the line on the plot. If we only consider the alcohol line on the plot above, we can approximate the location of two points:

• F0 = 1, x0 = 0.4
• F1 = 0.2, x1 = 4

Substituting the points to the equation above:

$F(x)=(1)(\frac{x}{0.4})^{\frac{log(0.2/1)}{log(4/0.4)}} = 2.5x^{-0.699}$

We now have the relationship of RS/R0 and mg/L:

$\frac{R_{S}}{R_{0}} = 2.5mgL^{-0.699}$

Solving for mg/L:

$mgL = (0.4\frac{R_{S}}{R_{0}})^{-1.431}$

We can now use this formula to calculate the BAC in mg/L.

### Alcohol Sensor with Arduino

Now that we have the formula for BAC in mg/L in, we need to convert the result to g/dL since it is the more common unit of measurement for BAC. This is simply:

$gdL = 0.0001*mgL$

This is now the resulting Arduino sketch. Remember to replace R0 with the results obtained from the previous sketch.

Here is a video showing the results of the sketch above using isopropyl alcohol:

To create a proper alcohol sensor, I added an LCD to my setup, particularly an I2C-based LCD to reduce pin usage. I then tested the project using isopropyl alcohol and beer with 6.9% alcohol per volume. This video shows the result:

This is the sketch for the arduino breathalyzer with LCD:

## 3 thoughts on “How to Use the MQ-3 Alcohol Sensor”

1. sandeepa hasaranga perera says:

how you get this equation 0.1896*x^2 - 8.6178*x/10 + 1.0792

2. sandeepa hasaranga perera says:

how you make this equation BAC = 0.1896*ratio^2 - 8.6178*ratio/10 + 1.0792

3. sacharidis says:

How do you have the curve in the introduction and what is his formula ?
And I don't understand the relation between mg/L and RS R0 ?
what is the unit of RS and R0 ?
Thank you

This site uses Akismet to reduce spam. Learn how your comment data is processed.