Home / Tutorials / Arduino Tutorial / How to Use the MQ-7 Carbon Monoxide Sensor

How to Use the MQ-7 Carbon Monoxide Sensor

The MQ-7 carbon monoxide sensor is especially designed to be sensitive to carbon monoxide (CO) gas which is emitted by vehicles, factories, etc. Since this gas is considered toxic to humans at certain levels, concentration of CO is used to determine the air pollution in a given area.

Introduction to MQ-7 Carbon Monoxide Sensor

According to its datasheet, the MQ-7 carbon monoxide sensor detects 20 to 2000 ppm of CO in air. Here is its sensitivity characteristic curve:

MQ-7 Carbon Monoxide Sensor Characteristic Curve

This is a graph of Rs/R0 vs. gas concentration in ppm. Rs is the resistance of the sensor in target gas while R0 is the resistance in clean air. We will use this graph later when we create our code.

For this tutorial, I will be using the MQ-7 breakout board which has four output pins as shown:

This breakout board is more convenient as it converts resistance variations to voltage variations. Here is its schematic diagram:

MQ3 schematic

This schematic diagram is the same as with the MQ-3 alcohol sensor and MQ-6 LPG sensor.

There are two ways to read the output from the MQ-7. One is through the DOUT pin which gives a high when the concentration threshold is reached and low otherwise. The threshold can be varied by adjusting the trimmer on the breakout board which is Rp in the schematic.

Meanwhile, the AOUT pin gives varying voltage representing the CO concentration. We can convert the voltage reading to ppm if we look at the characteristic curve above, which is a log-log plot.

We are only interested in the blue line on the plot which gives the CO concentration. The function of a line in such a plot is given as

Where F1, x1, and F0, x0 are any two points in the plot. We can select two points on the plot, as shown:

MQ-7 Plot annotatedThe encircled two points are approximated to be:

  • F1 = 0.25 , x1 = 10
  • F0 = 0.065, x0 = 100

Thus, using the equation above:

or, the relationship between concentration in ppm and RS/R0 is now:

Solving for ppm:

Arduino Sketch for MQ-7

Before we can use this formula in a sketch, we need to determine R0 of the MQ-7 sensor first. This varies between devices so there is a need for actual testing.

From the log-log plot, we can see that RS/R0 is constant in air and is equal to 1. Since by definition, R0 is the resistance of the sensor in clean air, then only RS varies for every gas.

RS is the sensor resistance and forms a voltage divider with the resistor R2 (see schematic diagram above). Thus, RS can be determined if the series resistor R2 from the schematic is known. Most boards use a 2 kilo-ohm resistor for R2.

We can then use this sketch to get R0:

Once R0 is determined, we can then use this sketch to display the ppm concentration of C0

Upload the sketch above to your Arduino, open your serial monitor and now you have an Arduino carbon monoxide sensor! Use this with a smartphone app and detect C0 levels in your surrounding. If its above 35 ppm, that’s already toxic and you should leave right away!

Check Also

Sensor attached to Arduino UNO

Using a Fingerprint Sensor

Fingerprint sensors are old technology but it wasn’t readily available to makers until it was …


  1. Hi, would it be possible to know the values of the resistors in the circuit? Thank you.

  2. Hi
    I am using MQ-7 to measure CO in PPM.
    WHEN i have copied the code and run the arduino software , give me some faults.
    can u send me the code please.
    I am not expert in this field.

  3. Excellent write-up ... but I cannot seem to figure out which pin on the sensor breakout board I should connect A1 to, when running the sketch that calculates R0.The schematic makes no mention of it, neither does your narrative.

    Thank you,

    Mike Sims

  4. Redhat Certified

    Can anybody provide me with a video tutorial of the setup. I'm extremely new to this field.

  5. at this line R0 = RS_gas / 1 . Is it 1 come from air constant?

Leave a Reply

Your email address will not be published. Required fields are marked *