We often see traffic police using breathalyzers to check whether drivers are under the influence of alcohol when checking for drunk driving. In fact, the alcohol tester is actually very easy to make. Here is how to make a homemade alcohol tester with a 3-digit display output. Of course, after all, it is used as a simple case, so the accuracy is slightly worse.
In this article, a breath analyzer circuit using 8051 microcontroller is used which outputs the blood alcohol content (BAC) from the breath. The "percentage of alcohol content" is displayed as a percentage on the 3-digit seven-segment display. The microcontroller used is AT89S51 of 8051 series and 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 aluminum oxide 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 connection terminals are fixed on the back.
The ethanol present in the breath is oxidized to acetic acid as it passes through the heating element. This ethanol lands on the tin dioxide sensing layer, so its resistance decreases. Use an external load resistor to convert this resistance change into a suitable voltage change. MQ135
A typical connection arrangement for an alcohol sensor is as follows:
MQ135 has different resistance values at different temperatures and different gas concentrations. The manufacturer recommends 100 ppm ammonia or 50
Calibrate the sensor in ppm alcohol. The recommended value of the load resistor is between 10K and 47K.
2. Schematic diagram of alcohol tester
List of required components:
Alcohol sensor (MQ135) – 1 pc.
IC (ADC 0804) – 1 pc.
Microcontroller (AT89S51) – 1 pc.
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 to digital format using ADC0804 (IC1). The V ref/2 pin of the ADC is used by R14 and R15
The resulting voltage divider network remains at 1.28V. V ref/2 =1.28V means that the step size of the ADC is 10mV. Every time the analog input increases by 10mV, the output of the ADC will increase by one bit. See
Datasheet for the ADC0804 to get a better grasp. The digital outputs of the ADC (D0 to D7) are connected to port 1 of the microcontroller. The control signals CS, RD, WR, and INTR are respectively sent from the microcontroller
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 V in+ and V in- of the noise filter (if present) in the ADC0804 sensor output. If C3 is not used, the ADC
The digital output will be unstable. The filter capacitor certainly causes some hysteresis in the ADC response, but it is not very important in this entry-level application. Microcontroller to ADC
The digital output performs the required operations in order to convert it to "percent alcohol content" and display it on a three-digit, seven-segment display. Port 0 of the microcontroller
Connected to multiplexed three-digit seven-segment display. The three-digit driving signals are obtained from the P3.0, P3.1, and P3.2 pins of the microcontroller.
4. 8051 microcontroller 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
DB4FH
DB66H
DB 6DH
DB 7DH
DB07H
DB7FH
DB 6FH
Previous article:Design of data acquisition system with C8051F340 microcontroller as the core
Next article:How to build an Android phone controlled robot using 8051 microcontroller and Bluetooth module
Recommended ReadingLatest update time:2024-11-15 07:52
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- STC32G Series MCU Technical Reference Manual
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- RISC-V open source hardware board — HiFive Unleashed
- CY8CKIT-149 PSoC 4100S PLUS PROTOTYPING KIT Unboxing and Power-On Run Example
- How does an intelligent fully automatic multimeter measure capacitance?
- PCB current and signal integrity design
- 15th Anniversary] EE DIY (Progress) -- Upper Computer UI Changes
- 【LoRa】Common Problems in LoRa Development
- How can I include all the component libraries and package libraries used when copying the PROTEL99 project file to another computer?
- Summary of where and how DSP stores and writes data
- [ST MEMS waterproof pressure sensor LPS27HHW review] + Problems with the routine
- Qinheng CH582mesh networking