Advisor: Tao Zhang

Download 96.33 Kb.
Size96.33 Kb.
Project Report
Alcohol Detecting System


Advisor: Tao Zhang

Member: Haotian Kong, Rui Xue, And Ji Dai

May 13, 2013
Table of Contents

  1. Introduction ………………………………………………… 3-4

    1. Background ………………………………………………... 3

    2. Motivation ………………………………………………………...… 3

    3. Objective ……………………………………………………………… 3

  2. Design Approach ………………………………………….…. 4-5

  3. Key factors on the research ………………………….…………...5-9

    1. Influence of alcohol on human ……………………..………….....5-6

    2. Alcohol Concentration change in weight…………………………..6-8

    3. The time after one drank ……………….………………….…….8

    4. Law of different countries ………………………….…………………..9

  4. Hardware ……………………………………………………...…9-14

    1. MQ3-sensor ………..………………………….…………………….....9-11

    2. Arduino Mega …………………………………………………….12-13

    3. BlueSmirf Silver Module ………………………….…………………13-14

  5. Software……………………………….…………..……………15-18

5.1 Software part—Arduino software ……..……………….………………….15-16

5.2 Android Programming ……………………………..……………….…..16-18

  1. Project Demonstration …………………………………………..19-20

  2. Future Plan ………………………………………………...20-22

  3. Cost …………………………………………………………22

  4. Summary …………………………………………………....22

  5. References and Attachments ………………………………….…23-29


    1. Background

Drunk driving is a very dangerous behavior. People will become slow in reacting and can’t control their actions. Drunk drivers’ aren’t able to deal with the emergency situations when they are driving. The investigation done by the World Health Organization in 2008 shows that about 50%-60% of traffic accidents are related to drunk driving. The drunk driving has been listed as the main reason for the fatal car accident.

    1. Motivation

These years, the cases of traffic accident caused by drunk driving have increased rapidly. More and more people have realized that the drunk driving does great harm to public security. It’s time to develop a kind of system which can stop the drunk driving effectively. As this kind of system hasn’t been popularized, we try to develop this system which is available on every car. This system won’t cost much, but it will bring much for it concentrates on human’s safety. This system has a preventative effect which can stop accidents from the beginning.

    1. Objective

We want to design a kind of system which can detect the alcohol concentration in the cars to prevent the behavior of drunk driving. The system consists of these parts:

  1. Sensor Part--used to detect the concentration of alcohol in the air and send the concentration in the form of voltage signals to the following part.

  2. Processing Part—used to receive the voltage signals and process the signal to analog signals that can be standard for the concentration of alcohol.

  3. Display Part—used to get the processed signal and show the data to users in the form of diagrams.

The sensor will be fixed near the driver’s seat. The driver should breath to the system before he (she) starting the car. If the concentration of alcohol detected is below the allowable standard, the car can be started normally. If the concentration of alcohol is above the allowable standard, the system will send alarm to the driver. The concentration of the alcohol will be showed in diagrams which can be seen on the driver’s cellphone.

The system should be safe, sensitive, accurate, convenient and cheap. This kind of system can be fixed on every car to ensure the driver’s driving safety and can protect the passengers’ walking safety.


The following block diagram shows the sketch how we design the system.

Figure 1.flow chart of Alcohol detecting system

The flow chart above shows the main structure of the alcohol detecting system. From this chart we can briefly know the components we have used and how to connect them. Here is the introduction of the usage of each component:

  1. MQ-3 alcohol sensor: This sensor can detect the value of the alcohol concentration in the air and transform this value to voltage signals. The sensor should be powered and the pin on the sensor which is used to send out the voltage signals should be connected with the analog-in pin on the Arduino board. 

  2. Arduino board: We chooses the Arduino Mega ADK as the developing board for it has more pins and has more advanced chip with more flash memory which can reach almost all of our requirements in the research period. With the help of Arduino board, we can transform the uncountable voltage signals to countable analog signals which range from 0 to 1023. The operating voltage is 5V. So the real voltage of the input voltage is:  (Output analog value/1024)*5V.  After the Arduino board has completed the data processing part, it would send the signals to the cellphone with the help of Bluetooth module. 

  3. Bluetooth module: Bluetooth module can help the system reach wireless connection. This means we needn't take pains to try to connect the cellphone with Arduino board by cockamamie wires. This design can let the system become more humanized.

  4. Android phone: Smart phone is a wide platform for developers to design applications. We have designed an application that can let the value of alcohol concentration showed in visual diagrams instead of analog signals. And because the cellphone is a good medium that can contact with others by messages or the Internet, the statistics can be shared easily.


—Blood Alcohol Concentration

3.1 Influence of alcohol on human

Alcohol will influence human’s behavior. One drinks more, one would be dizzier. Terrible traffic would occur because of drunk driving. From the chart blows, we can see the influence of alcohol on human behavior in details.

0.02 — 0.03 BAC: No loss of coordination, slight euphoria and loss of shyness. Depressant effects are not apparent. Mildly relaxed and maybe a little lightheaded.

0.04 — 0.06 BAC: Feeling of well-being, relaxation, lower inhibitions, sensation of warmth. Euphoria. Some minor impairment of reasoning and memory, lowering of caution. Your behavior may become exaggerated and emotions intensified (Good emotions are better, bad emotions are worse)
0.07 — 0.09 BAC: Slight impairment of balance, speech, vision, reaction time, and hearing. Euphoria. Judgment and self-control are reduced, and caution, reason and memory are impaired (in some*states .08 is legally impaired and it is illegal to drive at this level). You will probably believe that you are functioning better than you really are. 
0.10 — 0.125 BAC: Significant impairment of motor coordination and loss of good judgment. Speech may be slurred; balance, vision, reaction time and hearing will be impaired. Euphoria. It is illegal to operate a motor vehicle at this level of intoxication in all states.
0.13 — 0.15 BAC: Gross motor impairment and lack of physical control. Blurred vision and major loss of balance. Euphoria is reduced and dysphoria is beginning to appear. Judgment and perception are severely impaired.
0.16 — 0.19 BAC: Dysphoria predominates, nausea may appear. The drinker has the appearance of a "sloppy drunk."
0.20 BAC: Feeling dazed/confused or otherwise disoriented. May need help to stand/walk. If you injure yourself you may not feel the pain. Some people have nausea and vomiting at this level. The gag reflex is impaired and you can choke if you do vomit. Blackouts are likely at this level so you may not remember what has happened.
0.25 BAC: All mental, physical and sensory functions are severely impaired. Increasing risk of asphyxiation from choking on vomit will seriously injure you by falling or other accidents.
0.30 BAC: STUPOR. You have little comprehension of where you are. You may pass out suddenly and be difficult to awaken.
0.35 BAC: Coma is possible. This is the level of surgical anesthesia.
0.40 BAC and up: Onset of coma, and possible death due to respiratory arrest.

In sum, alcohol will negatively affect your behavior. The more you drink, you will be more easy to be wild.

3.2 Alcohol Concentration change in weight

There are far variables involved to accurately estimate or predict a person’s BAC simply based on gender. The data is so important for us to build a accurate project design.


Figure 17.Concentration of alcohol vs. consume number and weight-men


Figure 18.Concentration of alcohol vs. consume number and weight-women

The drink chart displayed above provides a rough estimate of a person's blood alcohol level (BAC). it is based on the number of drinks consumed and the person's weight. The red number in men chart shows you cannot drive in such a concentration. The purple number in women chart means you have out of control and driving skills have been significantly affected. The bigger you are, the more difficult you will get drunk. Our design is open to all people, so we consider the weight into account.

3.3 The time after one drank

As the following figure19, it’s also an important factor for calculating the concentration of alcohol in one’s body. From the chart above we find the relationship versus the weight and the consumed number. One will get lower concentration of alcohol as time passes, which will affect the measurement of our system. Based on the chart, we calculate the relationship between the concentrations of alcohol and the time after you drank.

Figure 19. Hours to zero BAC for men and women

3.4 Law of different countries


Figure 20. Different standard among different countries

The standard of legitimate centration of alcohol before driving is different among different countries. If one is from the USA and one is from China, they will under different it’s also an important factor. After our calculation, we find, for Chinese, if the display is larger than 75, our system will make an alarm.(for USA:140,for Canada:104)

    1. MQ3-sensor

4.1.1 Introduction of MQ3

In this sensor, there’s a little white tube in the middle of sensor. Basically, this tube is a heating system that is made of aluminum oxide and tin dioxide and inside of it there are heater coils, which practically produce the heat. And you can also find 6 pins. 2 pins that I called Pin H are connected to the heater coils and the other ones are connected to the tube.

The core system is the cube. As you can see in this cross-sectional view, basically, it is an Alumina tube cover by SnO2, which is tin dioxide. And between them there is an Aurum electrode, the black one. And also you can see how the wires are connected. Basically, the alumina tube and the coils are the heating system, the yellow, brown parts and the coils in the figure2

Figure 2. Inside the sensor

The MQ-3 is an alcohol gas sensor that is available for about $5 from sparkfun. It’s easy to use and has sparked the imagination of anyone who has dreamed of building their own Breathalyzer device for measuring the amount of alcohol in the human body. We got five MQ-3 sensors a couple of months ago and have spent a lot of time trying to figure out how to do this. After lots of “data gathering”, we found that this task is not as easy as it sounds.

4.1.2 Circuit of sensor connection of MQ3

As shown in Figure3, The other part of the circuit is essentially a variable resistor inside the sensor. The resistance across an A pins and a B pin varies depending on how much alcohol is in the air in the sensor. The more alcohol, the lower the resistance is. We measure alcohol in the breath by measuring this resistance. Instead of measuring the resistance directly, we measure the voltage level at the point between the sensor and a load resistor.

First, we use 5v. And as you can see one of H pins goes to the power and the other one is connected to the ground. And the pin A is connected between the power and the pin H and the pin B is goes to the microcontroller. Also between the ground and the Arduino, you need the resistor. Before you connect the resistor if you use the pot, you can tune the resistor for getting more accurate values. In the datasheet they say you can used 100k om to 470k om. So we use 220k om in our circuit.

It will react that depending on the environment, it gives us little bit of different values. But in our experiment, it gives me 200 as the lowest value and 700 as the highest value. And when it detects the alcohol in the air, actually it is pretty sensitive, the value gets higher very quickly but you have to wait for about 10 seconds to reset it. So that means getting values is fast. And the sensitivity of this sensor is affected by time span. When I used three different sensors, the range of value was a little smaller than the new one's. But it doesn’t affect the whole experiment.

4.1.3 Reaction Theory of MQ3

SnO2 ceramics will become the semi - conductor, so there are more movable electrons, which means that it is ready to make more current flow.

Then, when the alcohol molecules in the air meet the electrode that is between alumina and tin dioxide, ethanol burns into acetic acid then more current is produced. So the more alcohol molecules there are, the more current we will get. Because of this current change, we get the different values from the sensor.

4.1.4 Detail of Sensor Connection

As the figure 4 shown, We put the H (left) connect the 5.0V and H (right) to the ground (GND). We can choose either A or B as one of the analogin pin to connect the Arduino board. And use another one, B or A, just opposite to the former one, we can only use 4 of 6 pins in the project.

4.2 Arduino Board

4.2.1 Introduction of Arduino mega

Arduino Mega2560 microcontroller board is an easy-to-use development board based on the Atmel ATmega2560 MCU. The ATmega2560 has 256 KB of flash memory for storing code (of which 8 KB is used for the bootloader), 8 KB of SRAM, and 4 KB of EEPROM. The Arduino Mega2560 microcontroller board has 54 digital input/output pins (of which 14 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. The Arduino Mega2560 contains everything needed to support the MCU. Simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. This Arduino development board is compatible with most shields designed for the Arduino Duemilanove or Diecimila. The Arduino Mega2560 differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega8U2 programmed as a USB-to-serial converter. The Arduino MCU board includes a number of facilities for communicating with a computer, another Arduino, or other MCUs.

4.2.2 Sampling rate in the Design

Delay() is a key function to arrange the frequency of reading in the while loop.

Once the loop starts, the analogRead() function will sample the data from sensor and by delay(100) function, delay 100ms, then next sample data comes in.

In our project, we use the analogread() in the arduino, the Arduino board contains a 16 channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. It will map input voltages between 0 and 5 volts into integer values between 0 and 1023. It gives us readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. The input range and resolution can be changed using analogReference().

It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second. It returns int (0 to 1023).

4.3 Bluetooth Silver Module

The baud rate is quite important to be set in Arduino code part. At the first, we use the blue tooth module to test, the baud rate we set is 9600, that is suitable for the connection. But when using Bluetooth silver module, the baud rate should be 115200 .

Here’s the Connection the bluesmirf silver Bluetooth, as shown in the figure 6. There’re 6 pins in the Bluetooth Silver Module, we use the middle of them, the sequence is VCC, GND, TX and RX, TX and RX means the transmit port and receive port which should be connect to the receive port and transmit port in the arduino board.

As the following figure 7 and figure 8, BlueSmirf Bluetooth Module should have 115200 baud rate which should modify before we use it. When the BlueSmirf Bluetooth Module paired with your device, the green light is on. The picture Figure 7, shows the baud rate in the arduino code, the figure 8, shows the reading board in the computer.

5. Software part

5.1 setting of environment

5.1.1 Arduino software

It is the most complicated part of this experiment. We get the detailed tutorial from There’re four kinds of operating system for you to choose. Basically, the software helps us input the code into the arduino board, which shows the corresponding alcohol reading result of MQ3 (sensor).

As shown in figure 9, after placing the folder into the libraries folder, we should be able to access all the amarino files through the arduino programming environment and then open the code in arduino board.

Figure 9: SensorGraph code in Arduino

5.1.2 Installing Amarino

We download the following applications on your mobile phone

  1.  Amarino – Android Application- to be installed on phone.

  2. Amarino Plug-in Bundle- to be installed on phone.

  3. Amarino Library- To be kept in Java Project

5.1.3 Eclipse and ADT

It is the most complicated part of this experiment. The basic idea is to Install the Eclipse first (follow the system requirements), then install the android SDK, then install ADT plugin for Eclipse IDE. Codes still need to be changed to realize the function and is shown in the end of the manual.

5.2 Android Part

5.2.1 Structure of Android programming

Android programming based on the Java SE platform, we design the project as seven parts, Alarm, Amarino, AmarinoIntent, Country, GraphView, SensorGraph and StartingPart.

Figure 11. The brief structure in Android programming

The and, we set these activities to let the user choose the country they have to fit the different criteria the application has. As you can see in the following picture:

When you want to arrange the sequences of your activities (it’s the name of android interface), it should be set in the AndroidManifest.xml, that’s the different between Java and Android.

And In order to let the become the first, we should press the following code, let the inside the first activity we want to show to the user.

Then the and shows the actual diagram can show to the user,

Finally, we set the criteria as 500 to alarm because it can show you the brief change in each time. Once the reading touches 500, it will alarm at once.

Then open the apk file and install the application “alcohol detection” into smart phone. We use the Samsung S1 GT-I9100 android version is 4.2.2, processor is ARmv7 Processor rev 1(v71).

5.2.2 Problems in software design

  1. In the code part, in order to make the activity act like a window, not extend the whole screen, we can set the androidManifest.xml as /theme.Dialog.

Figure 15. Theme.Dialog in xml file

  1. When we use the application in virtual smart phone, it may show us the error process, as shown in the figure 16.

  2. We should check the androidManifest.xml to make sure that each activity has settled already.

  3. Layout is a very important part in android design, the label and arrangement of buttons and texts are all depend on these file, when we set the function in activity, we should set the corresponding part in Layout, and then, it will yield the ID in the “R.class” in Gen fold. And during the programming, R.class will disappear automatically, then we found if you have unlogical code in layout.xml, it can be done.


Figure 21. Alcohol detecting system

From the demonstration we can see that our alcohol detecting system has the following advantages:

  1. The materials are cheap and are easy to acquire. The cost of this system is one of the important factors we are considering. Because if we want to popularize this system, we should make it as cheap as possible so that every driver can afford of this useful system.

  2. It doesn’t some large measuring instruments which mean it can be made small enough and can be put into production without any challenging technological problems.

  3. We used the Bluetooth module. It can realize the wireless communication. It is a significant design because we can use the smart phone to receive the signals and do further designs.

  4. Smart phone is a wide platform for us to design more humanized applications to fulfill user’s requirements. In our system, we have transformed the abstract analog signals to visual diagrams. And the smart phone will send alarm to users when the alcohol concentration reaches a certain value.

  5. We can also share the value of alcohol concentration from the drivers to their relatives, friends or the police. Because the data can be showed on cellphones, we can send the date by the Internet or message.


These are what we have done up to now. In the future, we will:

    1. Try to reduce the cost of the system when it can be made as a product.

This is a system that can be used in everyday life for everyone. So users must be concerned with the cost of the alcohol detection system. The cheaper it is, the more chance it will be popularized. Because our system is in the period of experiment and design, the cost may be higher than the modified products. We are using Arduino Mega ADK as the developing board. It is expensive because it is appropriate for us to learn how to use developing board and is convenient to connect the wires with the sensor and the Bluetooth module. In future, we can design a printed circuit board to simplify the circuit and use a small chip instead of the developing board. Based on the technology of manufacture nowadays, the total cost of a finished product will be less than $20. This price is low enough which almost every driver can afford of this system.

    1. Make it small enough and more convenient to use.

The smaller and more convenient the alcohol detection system is, the more likely drivers will accept it. Up to now we have come up with several options to place it on the car:

  1. The first option is that we can set it on the keychain, the system is as small as a key and the driver can blow it directly. So the drivers won’t take pains to refit the car.

  2. Another option is that we can put a cable near the driver’s seat and the cable is connected with the ignition of the car. This means the alcohol detection system can be another key to the car. The driver should blow to the system before he/she start the car. If the value of the alcohol concentration is above a certain value, the system will stop the car starting. So a drunk driver won’t be able to start the car which will prevent the behavior of drunk driving. It is not only safe to the driver, but can ensure the passengers won’t be hit because of the driver’s drunk driving.

c:\users\xue rui\pictures\alcohol detecting system\in-car-alcohol-detection-systems.jpg

Figure 22. Connect with car ignition

  1. We can also design it as a plug-in unit. It can be plugged with a cellphone or on the console of the car. This design can ensure a tiny size of the system. And the system can be used as an USB stick that means the data can be stored in it and we can plug it with relevant terminal to do more calculations.

c:\users\xue rui\pictures\alcohol detecting system\ipega-digital-breath-alcohol-tester-for-apple-devices-black-p35617-300.jpg

Figure 23. Plug the iphone

  1. Fixing the alcohol detection system on the driver’s seat is also a wise choice. Because the sensor near the seat can detect the driver’s breathe alcohol concentration easily and the driver won’t take pains to blow to any system intentionally.

c:\users\xue rui\pictures\alcohol detecting system\passive-alcohol-detector.jpg

Figure 24. Fix on the back

7.3 Improve its efficiency and accuracy to let it become more reliable.

Whether the system is accurate and sensitive can affect whether the users are satisfied with it. Our system should tell the drivers the real alcohol concentration and whether they can control their driving skill after they have drunk some wines. Our system shouldn’t bring trouble to the users. Such as the system sends alarm continually and can’t be stopped.

7.4 Raise its popularity by advertisements so that it can be used on every car.

It is no doubt that if a product is wanted to be popularized, it should be advertised well. Our system is focus on detecting the driver’s alcohol concentration which can be used on everyday life. So we should tell drivers how dangerous the drunk driving will be and how to avoid this by fixing a tiny, cheap and accurate system. We are always thinking about how to construct a safe driving environment to drivers.


d:\users\dave\documents\tencent files\250749121\image\j%xfzoxxlum{n$~1_{8.jpg

Figure 25. Total cost for project


In this project, the most important thing is that the sensor can detect all the conditions when driver has drunk already no matter how much they did. Secondly, connecting to the car ignition is a proper way to force driver do so every time they want to drive. Thirdly, user can get the data on their android phone in time when they do breathing test every time.

We predict that alcohol detecting system can use in all cars to serve for the people who need.


  1. "Sensor Report - MQ3 Gas sensor", April 27, 2008

  1. "The Jacket That Tells You You’re Drunk", October 13th, 2011

  1. Blood/Breath Alcohol Concentration (BAC) calculator

  1. "Arduino Breathalyzer: Calibrating the MQ-3 AlcoholSensor"

  1. "Building an Breathalyzer with MQ-3 and Arduino", Mar 7, 2010

Manual of Alcohol Detecting System

Alcohol detecting system

It’s a kind of system that detect the alcohol concentration in the cars to prevent the behavior of drunk driving.

  1. android smart phone (samsung galaxy S1)

  2. OSX operating system

  3. Arduino mega

  4. Eclipse IDE for Java EE Developers

  5. Android SDK

  6. Amarino Tookit

  7. Bluetooth Medium- Bluesmirf Silver

We separate it as three parts: Laptop part, hardware part, software part

Step 1 : Setting up connection between Arduino board and MQ3 Sensor (hardware part)

Connect the Arduino borar and MQ3 in the following way: c:\users\xue rui\appdata\roaming\tencent\qq\temp\richole\ka@5yblc11fwf@9qpbm]~(r.jpg

H (left)–5.0V

H (right)-GND

A (one of both A) — 5.0V


We use 4 of 6 pins
Step 2 : Set up Arduino software (Laptop part)

It is the most complicated part of this experiment.

You can get a detailed tutorial from

There’re four kinds of operating system for you to choose

Basically, the software helps us input the code into the arduino board, which shows the corresponding alcohol reading result of MQ3 (sensor)

Step 3 : Downloading Meet Arduino Library (Laptop part)

Download the MeetAndroid Library and place it into the libraries Folder Arduino.

After placing the folder into the libraries folder, you should be able to access all the amarino files through the arduino programming environment.

Or import the code (sensorgraph) that lists below

Step 4 : Setting up bluesmirf silver with arduino board (hardware part)

Connect the bluesmirf silver Bluetooth adapter in the following way:

Tx–1 to Rx–0

VCC — 5.0V


TX — RX (digital pin 0 of arduino)

RX — TX (digital pin 1 of arduino)

  • * very very important: Your BlueSmirf Bluetooth Module should have 115200 baud rate. When the BlueSmirf Bluetooth Module paired with your device, the green light is on.

Step 5 : Installing Amarino (software part)

Go to and download the following applications on your mobile phone

a. Amarino – Android Application- to be installed on phone.

b. Amarino Plug-in Bundle- to be installed on phone.

c. Amarino Library- To be kept in Java Project
Step 6 : Test the communication between Blue smirf module and Arduino (laptop part)

Seek the open source at

Note: set the Serial Monitor Baud rate to 115200. Code lists in the below:

Step 7 : Set up Eclipse (software part)

It is the most complicated part of this experiment.

You can get a detailed tutorial from

The basic idea is to Install the Eclipse first(follow the system requirements), then install the android SDK, then install ADT plugin for Eclipse IDE.

Step 8 : Create new project in Eclipse (software part)

There is an open source of Sensor Graph, down load from

Codes still need to be changed to realize the function and is shown in the end of the manual.

Step 9 : Set up the application on the phone (software part)

NOTE: you must have ADT-Plugin installed.

Go to

*make sure you have your “AmarinoLibrary_v0_55.jar ” file is included. Download it

step 10 : Install the application in your phone(software part)

Your phone should already be connected via usb to your computer, In your phone settings , and install from unknown sources checked.

In Samsang S1, it was in settings>applications>USB debugging.
 Next, find alcohol detecting.apk that imports to your phone.

This will install the Alcohol detection app to your phone and run it.

TIPS: If your application is not installed on phone, then there is a possibility that your phone’s device driver is not installed on computer. Go to Device manager and install the driver for your phone. If you have internet connection, it searches itself for the driver. You can get more information from here:


Download 96.33 Kb.

Share with your friends:

The database is protected by copyright © 2022
send message

    Main page