Building an Breathalyzer with MQ-3 and Arduino

March 7, 2010

During the First Meeting of Electronic Arts in Florianópolis, we built a Breathalyzer using the Alcohol Gas Sensor MQ-3 and a Arduino Board to use in the last day of the meeting, in which we gave a party. You can see a quick video two posts below. Last days I received many emails asking for the code or how to make one, so I decided to build the sensor again, take pictures/videos and make a tutorial showing how you can make one, so here it is.


Parts Needed:

Here are some pictures from the building process:

To make the LEDs work, I have connected them in sequence using the Digital Pins 2 till 11 (ten LEDs total). Remember to use a resistor between 220Ω and 470Ω for each LED, like shown on the picture below:

To connect the sensor, you have to connect one of the H pin to +5V Supply (use an external power supply for that, it may be too much current for the arduino) and the other one to Ground.

Pin B (any of them) you connect to Ground. And the A pin (also any of them) you connect to the 100KΩ potentiometer as shown on the picture below. In the same pin where you are connecting the pin A, you need to connect a wire to the Analog/Digital Converter in Arduino, that is where you are going to read the Alcohol information.

This is a quick and easy DIY project, but if you have any problem building it, please feel free to post questions!

You can DOWNLOAD the .PDE file HERE.

And now, have a great drinking!!!

Remember, if you gonna drive, don’t drink,
but if you do, call me!!

Category: Arduino, Electronics, Engineering, Hardware


  • http://carolinabrum.com carol

    hilarious! joão, how can u be so hilarious!!
    great boys, congrat…
    1. does the beer integrate the part list?
    2. did you use fritzing to draw your schematics?

    kisses

  • http://www.danielandrade.net DanielAndrade

    @carol

    1. not beer, but Velho Barreiro (stronger 35%, soon I will add video)
    2. I used EagleCad. I tried using Fritzing, but I didn’t liked.

    :)

    • sqqqrly

      RE Fritzing: I love it. But to grow to love it, I had to get the latest beta version. It is very much improved. The version that is in most Linux repos is old.

      If you’re using the Windows version, well, there’s your first problem.

  • Pingback: DIY : Construire un ethylomètre avec un kit Arduino. | Semageek

  • Pingback: Don’t worry occifer, there is no blood in my alchohol! - Hack a Day

  • http://ion.podzone.net/Blog ioniser

    Have you done any work on converting the lvls to Alc/Vol
    eg millilitre(alcohol)/Litre(air)

  • http://phantomdev.com Tyler

    Good job on the excellent writeup.

  • http://hackedgadgets.com Alan Parekh

    Great project! I have no need for one but I could test it for you. :)

  • http://www.settorezero.com Gianni

    On the datasheet of MQ3 I’ve read that this sensor need a pre-heat time >24hours. Is really needed to preheat the sensor all this time?

  • http://www.danielandrade.net DanielAndrade

    @Gianni time > 24h is a lot!
    I’m not sure about that, I didn’t used it to make exact measurements so I can’t tell about it. :)

  • http://mooeymoomoo.blogspot.com Michael Hodgins

    Cool. I love that the Arduino can be used for projects like this.

  • http://www.settorezero.com Gianni

    @Daniel: Yes I know >24 is a lot… I suppose that this time period is to obtain most precise measurements

  • Pingback: Arduino un monde d’inventions | Aux Zamis

  • dan

    Did you use a resistor on the sensor?then what is the value of resistor?thnx!

  • http://www.danielandrade.net DanielAndrade

    @dan I used a 100KΩ Potentiometer to calibrate :)

  • dan

    what is the use of pulldown resistor at pin-A of the sensor?should i connect the port A to a resistor?thanx!

  • http://www.danielandrade.net DanielAndrade

    @dan http://en.wikipedia.org/wiki/Pull-up_resistor
    and yes, you need to connect the resistor :)

  • Pingback: Arduino Examples «

  • Alejandro

    good job. you can make the schematic of the entire assembly and post it?

  • dan

    can you pls post the schematic and all the connections to the breadboard?thanx in advance..=)

  • Jowie Jabillo

    can you explain this line of code:

    int ledLevel = map(sensorReading, 500, 1023, 0, ledCount);

    and how can we measure the electrical current from the analog input converting to digital output ???

  • ms

    could u post the complete code please? :)
    thanks a lot :)

  • Michael

    This will NOT work if wired the way you describe. Sensor pin B needs to be connected to VCC, not GND. Current needs to flow between A and B (direction does not matter). If you connect B to GND, and A to GND (through a resistor) no current flows. I have the MQ-3 and use it for similar circuits. Look at the datasheet. Just to verify, I did wire a circuit just as you describe, and of course there is no voltage at the analog input of the Arduino. Just connect B to VCC and everything will work.

    • mattgilbert

      Michael is right. Sensor pin B needs to be connected to power for this to work.

  • Pingback: Nice Electronic Hardware photos | Change The World Tech

  • Érico

    Is it possible to build the breathalyzer using the MQ-3, but not using the arduino?

    • http://www.danielandrade.net DanielAndrade

      Sure it is possible! But you will need a way to measure the voltage from the sensor some other way.

  • Pingback: Building A Breathalyzer | PyroElectro - News, Projects & Tutorials

  • Pingback: Breathalyzer | Change The World Tech

  • Guilherme Nabeyama

    Hi, how good is this breathalyzer, for how long it can measure the alcohol in blood, or this is only measure for a short period of time when the alcohol ate in the mouth?

  • geoff

    Thanks for this. Very informative, and it helped me build this fireplace breathalyzer for my Christmas party:

    http://vimeo.com/17752413

    I used the light to indicate when it was taking the reading, not display the result — but the inspiration came from your version.

  • hammy

    For people who are asking how to calibrate it or convert values to mg/L blood alchohol levels, see page 2 on this pdf http://nootropicdesign.com/projectlab/downloads/mq-3.pdf

  • http://www.danielandrade.net DanielAndrade

    @geoff Congrats!!
    @hammy Thanks for the info! :)

  • Pingback: Electronics-Lab.com Blog » Blog Archive » Arduino alcohol breath tester

  • Daniel Sousa

    Very good this project! But, how many doses of “Velho Barreiro” were necessary to test? eheheheheh….

    Daniel

  • Pingback: Electronics-Lab.com Blog » Blog Archive » Arduino based breath analyzer

  • jaclyn

    DO you have the circuit of this project?

  • http://www.danielandrade.net DanielAndrade

    @jaclyn what do you mean by that? If I have the scheme?

  • jaclyn

    Why we need to calibrate the sensor? The pin A of MQ-3 connect to port analog/digital pin 0. The potentiometer 100k one leg connect to gnd and another leg connect to analog/digital pin 0?

  • lol

    How to calibrate the sensor?

  • sailor

    i bought a Figaro TGS822 sensor, anyone use it??! there is any way to calibrate it…??!

  • omee khatri

    what a superb project…………… if even provided with brief circuit

  • http://www.danielandrade.net DanielAndrade

    @omee what do you mean by that? The circuit is there, just read the post ;)

  • Kevin Patrizio

    I am in a robotics class in highschool and I am trying to do this for a final project I was wondering if i could use any other boards other than the Arduino board?

  • Kevin Patrizio

    Is it possible to use a Propellor microcontroller?

    • http://www.danielandrade.net DanielAndrade

      Sure you can! Just modify the code

  • piyu

    how many leg does mq-3 have? 6 or 4?

  • Kevin Patrizio

    I recently built this breathalyzer to a T. The only problem I have with it is that when its turned on all the LEDS are lite. Why is this? Do I have to edit the code at all? PLEASE HELP!

  • http://www.danielandrade.net Daniel Andrade

    @Kevin you have to calibrate it with the potentiometer :)

  • Ian

    Great tutorial guys. This helps loads for my final project.

    I just have one question about the wiring in this picture http://img.photobucket.com/albums/v107/tigerbr/MQ-3.gif

    Is there any way to tell which side is A and which is B? Or can it work either way?

  • http://www.danielandrade.net DanielAndrade

    @Ian you can check that there is a difference between A side and B side just looking! :)

  • Pingback: Freeduino + Workshop Kit + Ethernet Shield = Ethylomètre on web ! | Blog de Yohann Lepage

  • Alex

    What type of arduino board did you use for the proejct could you direct me to the exact model number?

  • IShan

    Can u give me a link to ur schematic or circuit diagram about ur project cz i m facing a problem regarding my circuit…
    thx in Advance

  • http://www.danielandrade.net DanielAndrade

    @Ishan you can make your own schematic looking in the datasheet http://www.sparkfun.com/datasheets/Sensors/MQ-3.pdf

    @Alex You can use any arduino board, i used the 2009. http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove

  • gokul

    How can we take the output from the ardiuino board to some other application other than the ‘serial monitor’ in the arduino s/w?? we are tryin to develop an electronic nose using artificial neural nw, so we hav to get d o/p in analog form… also the sensor is always showing some values even if we remov it frm ‘alchoholic air’…
    do help me
    thanx!!

  • Levi

    How should the potentiometer be wired? Should it be connected to my A0 analog port??

  • Pingback: Quora

  • Pingback: MQ3 | Materials Find

  • Pingback: Arduino 101 | Widgeting

  • Guilherme

    Tentei reproduzir o projeto usando o mesmo esquema é o Arduino Mega 2650, mas o sensor MQ-3 retorna apenas o valor 0 (zero), mesmo quando há presença de alchool. O que está errado? Como posso identificar o problema?

  • http://gmail Austin Mathew Dilip P

    Sir you could have shown the complete circuit diagram along with procedure

  • http://gmail Austin Mathew Dilip P

    Sir you could have given the circuit diagram along with procedure. Next day after posting this comment could you please show the daigram

  • http://gmail Austin Mathew Dilip P

    Could you show the circuit diagram

  • http://www.danielandrade.net/2010/03/07/building-an-breathalyzer-with-mq-3-and-arduino/?& Brendan

    I ran across your blog, i believe your web site is awsome, keep writing.

  • Mike Patton

    Are you still active in answering questions for this project? Or are you tired of it? Ha
    I have what appears to be a common question that I still can’t seem to understand.

    I have the whole circuit built. The potentiometer part I still can’t dem to get right. Or I need to know its right so I can rule it out as my current problem.

    I am realatitvly new to all this, but I have built my own projects in the past

    Let’s please keep it in simpliest terms for everyone.

    100k pot has three legs. One SIDE leg goes to ground. The CENTER leg goes to analog input A0. The OTHER SIDE leg goes to MQ-3 pin A.

    Can you please confirm or correct. Thank you very much!

  • Pingback: Getting Started with Breathalyzer « Rob Faludi

  • Rob Gleason

    Hey guys this is an awesome project and I am interested in doing the same for a biomed electronics project. Anyway you could e-mail me a parts list and any pointers? Thanks alot!

  • Pingback: GAS SENSOR « carbonitp

  • Hendrik Roedel

    do i have to use the mq-3 or can i use everey gas sensor i want?

    great work btw ;)

  • Dorin

    Hi Daniel,

    did you connect all 6 pins from sensor to the Arduino or only 4 of them ? What value did you used for load resistence ?
    The detection concentration scope of your sensor was 0.05 to 10 mg/L of alcohol or 0.04 to 4 mg/L of alcohol ? I ask you this because I have found on Internet 2 differnts datasheets…

    Thanks

  • Dorin

    Or did you connected like in the link below???

    http://wiring.org.co/learning/basics/airqualitymq135.html

    • http://www.danielandrade.net DanielAndrade

      Yeah, I just used 4 pins! Because the two A are the same.

  • Chris

    Hi, would you happen to have a schematic of this project? This project looks exciting and I am just getting involved with Arduino so a lot of the terminology I am still getting familiar with.

    • http://www.danielandrade.net DanielAndrade

      What do you mean what happened?
      The schematic is fine, it doesnt show it all.

      Anything I can help you

  • Chris

    Hi Daniel,
    The schematic is great. Just being as though I am new to this… I can’t see how everything is connected via the photos. Like I see multiple wires going into the (-) negative section but I don’t see in the diagrams what is connected in (-). I’m guessing because I don’t know how to read the schematic being as though I’m just starting off.

  • http://www.danielandrade.net/2010/03/07/building-an-breathalyzer-with-mq-3-and-arduino/ calvin

    hi daniel
    awesome work!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    i am new and cant understand by the photo pls give a video or something showing how to connect pppppllllllllllllllllsssssssssss
    help me plsplsplsplsplspls

  • http://www.danielandrade.net/2010/03/07/building-an-breathalyzer-with-mq-3-and-arduino/ calvin

    i have only 1 week left for the exhibition
    and can u show me how to take the reading digitally or by computer

  • http://UniversityofSunderland Nicholas

    Hi, there im currently doing a final year project about MQ-3 Sensor, so by just measuring the resistance drop on the load resistor, we will be able to know the concentration of the alchohol? as in ppm? Im totally confused, can anyone help to explain this? what does the graph in the datasheet refers to? How do i measure the concentration of gas?

  • MATEO RAMIREZ

    HELLO!! CAN YOU POST FURTHER INFO ON HOW TO CONNECT THE 100 OHM RESISTOR, IM HAVING TRIUBLE READING THE VALUES FROM THE SENSOR

  • sudip neupane

    would you please explain the working principle ? i think it will be quite helpful for my final year project.

  • brian

    i have made it,,but the sensor is tgs2620..and i can’t calibrating the sensor,,can you help me? simulating by proteus..please send your project in my email,,[email protected]

  • Pingback: Building an Breathalyzer with MQ-3 and Arduino - Arduino for ProjectsArduino for Projects

  • João Miguel Correia

    boas, qual é o código usado, apenas para receber e enviar para o ecra (como os valores certos de alcool no ar)

    • http://www.danielandrade.net DanielAndrade

      é simplesmente o int sensorReading = analogRead(analogPin);

  • Julian

    Is the pull down resistor the potentiometer?how do you connect the potentiometer?Urgently need to hear from you =)

    • Julian

      one more thing..how can i calibrate the sensor using a potentiometer? am still new to these kind of stuff

  • Romeo Coreas

    el sketch tiene un error tiene el numero de led’s al revés tiene que comenzar del 2 al 11

  • Lucinda Bel

    Hi,
    I am a third year student, and i have my project abt how to prevent drink driving. Basically my professor last minute he asked me to build a breathalyzer and your work is very good. I had some questions if it’s ok?!
    1. Is it ok to use arduino uno board?
    2. the LEDs are connected to 330ohm resistors right?!
    3. The sensor has 4legs so there are connected to the board and the potentiometer right?!
    Thank you
    :) x

  • Lucinda Bel

    hi, I have one more question if it is ok; what is the output of this breathalyzer? i need to connect the output to a car simulation but i couldn’t find it and besides i am having short circuit for no reason.
    Thx

  • Lucinda Bel

    And the connection from the arduino to the LEDs please
    thx

  • Siddharth

    Hello..I’m building Alcohol Sensor for my university project but I have to use an mbed instead of audrino and show the results on a LCD display. Can you please guide me how the circuit diagram will look? Thanks

    • http://www.danielandrade.net dansku

      Hi, I don’t know how is the mbed circuit.

  • rossi

    Hey Daniel,
    I was really excited about your project, so i decided to use the idea for part of my thesis by adding lcd and buzzer and stuff. I want to use a potentiometer for calibrating my sensor, but its a bit confusing for me with the mq3 “useless” legs. Could you please send me the schematic by email, because I didn’t find it in the comment section :( ? Thanks in advance!

    • http://www.danielandrade.net dansku

      Like it’s said on the pos, you connect the pin B to ground and the A to the AnalogPic that connects to one leg of the potentiometer.

  • Alexa Mejia

    hi I am using this idea as a project but am a little confused on the connections. I already calibrated the sensor the 24 hours as requested so I don’t know if I still need the potentiometer in my circuit. Also I was wondering if you could upload a better picture of how you connected your wires since we can’t really see it very well. I also wanted to know if that is all the code or if it’s only part of it. Iwould appreciate your help so much I have hard time with circuits and I need a lot of help. When I make all the connections all the lights blink.

  • turw

    Hi, i’m newer in the arduino use. I’m interested to the alcohol meter. i want to use it to calculate the amount of the air for my experiment. if i have a continuious air + alcohol stream it’s possible to use the same connection. what can i do if i would use a concentartion of alcohol between 0 and 6 %
    thanks

  • Rusphil Francisco

    how can i put the LCD display in this project and what will be the program help me please!

    • Rusphil Francisco

      thanks!

  • Rusphil Francisco

    can i use mq2 sensor instead?

    • Daniel Andrade

      MQ-2 is a Combustible Gas Sensor, SnO2, so if you want to make a breathalyzer I would say no. But you can make a SnO2 sensor.

      • Rusphil Francisco

        mq303?

        • Daniel Andrade

          Try looking it’s datasheet!

  • Rusphil Francisco

    well you don’t use the LM7805 in here? where did you get the supply?

  • Rusphil Francisco

    what if i use mq303 ?how will i connect it? it has 3 pins,

  • Rusphil Francisco

    why is not working?

    • Daniel Andrade

      Show me the code!

      • Rusphil Francisco

        it just use ur code but using mq303 it has 3 pins, the 2 is i connected to the A0 and the 1 is grnd and 3 is +5v. i just change the sensor by mq303

  • Alexa Mejia

    hi i had a question what does this part of the code for and what do the numbers stand for
    int ledLevel = map(sensorReading, 500, 1023, 0, ledCount

    also im trying to get the BAC percentage with a seven segment display how would i do it

  • Pingback: Nice Hardware Components photos – TECH TALK KING

  • Pingback: Measure Who’s the Drunkest (+ Avoid DUIs) with a DIY Arduino Breathalyer - Science & Tech | Tech wikiHow

  • Pingback: ALCOHOL GAS SENSOR MQ-3 | Arduino

  • kserkses

    Hi. How to read values from MQ-3? Or this code above is enough?

    • http://www.danielandrade.net/ Daniel Spillere Andrade

      That should be enough! :)

      • kserkses

        another question ;)
        Red led light is on faster than green, because green LED shines very poorly.
        How to fix it?

  • kserkses

    another question ;)
    Red led light is on faster than green, because green LED shines very poorly.
    How to fix it?

  • Tristan Novak

    Hello, I am looking at the power consumption of this sensor. The heater will draw about 150mA max. My Arduino has a UA78M05 regulator, which can supply 500mA max. Therefore, if I don’t interface with too many other things, I should be able to power this from my Arduino, right?

  • Thomas Boyer

    Hello, I was just wondering, can we do this on a raspberry ?

  • nithin poovanna

    hi,i wanted to know whats the output of the MQ-3 sensor ,what does the 500-1023 range specify exactly ,what values are those?does it provide the output in millivolts or is it the BAC values ?