Arduino Nano 33 IoT - MQ3 Alcohol Sensor

This tutorial shows how to use Arduino Nano 33 IoT with the MQ3 alcohol sensor for measuring and detecting ethanol and alcohol vapor in the air. The MQ3 sensor is perfect for creating breath testing devices, alcohol detection alarms, and environmental monitoring systems.

You will learn:

Arduino Nano 33 IoT with MQ3 alcohol gas sensor module

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×MQ3 Alcohol Sensor
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of MQ3 Alcohol Sensor

Functioning as a Metal Oxide Semiconductor (MOS) Chemiresistor, the MQ3 identifies alcohol through changes in its sensing material's resistance. This module is engineered for ethanol vapor detection with reliable sensitivity across various concentrations.

The sensor's core element uses Tin Dioxide (SnO2) deposited on an Aluminum Oxide ceramic base. Thermal activation makes the SnO2 respond to alcohol molecules in the air. A protective stainless steel mesh surrounds the sensor, shielding the heating element while permitting gas diffusion to the sensing area.

Applications include DIY breathalyzer construction, impaired driving sensors, alcohol concentration alarms, and ambient alcohol level tracking systems.

Technical Specifications

  • Operating Voltage: 5V DC
  • Load Resistance: 200 KΩ
  • Heater Resistance: 33Ω ± 5%
  • Heating Consumption: < 800mW
  • Sensing Resistance: 1 MΩ – 8 MΩ
  • Detection Range: 25 – 500 ppm (parts per million)
  • Preheat Time: 24-48 hours for first use

What is ppm? The measurement ppm (parts-per-million) represents the ratio between target gas molecules and total molecules present. As an example, 500 ppm signifies 500 alcohol molecules among every 1,000,000 total gas molecules, with the other 999,500 being ambient air.

Pinout

Four terminals are available on the MQ3 sensor module:

  • VCC pin: Supply +5V power here.
  • GND pin: Connect to ground (0V).
  • DO pin: Digital output transitions to LOW above the alcohol threshold, HIGH below it. Threshold adjustment via onboard potentiometer.
  • AO pin: Analog output generates voltage based on alcohol concentration. Higher alcohol produces higher voltage.
MQ3 alcohol sensor module pinout diagram

Two LED indicators provide status information:

  • PWR-LED: Lights when module receives power.
  • DO-LED: Matches digital output state—on when detecting alcohol, off otherwise.

How It Works

The MQ3's operating principle is based on resistance changes in its Tin Dioxide (SnO2) semiconductor:

In fresh air: Heated SnO2 attracts oxygen molecules to its surface, capturing electrons and forming a depletion layer. These trapped electrons establish a conduction barrier, maintaining high electrical resistance.

With alcohol present: Alcohol molecules react with surface oxygen, releasing trapped electrons back into the tin dioxide structure. This release boosts conductivity significantly—higher alcohol levels create lower resistance.

Two output configurations are available:

Digital Output (DO pin):

  • The onboard trim potentiometer sets the threshold point.
  • Alcohol above the threshold drives DO to LOW and lights the LED.
  • Alcohol below the threshold maintains DO at HIGH with LED off.

Analog Output (AO pin):

  • Voltage output scales with alcohol concentration.
  • More alcohol vapor = higher voltage reading.
  • Less alcohol vapor = lower voltage reading.
  • Note: Potentiometer adjustment impacts only digital threshold, not analog values.

Warm-up and Calibration

Pre-heating Requirements

Proper heating ensures accurate MQ3 sensor performance:

  • First time use or extended storage (30+ days): Provide 24-48 hours of continuous heating to stabilize the sensor for consistent measurements.
  • Regular operation: A short 5-10 minute warm-up suffices. Early readings may start high but will settle quickly.

Heat the sensor by connecting VCC and GND to 5V and ground—use a power supply or connect directly to Arduino Nano 33 IoT power pins.

Finding Your Threshold Values

Heating element sensors like the MQ3 can drift during storage. For breathalyzer uses, calibrate threshold values through this process:

  1. Establish clean air reference: Run the sensor in fresh air and record the analog output (generally 100-150).
  2. Introduce alcohol vapor: Hold isopropyl alcohol or hand sanitizer near (avoiding contact with) the sensor, letting vapor reach it. Note the higher readings (typically 400-900 depending on vapor density).
  3. Create threshold zones: From your data, define detection ranges:
  • No alcohol: Values below baseline + 20 (example: < 120)
  • Light detection: Mid-level values (example: 120-400)
  • Strong detection: Values above mid-level (example: > 400)

Critical: Each sensor and environment produces different readings. Always perform calibration with your actual setup before use.

Setting the Digital Threshold

Adjust the DO pin threshold via the module's potentiometer:

  1. Bring alcohol vapor near the sensor.
  2. Turn potentiometer clockwise until LED lights.
  3. Slowly turn counterclockwise until LED just turns off.
  4. Threshold is now set.

Wiring Diagram

The MQ3 module has both digital and analog outputs available. Choose one output or use both simultaneously based on your needs.

  • Wiring diagram for connecting the Arduino Nano 33 IoT to the MQ3 alcohol sensor using the USB port for power.
The wiring diagram between Arduino Nano and 33 IoT MQ3 alcohol sensor

This image is created using Fritzing. Click to enlarge image

  • A wiring diagram showing how to connect the Arduino Nano 33 IoT and the MQ3 alcohol sensor using the Vin power pin.
The wiring diagram between Arduino Nano and 33 IoT alcohol detector

This image is created using Fritzing. Click to enlarge image

MQ3 Alcohol SensorArduino Nano 33 IoT
VCC5V
GNDGND
DO2
AOA6

Arduino Nano 33 IoT Code - Digital Output Reading

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-mq3-alcohol-sensor */ #define PIN_DO 2 // The Arduino Nano 33 IoT pin connected to the DO pin of the MQ3 sensor void setup() { // Initialize serial communication Serial.begin(9600); // Initialize the Arduino Nano 33 IoT pin as an input pinMode(PIN_DO, INPUT); // Warm-up message Serial.println("Warming up the MQ3 sensor"); delay(20000); // 20 seconds warm-up time for recently used sensor } void loop() { int gasState = digitalRead(PIN_DO); if (gasState == HIGH) { Serial.println("Alcohol is NOT detected"); } else { Serial.println("Alcohol is detected"); } delay(1000); }

Detailed Instructions

  • Open the code in Arduino IDE
  • Upload to Arduino Nano 33 IoT via the Upload button
  • Place alcohol vapor near the MQ3 sensor (use hand sanitizer or rubbing alcohol on cotton)
  • Check detection results in Serial Monitor
COM6
Send
Alcohol is NOT detected Alcohol is NOT detected Alcohol is NOT detected Alcohol is detected Alcohol is detected Alcohol is detected Alcohol is detected Alcohol is NOT detected Alcohol is NOT detected
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Remember, if detection results are incorrect (always on or always off), rotate the potentiometer to adjust sensor sensitivity.

Arduino Nano 33 IoT Code - Analog Output Reading

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-mq3-alcohol-sensor */ #define PIN_AO A6 // The Arduino Nano 33 IoT pin connected to the AO pin of the MQ3 sensor void setup() { // Initialize serial communication Serial.begin(9600); // Warm-up message Serial.println("Warming up the MQ3 sensor"); delay(20000); // 20 seconds warm-up time for recently used sensor } void loop() { int gasValue = analogRead(PIN_AO); Serial.print("MQ3 sensor AO value: "); Serial.println(gasValue); delay(1000); }

Detailed Instructions

  • Copy the code into Arduino IDE
  • Click the Upload button to upload to Arduino Nano 33 IoT
  • Place alcohol vapor near the sensor (hand sanitizer or isopropyl alcohol)
  • Watch the values in Serial Monitor
COM6
Send
MQ3 sensor AO value: 120 MQ3 sensor AO value: 125 MQ3 sensor AO value: 128 MQ3 sensor AO value: 450 MQ3 sensor AO value: 620 MQ3 sensor AO value: 850 MQ3 sensor AO value: 920 MQ3 sensor AO value: 980 MQ3 sensor AO value: 950 MQ3 sensor AO value: 680 MQ3 sensor AO value: 420
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

From digital or analog outputs, you can build threshold logic to activate alarms, control warning lights, or log data for breathalyzer functionality.

Arduino Nano 33 IoT Code - Breathalyzer with Threshold Detection

This example demonstrates using analog output with calibrated thresholds to determine alcohol consumption levels.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-mq3-alcohol-sensor */ #define PIN_AO A6 // The Arduino Nano 33 IoT pin connected to the AO pin of the MQ3 sensor // Threshold values - REPLACE THESE with your calibrated values! // Run calibration first to find these values for your sensor #define SOBER_THRESHOLD 120 // Below this = sober #define DRUNK_THRESHOLD 400 // Above this = drunk, between = drinking but within limits void setup() { // Initialize serial communication Serial.begin(9600); // Warm-up message Serial.println("MQ3 Alcohol Sensor - Breathalyzer"); Serial.println("Warming up sensor..."); delay(20000); // 20 second warm-up for recently used sensor Serial.println("Sensor ready!"); Serial.println(); } void loop() { int gasLevel = analogRead(PIN_AO); // Read the analog value from sensor // Print sensor value Serial.print("Sensor Value: "); Serial.print(gasLevel); Serial.print(" | Status: "); // Determine status based on thresholds if (gasLevel < SOBER_THRESHOLD) { Serial.println("Stone Cold Sober"); } else if (gasLevel >= SOBER_THRESHOLD && gasLevel < DRUNK_THRESHOLD) { Serial.println("Drinking but within limits"); } else { Serial.println("DRUNK"); } delay(1000); // Wait 1 second between readings }

Detailed Instructions

  • Required: Calibrate your sensor first using the analog reading code to find correct threshold values for your hardware.
  • Update the SOBER_THRESHOLD and DRUNK_THRESHOLD values in the code with your calibrated numbers.
  • Upload the modified code to Arduino Nano 33 IoT
  • Test with alcohol vapor (isopropyl alcohol or hand sanitizer vapor)
  • View status messages in Serial Monitor
COM6
Send
Sensor Value: 115 | Status: Stone Cold Sober Sensor Value: 118 | Status: Stone Cold Sober Sensor Value: 350 | Status: Drinking but within limits Sensor Value: 480 | Status: DRUNK Sensor Value: 520 | Status: DRUNK Sensor Value: 290 | Status: Drinking but within limits Sensor Value: 125 | Status: Stone Cold Sober
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Disclaimer: This project is for educational purposes only. Never use this device as a legal breathalyzer or for driving safety decisions.

Video Tutorial

Function References

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!