We all see Police using breathalyzers on drivers to check if they are under the influence of alcohol. Drink & driving is a crime in all countries. But do you know that this machine is easy to make? Here is how to DIY alcohol breathalyzer with 3 digit display output.

Alcohol Breathalyzer circuit using 8051 microcontroller (AT89S51)

This article is about a breathalyzer circuit using 8051 microcontroller which outputs the blood alcohol content (BAC) from the breath. The BAC is displayed in percentage on a 3 digit seven segment display. The microcontroller used if AT89S51 which belongs to the 8051 family and the alcohol sensor is MQ135 gas sensor from Futurelec.

MQ135 gas sensor Circuit

MQ135 is a stable and sensitive gas sensor which can detect ammonia, carbon dioxide, alcohol, smoke, nitrogen dioxide etc. The sensor consists of a tin dioxide sensitive layer inside aluminium oxide microtubes, measuring electrode and a heating element inside a tubular aluminium casing. The front end of the sensor is covered using a stainless steel net and the rear side holds the connection terminals.

The ethyl alcohol present in the breath is oxidized into acetic acid while passing over the heating element. This ethyl alcohol falls on the tin dioxide sensing layer and as a result, its resistance decreases. This resistance variation is converted into a suitable voltage variation using an external load resistor. The typical connection arrangement of an MQ135 alcohol sensor is shown below.

mq135 alcohol sensor
MQ135 alcohol sensor

MQ135 has different resistance values at different temperature and different concentration of gases. The manufacturer recommends calibrating the sensor at 100ppm of ammonia or 50ppm of alcohol. The recommended value of the load resistor is between 10K to 47K.

Circuit diagram

Breathalyzer using 8051

List of Components

  • Alcohol sensor (MQ135) – 1 nos
  • IC (ADC 0804) – 1 nos
  • Microcontroller (AT89S51) – 1 nos
  • 7 segment display – 3 nos
  • Transistor (2N2222) – 3 nos
  • Switch – 1 nos
  • Capacitor (150pF) – 1 nos
  • Capacitor (22uF/10V) – 1 nos
  • Capacitor (10uF/10V) – 3 nos
  • Resistors: 100 ohm – 11 nos, 10k – 3nos, 22k – 1 nos, 8.2k – 1 nos, 330 ohm – 1 nos

Working of Alcohol Detector circuit

The voltage output of the alcohol detector unit is converted into a digital format using the ADC0804 (IC1). The Vref/2 pin of the ADC is held at 1.28V using the voltage divider network made of R14 and R15. Vref/2 =1.28V means the step size of the ADC will be 10mV and the output of the ADC will increment by one bit for every 10mV increment in the analog input. Refer the datasheet of ADC0804 for a better grasp. Digital out of the ADC (D0 to D7)  is interfaced to Port1 of the microcontroller. Control signals CS, RD, WR, INTR are obtained from the microcontrollers P3.7, P3.6, P3.5, P3.4 pins respectively. R9 and C1 are associated with the clock circuitry of the ADC0804.

Capacitor C3 connected between Vin+ and Vin- of the ADC0804 filters of noise (if any) in the sensor output. If C3 is not used the digital output of the ADC will not be stable. This filter capacitor will surely induce some lag in the ADC response but it is not very relevant in this entry-level application. The microcontroller performs required manipulations on the ADC digital output in order to convert it into BAC % and displays it on the three digit seven segment display. Port0 of the microcontroller is interfaced to the multiplexed three digit seven segment display. The drive signals for the threes digits are obtained from the microcontroller’s P3.0, P3.1, P3.2 pins respectively.


MOV P1,#11111111B
MOV P0,#00000000B
MOV P3,#00000000B
MAIN: MOV R4,#250D
      CLR P3.7
      SETB P3.6
      CLR P3.5
      SETB P3.5
      CLR P3.7
      CLR P3.6
      MOV A,P1
      MOV R5,A
      SUBB A,#86
      JC NEXT
      SETB P3.3
      CLR PSW.7
      SUBB A,#115D
      MOV A,#00000000B
      CLR PSW.7
       MUL AB
       MOV B,#8D
       DIV AB
       MOV B,#10D
       DIV AB
       MOV R6,A
       MOV R7,B
      MOV P0,#01000000B
      CLR P3.0
      SETB P3.1
      MOV A,R6
      MOV P0,A
      CLR P3.1
      SETB P3.2
      MOV A,R7
      MOV P0,A
      CLR P3.2
         CPL A
     DB 06H
     DB 5BH
     DB 4FH
     DB 66H
     DB 6DH
     DB 7DH
     DB 07H
     DB 7FH
     DB 6FH


  • The MQ135 gas sensor requires around 5 minutes of preheating before the first use.
  • The MQ135 takes few minutes to retrace back to its normal condition after a positive test (alcohol present in the breath).
  • If there is no alcohol in the breath, the sensor output will swing back to its normal condition very fast.
  • Read these articles Interfacing seven segment display to 8051 microcontroller , Interfacing ADC to 8051 microcontroller  before attempting this project.
  • This breathalyzer circuit is just an entry level one and is not suitable for high-end applications such as law enforcement or laboratory application.
  • The logic for converting the digital output of ADC into BAC percentage was obtained using approximation techniques.


  1. pkungza1

    Why am I not later than seven segment too.

  2. I need the hex file ………..or link to hex file ……

  3. tell me how to check the output. what output should be checked on 7seg led

  4. Roopsingh

    PlZ send me alcohol detector using 8051
    Codeing&ckt diagram&report

  5. Prateek Kumar

    sir plz tell me can i use MQ 2 gas sensor instead of MQ135 ?

  6. jadhav subrav

    in the program, why the decimal value are used like b,#8d….etc, can you explain please

  7. In the program ,reg r4 is loaded with 250D,SUBB A,#86D….etc.what is the significance of these values.can you explain the pgm

  8. Iwould like to put this project for college project exibtion ..wiill u giv me infomatin of components from where to buy..??

    • You can purchase all components in any electronic shop…only mq135 you have to purchase from online..which I mentions above where to buy…

  9. Venkiteswaran T.K.

    Very good for learners and old who has nobody to teach and Explain.
    Let the goddess of learning bless the installers of these series.
    with great aspirations.

  10. Nilesh Nayi

    MQ135 gas sensor…. where to buy???

    suggest online shopping website ..

  11. the seven segment display used is common cathode display or a common anode display???? please reply

  12. rowanlwalters

    thanks for the 8051 circuits im off to wrestle wiyh them ill let you know how i got on itll take me ages because i learned electronics at college and furthered my education in the 80s we finished on microprocessors we were using the zilog 80 at the time i know and remember all the basics but work forced me to leave it alone
    so this will be a sturggle down memory lane because even at college i realised knowing the internal structure was along way off from piecing a string of codes and external sync command together

    • Hello Rowan,

      All the best with your adventure 🙂 Go ahead and let us know!

  13. how to convert these program in c language. or can u give me the program for c language? plz plz plz plz reply me. thank q.