Arduino Breathalyzer Using MQ3 Gas sensor and OLED Display
Hi guys, Welcome to this tutorial. Today we will build a breathalyzer using the MQ3 gas sensor, an OLED display and Arduino.
A breathalyzer is a generalized trademarked name for devices used for determining blood alcohol content from a breath sample. This means the device can detect from your breadth, the amount of alcohol you have taken. This device becomes very useful when you consider several cases of accidents caused by drunk driving. With this device, you can easily warn the driver of a car when he/she is too drunk to drive a car. It is important to note that this project is not accurate enough to replace the standard breathalyzer and you shouldn’t drink and drive.
For this project, we will be using the MQ3 alcohol sensor. It is a cheap semiconductor sensor capable of detecting the presence of alcohol in air at concentrations between the value 0.05 mg/L to 10 mg/L. The sensor uses a chemical reaction to determine alcohol level and the primary sensing element in the sensor is SnO2, the conductivity of SnO2 is low in clean air but increases as the concentration of alcohol gas in air (breath) increases. It has high sensitivity to alcohol and has a good resistance to disturbances and noise from things like smoke and gasoline.
The MQ3 module has 4 pins including both digital and analog outputs, VCC and Gnd. MQ3 alcohol sensor module can be easily interfaced with microcontrollers and development boards like Arduino Boards, Raspberry Pi etc.
The readings from the MQ3 sensor will be displayed via the Arduino mega on an OLED display. A tutorial detailing how to use the OLED display with the arduino is available here.
The MQ3 sensor senses alcohol in a somewhat controlled environment in the sense that the sensor only senses alcohol after heating up to a particular level. To get accurate results, it needs between 10-15 mins on power up to heat up to the desired temperature level which is usually around 40 degrees.
its important to note that this sensor only detects alcohol molecules in air and not liquid alcohol.
To dive in, here is a list of components needed for the tutorial. These components can be purchased via the attached links.
- MQ3 Alcohol Sensor Module
- 0.96′ I2C OLED display
- Arduino Mega (Uno or any other board type would also work)
- Small Breadboard
- Jumper Wires
Connect all the components as shown in the schematics below.
Connect the component as shown above. For clarity, the pin connections are also described below.
MQ3 - Arduino VCC - 5v GND - GND A0 - A0
OLED - ARDUINO VCC - 5v GND - GND SCL - SCL(Pin D21) SDA - SDA(Pin D20)
with the connections all done, we are ready to start writing the code.
As usual, we will break down the code before dropping it all.
The first thing we do is include the functions which are needed for us to be able to interface the oled display with the arduino. more information on how the display part of this project works can be found here.
We then input the wait time. Here I used 900s but you can change it to suit your needs.
We then declare the analog pin to which our alcohol sensor is connected i.e Analog pin 0.
The next major part part after declaring the pin is in the loop function, where we call the read alcohol function which gives us the analog value as determined by the alcohol sensor.
with the value stored, we then check if the device is warm and display the Analog value using the print alcohol function. We also display a message based on the analog level to say whether the owner of the breadth is sober or not.
The full code for this project is available below.
Copy the code, paste in the arduino IDE and upload to your board. You should see something like the image below after its warm. The Arduino code is attached in a zip file at the end of the project.
That’s it for this tutorial. As usual, let me know if you have any questions or comments via the comment section..
You can watch the video of this tutorial here.