How Does an MQ Gas Sensor Work?

MQ gas sensors are the affordable way to detect smoke, LPG, alcohol, and other gases in maker projects, and Compoden's AI build assistant helps you choose the right one and read it safely. The MQ family appears in gas-leak alarms, air-quality monitors, and safety projects. This article explains how they sense gas, the signals they give, and how to read them on an Arduino or ESP32.

The working principle

An MQ sensor contains a small sensing layer made of a metal-oxide material, most often tin dioxide, sitting on a tiny built-in heater. The heater warms the layer to a working temperature so the chemistry can happen. In clean air the layer has a certain electrical resistance. When a target gas is present, gas molecules interact with the heated surface and change how easily current passes through the layer, so its resistance shifts. More gas means a larger change in resistance. The sensor turns that resistance change into a voltage you can measure.

Different MQ models are tuned for different gases by changing the sensing material and the way they are calibrated. One model leans toward LPG and combustible gas, another toward alcohol, and another toward smoke or carbon monoxide. They detect a family of gases rather than one single gas, so they are best for general detection rather than identifying exactly which gas is present.

How it outputs a signal

Most MQ modules give two outputs. The analog output is a voltage that rises and falls with the gas concentration, giving you a continuous reading. The digital output is a simple HIGH or LOW that flips when the gas crosses a threshold you set with an onboard trimmer, which is handy for a straightforward alarm. The module also needs time to warm up after power-on before its readings settle.

How you read it on a microcontroller

Wire VCC and GND to power and ground. For the analog output, connect it to an analog input on your Arduino and read the changing value; a rising number means more gas. For the digital output, connect it to a digital input and read HIGH or LOW to trigger an alarm. Note that the ESP32's analog inputs behave a little differently from the Arduino's, so check which pins to use. Because MQ sensors are not precise instruments, most projects treat them as relative detectors, watching for a rise above a baseline rather than reporting an exact concentration. Always allow the warm-up period before trusting readings.

Common uses

MQ sensors are used in gas-leak alarms for kitchens, smoke and fire early warning, breath alcohol testers, and basic air-quality monitors. They are cheap and easy to start with. Their limits are slow warm-up, sensitivity to temperature and humidity, drift over time, and broad rather than gas-specific response, so for life-safety use they should support, not replace, a certified detector.

Build it with Compoden's AI

Picking the correct MQ model for your target gas and reading it sensibly is exactly where guidance helps. Compoden's AI build assistant matches an MQ sensor to the gas you care about, explains the analog and digital outputs, and shows how to wire and read it on your Arduino or ESP32, including the warm-up step. Tell it whether you are building an LPG alarm, a smoke detector, or an air monitor, and it suggests parts and an approach. Browse our collection and keep the assistant handy.

Build a safer space today. Browse MQ gas sensors at Compoden and let the AI build assistant guide you.

How does an MQ gas sensor detect gas? It uses a heated metal-oxide layer whose electrical resistance changes when target gas molecules touch its surface. More gas causes a bigger change in resistance, which the module converts into a voltage you can read.

Does an MQ sensor give analog or digital output? Most MQ modules offer both. The analog output is a voltage that varies with gas concentration, and the digital output is a HIGH or LOW that flips at a threshold set by an onboard trimmer, useful for simple alarms.

Can an MQ sensor measure exact gas concentration? Not precisely. MQ sensors respond to a family of gases and drift with temperature, humidity, and age, so they are best used to detect a rise above a baseline. For life-safety, pair them with a certified detector.

Back to blog