Make an alcohol tester based on 8051 microcontroller
Source: InternetPublisher:赔钱虎 Keywords: Alcohol tester Updated: 2025/02/11
We often see traffic police use breathalyzers to check if drivers are under the influence of alcohol when checking for drunk driving. In fact, breathalyzers are actually very easy to make. Here is how to make a breathalyzer with a 3-digit display output. Of course, after all, it is used as a simple case, so the accuracy is a little worse.
In this article, a breathalyzer circuit using 8051 microcontroller is presented which outputs the blood alcohol content (BAC) from the breath. The “percentage of alcohol content” is displayed as a percentage on a 3-digit seven segment display. The microcontroller used is AT89S51 from the 8051 series and the alcohol sensor MQ135 gas sensor.
1. MQ135 gas sensor circuit
MQ135 is a stable and sensitive gas sensor that can detect ammonia, carbon dioxide, alcohol, smoke, nitrogen dioxide, etc. The sensor consists of a tin dioxide sensitive layer inside an alumina microtube, a measuring electrode and a heating element inside a tubular aluminum shell. The front end of the sensor is covered with a stainless steel mesh and the back side is fixed with connection terminals.
The ethanol present in the breath is oxidized to acetic acid as it passes through the heating element. This ethanol falls on the tin dioxide sensing layer, so its resistance decreases. This resistance change is converted into a suitable voltage change using an external load resistor.
A typical connection arrangement for an alcohol sensor is shown below:
MQ135 has different resistance values at different temperatures and different gas concentrations. The manufacturer recommends that the resistance value be 100 ppm of ammonia or 50
The sensor is calibrated in ppm of alcohol. The recommended value of the load resistor is between 10K and 47K.
2. Schematic diagram of alcohol tester
List of components needed:
Alcohol sensor (MQ135) – 1 pc.
IC (ADC 0804) – 1 pc.
Microcontroller (AT89S51) – 1.
7-segment display – 3 pcs.
Transistor (2N2222) – 3 pcs.
Switch – 1 pc.
Capacitor (150pF) – 1 pc.
Capacitor (22uF/10V) – 1 pc.
Capacitors (10uF/10V) – 3 pcs.
Resistors: 100 – 11 nos, 10k – 3nos, 22k – 1 nos, 8.2k – 1 nos, 330 ohm – 1
nos.
3. Working Principle of Alcohol Detector Circuit
The voltage output of the alcohol detector unit is converted into digital format using ADC0804 (IC1). The V ref/2 pin of the ADC is connected using a resistor connected by R14 and R15.
The voltage divider network is maintained at 1.28V. V ref/2 = 1.28V means that the ADC step size is 10mV, and the ADC output will increase by one bit for every 10mV increase in analog input.
The data sheet of ADC0804 is provided for better understanding. The digital outputs (D0 to D7) of ADC are connected to port 1 of microcontroller. The control signals CS, RD, WR, and INTR are respectively sent from microcontroller to MCU.
P3.7, P3.6, P3.5, P3.4 pins are obtained. R9 and C1 are related to the clock circuit of ADC0804.
Capacitor C3 is connected between Vin+ and Vin- of the noise filter (if any) in the ADC0804 sensor output. If C3 is not used, the ADC
The digital output will be unstable. This filter capacitor will definitely cause some lag in the ADC response, but it is not very important in this entry-level application.
The digital output performs the required operations in order to convert it into "Alcohol Content Percentage" and display it on the three-digit seven-segment display. Port 0 of the microcontroller
Connect to the multiplexed three-digit seven-segment display. The driving signals of the three digits are obtained from the P3.0, P3.1, and P3.2 pins of the microcontroller respectively.
4. 8051 MCU Alcohol Tester Program
ORG 00H
MOV P1,#11111111B
MOV P0,#00000000B
MOV P3,#00000000B
MOV DPTR,#LUT
MAIN: MOV R4,#250D
CLR P3.7
SETB P3.6
CLR P3.5
SETB P3.5
WAIT: JB P3.4,WAIT
CLR P3.7
CLR P3.6
MOV A,P1
MOV R5,A
SUBB A,#86
JC NEXT
SETB P3.3
CLR PSW.7
NEXT: MOV A,R5
SUBB A,#115D
JNC LABEL
MOV A,#00000000B
CLR PSW.7
LABEL: MOV B,#5D
MUL AB
MOV B,#8D
DIV AB
MOV B,#10D
DIV AB
MOV R6,A
MOV R7,B
DLOOP:SETB P3.0
MOV P0,#01000000B
ACALL DELAY
CLR P3.0
SETB P3.1
MOV A,R6
ACALL DISPLAY
MOV P0,A
ACALL DELAY
CLR P3.1
SETB P3.2
MOV A,R7
ACALL DISPLAY
MOV P0,A
ACALL DELAY
CLR P3.2
DJNZ R4,DLOOP
SJMP MAIN
DELAY: MOV R3,#255D
LABEL1: DJNZ R3,LABEL1
RET
DISPLAY: MOVC A,@A+DPTR
CPL A
RET
LUT: DB 3FH
DB 06H
DB 5BH
DB
- How to control a bidirectional DC motor using an 8051 microcontroller
- How to use 8051 microcontroller to control stepper motor?
- What is the difference between a microcontroller and a microprocessor?
- Circuit diagram of multifunctional digital clock
- How to Implement a Bipolar LED Driver Circuit Using 8051 Microcontroller
- Using PIC microcontroller to make a temperature and humidity meter
- Isolated transmit/receive loop circuit (XTR105, RCV420)
- How to use ESP8266 to design a portable air quality monitoring station
- Experiment on using 51 microcontroller to drive relay
- 815ept motherboard
- Microcontroller power-on reset circuit
- Negative voltage generation circuit diagram
- Interface circuit design of SPCE061A microcontroller and fingerprint identification module
- A microcontroller infrared asynchronous communication port circuit diagram
- Microcontroller hand washing controller circuit diagram
- The interface between DAC1231 and microcontroller 8031
- Typical circuit for connecting MAX1101 and microcontroller
- SMC62T3 microcontroller basic line connection
- Portable Breathalyzer
- Microcontroller universal digital tachometer circuit