MQ-3 alcohol sensor with Arduino

FunduinoPublished on

Alkohol in der Luft erfassen und mit zwei LEDs anzeigen

Der MQ-3 gehört zur Familie der MQ-Gassensoren und reagiert vor allem auf Ethanol – den Alkohol, der auch in Desinfektionsmitteln und Getränken steckt. Je mehr davon in der Luft liegt, desto höher der Wert, den er ausgibt.

In dieser Anleitung liest du den Sensor am Arduino aus, bestimmst deinen eigenen Frischluft-Referenzwert und baust daraus eine Anzeige aus einer roten und einer grünen LED.

Back of the MQ-3 sensor module with blue potentiometer
Back of the MQ-3: Use the potentiometer to set the threshold for the digital output.

You need this

MQ-3 alcohol sensor - 0.04-4 mg/L, analog output, 5 V MQ-3 alcohol sensor - 0.04-4 mg/L, analog output, 5 V 2,70 € *Item no. F23106855About the product — MQ-3 alcohol sensor - 0.04-4 mg/L, analog output, 5 V
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino 11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
Breadboard cables male-female - 40 pieces, 20 cm Breadboard cables male-female - 40 pieces, 20 cm 1,74 € *Item no. FUN-1010554About the product — Breadboard cables male-female - 40 pieces, 20 cm

All 3 parts together 15,56 € *Ready to ship immediately · Delivery time: 1-3 business days

* All prices include statutory VAT, plus shipping costs.

Material

You need the following for this project:

  • 1× microcontroller with a compatible USB cable
  • 1× MQ-3 alcohol sensor
  • Male-to-female jumper wires

For the display, add the following in the final step:

  • 1× red LED and 1× green LED
  • 2× 220-ohm resistors
  • 1× breadboard

The connections of the MQ-3

The MQ-3 detects the concentration of alcohol - more precisely, ethanol - in the air and outputs it as an analog value. The module has four connections:

  • VCC - power supply, connect to the Arduino's 5V pin
  • GND - connect to a GND pin on the Arduino
  • A0 - analog output, connect to pin A0 on the Arduino
  • D0 - digital output, which only indicates whether a threshold has been exceeded

For this guide, you only need VCC, GND, and A0. Set the threshold for the digital output mechanically using the potentiometer on the back of the module.

Do not connect D0 to Arduino pin 0. Pin 0, together with pin 1, belongs to the serial interface, which is also used to upload the sketch. If you want to use the digital output, use a free pin for this, such as pin 2.

Back of the MQ-3 sensor module with blue potentiometer
Back of the MQ-3: Use the potentiometer to set the threshold for the digital output.

Burn in the sensor and determine the reference value

Like all sensors in the MQ series, the MQ-3 also operates with a heated element. A brand-new module therefore only provides stable readings after a lengthy burn-in period - ideally, leave it connected to the power supply continuously for 24 to 48 hours.

Then determine your reference value: Let the sensor run in fresh air for a few minutes and note the reading it shows. In our setup, it was around 100 - yours may be significantly different.

The sensor element becomes noticeably warm during operation. This is normal.

Important: The MQ-3 is a DIY component, not a calibrated measuring instrument. It reacts to ethanol in the air but does not measure breath alcohol concentration. It is unsuitable as a breathalyzer or for assessing fitness to drive.

Read sensor value

Upload the sketch to the microcontroller and open the Serial Monitor at 9600 baud. The current reading will appear there twice per second.

To try it out, just hold a cotton swab with a little disinfectant or an open glass containing an alcoholic liquid near the sensor - the reading will then increase significantly.

Sketch 1: Read sensor value
int Wert;

void setup()
{
  Serial.begin(9600);   // Diese Baudrate muss auch im Seriellen Monitor eingestellt sein.
}

void loop()
{
  // Der analoge Sensorwert wird am Pin A0 ausgelesen.
  Wert = analogRead(A0);

  Serial.print("Alkoholwert: ");
  Serial.println(Wert);

  delay(500);
}

Display with two LEDs

Using the reference value from step 3, you’ll now build a simple indicator. Expand the setup with two LEDs, each with a 220-ohm resistor: the red LED on pin 12, the green one on pin 13.

If the measured value is above the reference value, the red LED lights up. If it’s below, the green LED lights up.

The threshold of 100 matches our fresh-air reading. If your own reading is higher or lower, enter it in the sketch - otherwise the same LED will always light up.

Sketch 2: Display with two LEDs
int Wert;
int LEDgruen = 13;   // Die gruene LED wird mit Pin 13 verbunden
int LEDrot = 12;     // Die rote LED wird mit Pin 12 verbunden

void setup()
{
  Serial.begin(9600);
  pinMode(LEDgruen, OUTPUT);
  pinMode(LEDrot, OUTPUT);
}

void loop()
{
  Wert = analogRead(A0);

  Serial.print("Alkoholwert: ");
  Serial.println(Wert);

  // Liegt der Wert ueber dem Referenzwert, leuchtet Rot,
  // andernfalls Gruen. Der Wert 100 ist ein Beispiel -
  // trage hier deinen eigenen Frischluftwert ein.
  if (Wert > 100)
  {
    digitalWrite(LEDrot, HIGH);
    digitalWrite(LEDgruen, LOW);
  }
  else
  {
    digitalWrite(LEDrot, LOW);
    digitalWrite(LEDgruen, HIGH);
  }

  delay(500);
}
Rate the instructions

Comments

Ask a question or share an experience

Contact us if something doesn’t work. Please include your board and the error message.

We review every comment before publication. Your email address remains with us.