Skip to main content

MQ Gas Sensors – How it works

How the sensor works

An MQ sensor is a type of gas sensor that operates on a chemiresistive principle, meaning it detects gases by measuring changes in electrical resistance.

The core component of an MQ sensor is a metal oxide semiconductor (MOS), typically made of tin dioxide (SnO₂). In clean air, this material has a high resistance, but when exposed to certain gases, a chemical reaction occurs that alters its conductivity.

Basic MQ sensor diagram
Basic MQ sensor diagram

Datasheets

The measuring range, preheat time, available gasses to detect and much more can be found in the datasheets:

SensorDatasheet
MQ2Link
MQ3Link
MQ4Link
MQ5Link
MQ6Link
MQ7Link
MQ8Link
MQ9Link
MQ131Link
MQ135Link
MQ137Link
MQ138Link

Communication (Native)

There are two pins used for communicating with the sensor: analog and digital.

The analog pin outputs the voltage from the sensor, which is then used by the dasduino board to calculate the levels of a particular gas. As stated previously, the resistance of the sensor falls as the concentration of gas increases. We can determine the gas concentration in ppm/ppb by using the ratio of the resistance measured during calibration (Ro) to the current sensor resistance (Rs).

Example of an MQ sensor resistance curve
Example of an MQ sensor resistance curve

The curve that the resistance follows for a specific gas must be approximated by the sensor. This is achieved by identifying attributes of the curves and applying a linear or exponential regression method. This process is explained in detail in the link below:

Understanding a gas sensor

Detailed guide on how to calculate the approximate curve of resistance by Jaycon

ℹ️

All of our sensors have a pre-configured regression method for each sensor! Check them out here

The digital pin works through the onboard potentiometer. Adjusting the potentiometer sets the voltage (gas concentration) at which the digital pin will be set to HIGH. This is commonly used as a trigger for an alarm if the concentration of a gas becomes too high.

Onboard potentiometer
Onboard potentiometer

Communication (Qwiic)

The Qwiic compatibility is made possible with the Atmel ATTINY404-SSNR. When using Qwiic, you are essentially communicating with an onboard ATTINY404-SSNR MCU via I2C communication, and the MCU detects the sensor's voltage level.

ATTINY404-SSNR on board
ATTINY404-SSNR on board

The breakout board operates with a default I2C address of 0x30; however, it can be changed using onboard switches. To change the breakout board's address, check out the Address selection. When detected, the ATTINY404-SSNR receives data from the sensor and passes it to the main MCU using the I2C data line.