MQ-3 Alcohol Sensor Arduino Code | Configuration and Explanation

The MQ-3 sensor is used to detect alcohol. It an be programmed by arduino. Here, we build a program to identify ethanol vapor. In this tutorial, you will learn all about MQ-3 sensor configuration and coding.


MQ-3 alcohol sensor arduino code

  1. Description about MQ-3 gas sensor
  2. Configuration of the sensor
  3. Arduino code
  4. Sensor values at normal conditions and when exposed to alcohol vapor

MQ-3 Sensor

MQ-3 alcohol sensor can be used to detect vapor of alcohols such methanol and ethanol. It means, MQ-3 sensor is so much sensitive for alcohols. But less sensitive to benzene.

MQ-3 sensor is a cheap sensor and you can buy it from online sellers.



Configuration of the sensor

MQ-3 sensor is a simple sensor and configuration of the sensor is very easy. It can be set to Arduino board in one minute.


In the MQ-3 sensor, there are four pins are available to connect Arduino board.

  1. VCC
  2. GND
  3. DO
  4. AO

In our program, VCC, GND, AO pins are connceted to the arduino board.


When you going to take a measurement by MQ-3 sensor, You have to wait several minutes until sensor come to steady state (Use arduino serial plotter). When you give power to the sensor, large output value will be shown. But with time, that value will decrease and come to a constant range.



Arduino Code of MQ-3 sensor

  1. /*
  2. The MQ-3 sensor is used to detect alcohol. It an be programed by arduino.
  3. Here, we build a program to identify ethanol vapor.
  4. In the MQ-3 sensor, there are four pins.
  5. VCC
  6. GND
  7. DO
  8. AO
  9. VCC, GND, AO pins are connceted to the arduino.
  10. */
  11. int sensorPin = A0; // select the input pin for the MQ-3 sensor
  12. int sensorValue = 0; // variable to store the value coming from the sensor
  13. void setup() {
  14. Serial.begin(9600);
  15. }
  16. void loop() {
  17. // read the value from the sensor:
  18. sensorValue = analogRead(sensorPin);
  19. Serial.print("MQ3 sensor value");
  20. Serial.println(sensorValue);
  21. delay(1000);
  22. }


Download arduino code for MQ-3 sensor

Sensor values shown at normal conditions and when exposed to alcohol vapor

Upload your code to arduino board. Then open Serial Monitor in the arduino window to see the analog input values coming from the MQ-3 sensor.


When your MQ-3 gas sensor is at normal air

Serial monitor will show very low values. Usually this value will be less than 60 according to my experience and my atmospheric conditions.

When your MQ-3 gas sensor is exposed to alcohol vapor

Suddenly your analog input values increase to a large amount. When you remove your sensor from your alcohol source, you can see values are dropping.

The response speed will be depend on your quality of the sensor.




What are the other gas sensors can be used to measure air quality?

  1. Hydrogen
  2. Carbon dioxide
  3. Carbon monoxide
  4. Natural gas
  5. LPG


How do I modify the Arduino code to switch on a buzzer when MQ-3 sensor detects an alcohol vapor?

Just set your buzzer Arduino code to your existing code according to the MQ-3 sensor analog input value.



I have uploaded arduino code to get analog input from MQ 3 sensor. When sensor was exposed to ethanol, sensor responsed very quickly. I used a Serial Plotter to see the analog signal. But, after the removing the ethanol source from the sensor, sensor took a lot of time to come back to the normaal condition. Why this was happened?

This is a general case of MQ series sensors (according to my experience). They response to the gas immediately. But do not response after removal of gas. This can be occurred due to gas exists some time around the sensor though source is not there. Also, according to the quality of your sensor, response time may vary. If you want very low response time, you have to buy a best quality sensor.



Can I use MQ-3 sensor to identify ethanol?

Yes. you can. But, you have to be very careful whether how other gases will effect on sensor outputs. If some gases can interact with sensor as ethanol does, there may be misunderstandings.




Related Tutorials