How to use the MQ3 alcohol sensor with Arduino | Step by step instructions
Hello guys, welcome back to another tutorial from the SriTu Hobby. In this tutorial, we will learn how to use the MQ3 alcohol sensor with Arduino. With this sensor, we can measure the alcohol level in the air. Also, this MQ3 sensor can be used mainly to create projects to get the level of alcohol in the human body. So, we can buy this sensor in the market at a low price.
The structure of this MQ3 sensor
These sensors are made of iron mesh on the surface and a plastic cover on the outside. Also, these sensors are designed so that only gaseous elements can travel inside. These are also known as heater-driven sensors. If we talk about the interior of these sensors, there are 6 legs connected to the sensing element. Two of these six legs are used to heat the sensing element. Also, these are connected via a nickel-chromium coil. The other 4 legs are connected to the body of the sensing element using the platinum element. If we talk about this sensing element, it is made of ceramic containing aluminium oxide and coated with tin dioxide on the outside. Also, these tin dioxides are very sensitive to alcohol. The ceramic substrate here controls the heat as needed.
Sensor activation on clean air
The tin dioxide-coated sensing element (we talked about above) absorbs oxygen to the surface when heated to a high temperature. When fresh air enters the sensor, electrons are attracted to oxygen molecules from the tin dioxide zone. Then a layer of electron decay forms below the tin dioxide particles. Also, a potential barrier is created. The tin dioxide film then blocks the flow of electric current. So, the output voltage decreases.
Sensor activation on alcohol
When the alcohol mixture is brought close to the air sensor, it reacts with the tin dioxide, reducing the surface absorption of oxygen. Then the potential barrier decreases. The electrons are then released into the tin dioxide. Then the current flows freely. So, the output voltage increases. We can get this output voltage in the form of Analog and Digital input. That task is performed by the module to which this sensor is connected. The Potentiometer in this module can also change the sensitivity of the digital input.
OK, now let’s see the pin structure of this sensor
OK, now we will learn how to use this sensor with an Arduino board. The required components are as follows.
- Arduino UNO board x 1 — Our Store / Amazon
- MQ3 sensor x 1 — Our Store / Amazon
- Breadboard x 1 — Our Store / Amazon
- 5v buzzer x 1 — Our Store / Amazon
- LED x 1 — Our Store / Amazon
- 180-ohm Resistor x 1 — Our Store / Amazon
- Jumper wires — Our Store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.
Step 2
Secondly, connect these components. For that, use the circuit diagram below.
Step 3
Thirdly, let’s create a program for this project. It is as follows.
- The complete program of this project – Download
/*MQ-3 sensor with Arduino.
created by the SriTu Tech team.
Read the code below and use it for any of your creations.
Home Page
*/
#define sensorDigital 2
#define LED 3
#define buzzer 4
#define sensorAnalog A1
void setup() {
pinMode(sensorDigital, INPUT);
pinMode(LED, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
void loop() {
bool digital = digitalRead(sensorDigital);
int analog = analogRead(sensorAnalog);
Serial.print("Analog value : ");
Serial.print(analog);
Serial.print("t");
Serial.print("Digital value :");
Serial.println(digital);
if (digital == 0) {
digitalWrite(LED, HIGH);
digitalWrite(buzzer, HIGH);
} else {
digitalWrite(LED, LOW);
digitalWrite(buzzer, LOW);
}
}
Code explanation
Firstly, the sensor, LED, and buzzer pins are defined.
#define sensorDigital 2
#define LED 3
#define buzzer 4
#define sensorAnalog A1
Secondly, these pins are set as OUTPUT and INPUT pins. Also, the serial monitor is enabled in the void setup.
void setup() {
pinMode(sensorDigital, INPUT);
pinMode(LED, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
In the void loop, the Digital and Analog values received through the sensor are inserted into two separate variables and printed on a serial monitor. Also, if the digital value is 0, the LED and the buzzer turn ON, and if the digital value is 1, the LED and the buzzer turn off.
void loop() {
bool digital = digitalRead(sensorDigital);
int analog = analogRead(sensorAnalog);
Serial.print(“Analog value : “);
Serial.print(analog);
Serial.print(“t”);
Serial.print(“Digital value :”);
Serial.println(digital);
if (digital == 0) {
digitalWrite(LED, HIGH);
digitalWrite(buzzer, HIGH);
} else {
digitalWrite(LED, LOW);
digitalWrite(buzzer, LOW);
}
}
Step 4
Finally, select the board and port. After, click the upload button.
Now you can test this project using alcohol. The full video guide is below. So, we will meet in the next tutorial. Have a good day.
How to use the MQ3 alcohol sensor with Arduino | Step by step instructions