Gas & Air Quality
Interfacing MQ 3 Gas & Air Quality with Raspberry Pi
What is the MQ 3?
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.
Setting Up MQ 3 with Raspberry Pi
Library
Adafruit-MCP3008 by Adafruit
pip3 install adafruit-circuitpython-mcp3xxx
Wiring
| Component pin | Raspberry Pi pin | Note |
|---|---|---|
| VCC | 5V (physical pin 2) | Heater needs the full 5V rail |
| GND | GND (shared with MCP3008) | |
| AO | Through a divider into MCP3008 CH0 | The Pi has no analog input — route through an MCP3008 over SPI, dividing the ~5V swing down to the MCP3008's 3.3V reference |
| DO | GPIO27 (optional) | Digital threshold output |
Swipe sideways to see every column →
- The Pi has no analog input pins, so an MCP3008 (or similar external ADC) is required here, not optional.
- Wire the divider the same way as the ESP32 setup — the MCP3008 also tops out at 3.3V.
- Same warm-up and "not a real breathalyzer" caveats apply as on the other boards.
Related Components
A3144
Digital Hall-effect switch for contactless magnetic detection
ACS712
Measure AC or DC current with an analog Hall-effect sensor
MQ 2
Detects LPG, smoke, and combustible gases — the standard gas sensor for safety projects.
MQ 7
Dedicated CO sensor for indoor safety monitors and air-quality projects.
Related Guides & Projects
Raspberry Pi Pico W and Pico 2 W: Install MicroPython with Thonny or UF2
Hold BOOTSEL, drag the correct UF2 file, open the REPL and blink the onboard LED. Includes the Pico vs Pico W vs Pico 2 W firmware differences and what to do when the drive does not appear.
Raspberry Pi Pico W Web Server in MicroPython: Control an LED and Read a Sensor
Connect the Pico W to WiFi, serve a responsive control page, switch an LED and display the onboard temperature or an external sensor, with timeouts and reconnect handling.
Raspberry Pi Pico Oscilloscope with MicroPython
Convert a Raspberry Pi Pico into a basic 500 kSPS oscilloscope using its 12-bit ADC and MicroPython. Displays waveforms on an SSD1306 OLED or streams samples over USB serial to a Python plotter on your PC.
Self-Hosted Nextcloud NAS on Raspberry Pi 4
Build a private, durable Nextcloud NAS on a Raspberry Pi 4 -- SSD boot instead of a failure-prone SD card, Docker Compose with Redis caching, Tailscale for remote access with zero ports forwarded, and an automated backup strategy that actually runs.