MQ 3 practical reference
Tuned specifically for detecting alcohol vapor concentration, frequently used in breathalyzer-style hobby projects. The MQ-3 is a metal-oxide semiconductor gas sensor whose surface resistance changes in the presence of ethanol vapor, producing an analog output that increases with alcohol concentration — like other MQ-series sensors it needs a warm-up period and isn't lab-calibrated, so it's best suited for relative/comparative alcohol-detection demos rather than legally-relevant breathalyzer readings.
Key specifications
- Sensor type: MQ-3 metal-oxide semiconductor (MOS) gas sensor, tuned for alcohol vapor
- Operating voltage: 5 V DC (heater circuit + sensing circuit both typically run at 5V)
- Detection range: ~0.05-10 mg/L alcohol vapor concentration
- Warm-up time: Requires several minutes (some sources recommend 24-48 hours for first-use burn-in) of heater warm-up before stable readings
- Output: Analog voltage proportional to alcohol vapor concentration, plus a digital threshold output (DO) on breakout modules with an onboard comparator
- Sensitivity adjustment: Onboard potentiometer sets the digital-output trigger threshold
- Interface: 1 analog pin (AO) + 1 digital pin (DO, breakout-dependent)
Pinout and connection notes
Like all MQ-series sensors, allow several minutes of warm-up after power-on before trusting readings, since the internal heater element needs time to reach a stable operating temperature; results also drift with humidity and temperature, so treat readings as relative/comparative rather than a precisely calibrated measurement, and never rely on this sensor for legal or medical breath-alcohol determinations.
- VCC: Power, 5V DC (powers both the internal heater and sensing circuit)
- GND: Ground
- AO: Analog output — voltage proportional to alcohol vapor concentration
- DO: Digital output — threshold-triggered HIGH/LOW based on the onboard potentiometer setting
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Specifications
- Sensor type
- MQ-3 heated metal-oxide semiconductor alcohol-vapour sensor
- Target response
- Sensitive to ethanol vapour; other gases and environmental conditions can affect response
- Heater
- Requires a continuously powered heater; allow warm-up and longer conditioning after storage or first use
- Module outputs
- Bare sensor requires a load-resistor circuit; common breakout boards add AO and comparator DO
- Supply
- Heater is commonly operated from a 5 V rail; check the exact sensor and module datasheet
- Measurement quality
- Requires calibration and compensation for meaningful concentration estimates; raw ADC values are not BAC
- Power budget
- Heater current is significant compared with a microcontroller GPIO; power it from a suitable supply
Pinout
| Pin | Name | Description |
|---|---|---|
| VCC | Module supply | Common breakout boards use 5 V for the heater and sensing circuit; verify the board current requirement. |
| GND | Ground | Common ground with the controller and sensor supply. |
| AO | Analog output | Analog voltage from the sensing/load-resistor circuit; measure its range before connecting to an ADC. |
| DO | Comparator output | Optional digital threshold output on comparator-equipped boards; polarity and output stage vary. |
Wiring & code
Setting up MQ 3 with Espressif ESP32
The MQ-3 module detects alcohol (ethanol) vapour. A heated sensing element changes its resistance with the gas level, and the module turns that into two outputs: AO, an analog voltage that rises with the concentration, and DO, a digital signal from an onboard comparator that switches at a level you set with the blue trimmer. This guide wires it to an ESP32, reads AO with averaging, and builds a buzzer alarm that learns the clean-air level at start-up.
On an ESP32 there is one extra job: the module runs from 5 V, so its AO pin can swing close to 5 V, above the 3.3 V the ESP32's pins accept. A two-resistor divider fixes that.
Wiring
| Component pin | ESP32 pin | Note |
|---|---|---|
| VCC | 5V (VIN) | The heater draws about 150 mA and needs 5 V, so not 3V3 |
| GND | GND | Shared with the ESP32 |
| AO | GPIO34 via divider | 10 kΩ from AO to GPIO34, 20 kΩ from GPIO34 to GND: AO can reach about 5 V |
| DO | Not connected | Pulled up to 5 V on most modules; use a divider too if you need it |
Warning
This is a hobby sensor, not a certified alarm. Don't rely on it to protect people; use a certified gas or smoke detector for that.
Warm-up and burn-in
- Every power-up: the heater takes a few minutes to reach a stable temperature. Readings drift down during that time, so ignore the first minutes.
- A new sensor: the datasheet asks for a burn-in of about 24 hours powered before the readings are stable. Leave it running once before you calibrate anything.
- It gets hot. The heater draws about 150 mA at 5 V and the mesh cap gets warm to the touch. That is normal; keep it away from anything that melts.
Read the sensor
/*
MQ-3 gas sensor on an ESP32: averaged reading of the analog output
MQ-3 VCC -> 5V (the heater needs 5 V), GND -> GND
MQ-3 AO -> 10 kOhm -> GPIO34, and 20 kOhm from GPIO34 to GND
(AO can reach ~5 V; the divider keeps GPIO34 under 3.3 V)
*/
const int AO_PIN = 34; // ADC1 pin: still works with Wi-Fi on
const float DIVIDER = (10.0 + 20.0) / 20.0; // (R1 + R2) / R2 = 1.5
const int SAMPLES = 20;
int readAverage() {
long sum = 0;
for (int i = 0; i < SAMPLES; i++) { sum += analogRead(AO_PIN); delay(5); }
return sum / SAMPLES;
}
void setup() {
Serial.begin(115200);
Serial.println("MQ-3 warming up: readings settle after a few minutes");
}
void loop() {
int raw = readAverage(); // 0..4095 (12-bit)
float pinVolts = raw / 4095.0 * 3.3;
float sensorVolts = pinVolts * DIVIDER; // voltage at the module's AO pin
Serial.print("raw ");
Serial.print(raw);
Serial.print(" AO ");
Serial.print(sensorVolts, 2);
Serial.println(" V");
delay(500);
}How it works. Inside the MQ-3, the sensing element's resistance (Rs) falls as the gas level rises. On the module it forms a voltage divider with a load resistor, so AO rises with more gas. Averaging 20 readings smooths out the noise from the heater and the air. The voltage alone is not a concentration: converting it to ppm needs the sensor's own clean-air resistance (R0) and the sensitivity curve from its datasheet, and each sensor differs. Treat it as more or less gas than before. On the ESP32 the reading is scaled back up by the divider ratio of 1.5 to give the voltage at the module's AO pin.
Try it in the simulator
This is the alarm build from the next section, wired as in the diagram. Press Run, wait for the baseline, then raise the gas level from the MQ-3's Settings: the buzzer sounds once the reading climbs past the baseline plus the margin.
Try this circuit in the SolderHub Simulator
Run this exact circuit in your browserReady-wired, code loadedConfirm simulator behavior against the real wiring and the sensor datasheet before connecting hardware.
Buzzer alarm with a clean-air baseline
A fixed threshold breaks as soon as the room, the temperature or the sensor itself changes. This sketch instead measures the clean-air level right after warm-up and alarms when the reading rises a set margin above it. Add an active buzzer: + to GPIO25, − to GND. Power it up in clean air so the baseline is right.
/*
MQ-3 alarm: learn the clean-air level at start-up, sound a buzzer above it
MQ-3 VCC -> 5V, GND -> GND, AO -> GPIO34 through a 10k/20k divider
Active buzzer + -> GPIO25, - -> GND
*/
const int AO_PIN = 34;
const int BUZZER_PIN = 25;
const unsigned long WARMUP_MS = 5000; // a real sensor needs a few minutes; 5 s keeps the demo quick
const int MARGIN = 200; // ADC counts above the baseline that count as an alarm
const int SAMPLES = 20;
int baseline = 0;
int readAverage() {
long sum = 0;
for (int i = 0; i < SAMPLES; i++) { sum += analogRead(AO_PIN); delay(5); }
return sum / SAMPLES;
}
void setup() {
Serial.begin(115200);
pinMode(BUZZER_PIN, OUTPUT);
Serial.println("Warming up in clean air...");
delay(WARMUP_MS);
baseline = readAverage();
Serial.print("Clean-air baseline: ");
Serial.println(baseline);
}
void loop() {
int raw = readAverage(); // 0..4095
bool alarm = raw > baseline + MARGIN;
digitalWrite(BUZZER_PIN, alarm ? HIGH : LOW);
Serial.print(raw);
Serial.println(alarm ? " ALARM" : "");
delay(250);
}- Tune the margin. Watch the numbers in the Serial Monitor with the sensor in clean air, then bring a source near it (a cotton bud with hand sanitiser) and set MARGIN between the two.
- Use a longer warm-up in a real build: replace 5 seconds with two or three minutes.
- Prefer the trimmer? Turn the blue potentiometer until the DO LED just goes off in clean air, then read DO instead of AO for a simple on/off alarm. On an ESP32, DO needs its own divider because the comparator output is pulled up to 5 V.
Troubleshooting
| Symptom | Fix |
|---|---|
| Reading falls steadily for minutes after power-up | Normal heater warm-up: wait before trusting it |
| Reading never changes | Check the 5 V supply: the heater needs about 150 mA. A sensor fed from 3.3 V barely heats |
| Reading stuck near 4095 | The divider is missing or reversed: 10 kΩ from AO to the pin, 20 kΩ from the pin to GND |
| Reading drops when Wi-Fi starts | Keep AO on an ADC1 pin (GPIO32–39); ADC2 stops when Wi-Fi is on |
| DO never changes | Turn the blue trimmer: the threshold may be set past the range you are testing |
| Alarm triggers at power-up | The baseline was taken while the sensor was still warming up: lengthen WARMUP_MS |









