MQ3 gas sensor- alcohol-Gas & Air quality

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Dasduino and the basic code. Everything else is left to your imagination.


MQ3 is a gas sensor which reacts to alcohol (ethanol). Breakout contains everything necessary for digital and analog readings of alcohol in the air. Do not use it to check if you are able to drive!

Dimensions: 32x32x27 mm
Voltage: 5VDC
Output: digital (HIGH/LOW), analog (0-5V)

For more, check datasheet.



Basically, there is a heater which turns on by connecting a 5V voltage to Vcc and Gnd. According to the datasheet, the heater reaches the maximum of 150mA. Therefore, it would not be bad to supply the MQ3 through an external power supply. The other part of this sensor is a variable resistor. The resistance inside the sensor changes with regard to the amount of alcohol in the air, in a way that more alcohol means less resistance. Instead of measuring the resistance on the microcontroller, we shall measure the voltage on the analog pin (0-1023), so higher reading values will indicate a higher amount of alcohol in the air.


Breakout MQ3 contains voltage comparator and potentiometer for adjusting the sensitivity which enables digital readings. Readings are obtained via the digital DO pin of the MQ3 sensor. When the adjusted reading is exceeded on the potentiometer, we read LOW on the Dasduino.

// digital readings off the DO pin to D7 Croduino pin
int ulazPin = 7; // DO pin to D7 Croduino pin
int led = 13; // integrated LED on the Croduino Basic
void setup() {
  pinMode(ulazPin, INPUT);
  pinMode(led, OUTPUT);
void loop() {
  if(digitalRead(ulazPin) == LOW) {
    digitalWrite(led, HIGH); // if the breakout emits signal, turn on the LED
  else {
    digitalWrite(led, LOW); // otherwise, turn off the LED



While the sensor works perfectly for measuring relative amount of alcohol in the air, we will have to work a bit harder to get the exact readings. We have already mentioned why and how does the MQ3 send 0-5V voltage through the analog output AO. For starters, we will read off the values on the analog Dasduino pin A0 (0-1023).

void setup() {
void loop() {
  int ocitanje = analogRead(A0);

Let’s start with maths. The good thing is that based on the amount of alcohol in the air (breath) we can calculate the amount in one’s body. By the formula [%]the amount of alcohol in the blood = the amount of alcohol in the air [mg/L] * 0,21.

All we need to do is read the amount of alcohol in the breath. First, bear in mind that the MQ3’s heater must warm up in order to work properly. Also, the time between these two measurements should be about 4-5 minutes for the resistance of the sensor to come to the measurement resistance. If we are fine with that, we should open the datasheet to the part which says how to calibrate the sensor, and we won’t be delighted. According to it, we are supposed to bring 0.4mg of ethanol to a 1L space for the resistance of the sensor to be 200kΩ. That is, depending on the temperature and humidity of the air, from 100kΩ to 470kΩ.

Since we do not have the conditions to carry out such an experiment, another method comes to mind – correlation. Namely, we can find plenty online calculators of the amount of alcohol in the blood. For example, for scientific purposes, we drink one beer. Using the calculator we calculate the percentage of alcohol in the blood and read the analog reading on Dasduino. With a simple algorithm, we make the correlation between the two values.

For the most accurate measurements, it would be necessary to make a large number of comparisons (read: consumptions), which, unfortunately for soldered crew, will not be done. If you go into the measurements, be sure to report the results.