Taking CO readings with MQ7 gas sensor

I am trying to use an MQ7 CO gas sensor with Arduino. You are supposed to alternate the power to the sensor between 5V and 1.4V. I understand that you take CO readings at the end of one period and flammable gases readings at the end of the other, but I can't find any clear reference to which period to take the CO readings at the end of. Can anyone tell me when you are supposed to take the CO reading?

Take a look at the specs of the MQ7 CO gas sensor, also try googling for a code example, found it in less than 30 seconds

Gas Sensor Example

Avoid the above tutorial. It is completely incorrect and in addition states to use an LED without a current limiting resistor, which can destroy both the Arduino output pin and the LED.

The MQ-7 data sheet describes the measurement procedure.

This tutorial offers good advice on how to construct the measuring circuit, which needs to provide two heater voltages. Hazardous Gas Monitor - learn.sparkfun.com

IF I am reading the datasheet correctly, it is saying to take the Co reading while the heater voltage is 5 V near the end of the 5V 60-second period. Is the correct? The wording is not completely clear.

That is correct, end of the 5V, 60s interval.

How are you arranging to power the heater? You should not use the Arduino 5V output under any circumstances.

The code example you point to is worthless for my question. It does not even alternate the voltage level as described in the instructions between 5V and 1.4 V. The diagram in the article clearly shows the sensor simply connected to the 5V termainal.

As you have probably noticed, there are a number of MQ-7 tutorials like that, published by people who do not have the slightest idea what they are doing, and certainly did not look at the data sheet.

It really bothers me that the Sparkfun tutorial does not provide a schematic diagram for their circuit. They should know better than that.

EDIT: This may be a promising approach, but I did not look at the circuit closely: Internet of Things: March 2014

1 Like

I looked at it. Oddly, the sketch reads the MQ7 sensor during both the high and low periods. However, the article does mention that the time to read the sensor is at the end of the 5V cycle just before switching to 1.4V, which is what I am looking for. Thanks. BTW, what I am building is a fully functioning environmental tricorder that reads atmospheric gases, temperature and humidity, nuclear and electromagnetic radiation, magnetic fields, etc. I am currently working on the gases using MQ sensors before I add more advanced sensors.

Sounds like fun!

I found the Electronic Nose project by Michael Madsen to be quite fascinating. It uses several different MQ sensors and combines the results using sophisticated math to distinguish odors.

The web site went off line a while back, but copies can be found on the internet archives.

Check it out! Electronic nose | Michael Madsen

" It uses several different MQ sensors and combines the results using sophisticated math to distinguish odors." I have been considering doing something like that myself since most MQ sensors detect multiple gases, but I was not thinking quite that sophisticated. I was thinking along the simpler lines of having it try to determine which gas (e.g., methane, propane, alcohol, hydrogen, etc.) it was detecting by having multiple sensors and evaluating which sensor was getting the highest reading. BTW, what I do is write books about Arduinos and other techie subjects. The functioning tricorder is supposed to be my next book, but it is slow going.

I just read the MQ-7 Carbon monoxide sensor specification from the SparkFun website. I could find no reference to reading flammable gases. The Figure 5 shows when to read the sensor.

I found this table:


From what I have seen of these cheap sensor is that they were designed for one purpose only, YES/NO output for "various" gas levels.
Such as the bilge in boats, basement gas alarms.
Any attempt at getting an exact reading is fruitless.

If you want a gauge that gives you CO levels, you will need a dedicated CO sensor.
Also be prepare to have them regularly calibrated as they have a definite life.

Then you will need to calibrate it.

Tom... :smiley: :+1: :coffee: :australia:

The MQ-7 data sheet shows that it is more sensitive to hydrogen gas than to CO, but less sensitive to LPG, methane and "alcohol" (presumably ethanol gas). Those are all extremely flammable gases.

Interesting, can you post the link for this data sheet? Thanks

One is on the Sparkfun web site, but the sensitivity graph is rather different than on the MQ-7 data sheet that I have had for some time (attached).

I gather that these graphs are not at all reliable. The sensors certainly aren't.
MQ-7.pdf (52.2 KB)

Edit: wrong data sheet uploaded, now corrected. I also just noticed that according to the data sheet on the Sparkfun site, the "detection period" is (presumably at the end of) the interval where the heater is powered by 1.5 V, seemingly contradicting the attached data sheet.

The chart you displayed shows the primary gas each is designed to detect. The problem with almost all of the MQ sensors is that each detects multiple gases. If you look at the graph on the datasheet, you will see graphs for hydrogen, LPG (propane), methane, and alcohol. The hydrogen graph looks even more pronounced than the CO graph.

They do have a digital YES/NO output, but they also have an analog output. The calibration may be poor, but it will indicate relative levels that can translate into approximate ppm levels. My tricorder has a self-calibrating feature where you expose it to clean air and it calibrates itself, then you take it to where you want to test for gases.

Yes, I saw that. One way my tricorder will handle that is to have multiple MQ sensors and combine the results. For example, the MQ8 is highly sensitive to hydrogen but barely sensitive to CO. If you get little or no reading on the MQ8 but a high reading on the MQ7, you have CO. If you get high readings on both, you have H2. BTW, the MQ9 also detects CO and is not apparently sensitive to H2, although it does react to methane and propane. It is also much more expensive. Oddly, the MQ9 datasheet says it is exactly the opposite of the MQ7. You read CO at the end of the LOW cycle. This is very worrying to me because I cannot see how two such similar devices can work exactly opposite.

"I also just noticed that according to the data sheet on the Sparkfun site, the "detection period" is (presumably at the end of) the interval where the heater is powered by 1.5 V, seemingly contradicting the attached data sheet."
This is why I am going nuts. I read that you take the readings at the high temperature in one place and the low temperature in the other. Also, some of these are obviously poor translations and the wording is unclear. I cannot seem to find a clear, authoritative source for info anywhere that spells out explicitly how to use this.

The MQ-7.pdf file you link to here is really weird. The last 2 lines, c and d, are nearly gibberish and seem to suggest that you take the readings at the end of BOTH periods, only using different load resistors.