Carbon Monoxide Sensor

MQ-7 carbon monoxide sensor
The MQ-7 (datasheet) is a low-cost CO sensor used to detect Carbon Monoxide (CO) levels.

The sensor provides an analogue output and so needs to be connected to an analogue to digital converter of some sort. For this project we are using the analogue input on an Arduino Uno.

The sensor requires a complex power supply in order to get useful readings. The heater circuit should be power cycled between 5V and 1.4V. 5.0V needs to be applied to the heater element for 60 seconds, to clean the detector. A voltage of 1.4V is then applied for 90 seconds to allow the sensor to settle before taking a reading.

Typically we could acheive this using a digital output on the Arduino with PWM but the output pins on the Arduino UNO don't actually reach 5V dc and can't supply enough current to the sensor being used. To address both issues, we are using a transistor to switch an external 5V dc power supply using PWM, to get the required 5.0V and 1.4V levels. Typically you would use a 2N2222 NPN bipolar transistor but we used a BC337 which is equivalent in this application.

For the external 5V power supply we are using a tiny dc-dc converter module. These can be adjusted to provide the required voltage and are very reliable and cheap (on eBay).

Note that this sensor requires a 24 hour 'burn in' period and that it does get slightly warm to the touch in normal use.

Software

Our software drives the correct voltages to the sensor and then takes a reading. The whole cycle takes 2.5 minutes, so we are not going to get any updates quicker than this.

Our software also monitors the lowest reading seen and the highest reading seen. If any readings appear outside these limits, the code sends a warning message to our Home Control System (HCS) and this logs the new values seen. The software also recalibrates itself based on these new values.

Testing & Calibration

The main issue with this sensor is that it isn't calibrated so we had to try and acheive some form of calibration. The normal CO levels found in the air are zero (0ppm). The maximum recommended indoor level is 9ppm. Before you try to cailbrate the CO sensor, you must put it through the 'burn in' process. This involves letting it run for 24 hours. Whilst doing this we tracked the values coming back from our sensor and we saw significant changes during this burn in period.

CO sensor readings
After 48 hours we tried to calibrate the sensor by just watching the values coming back from the sensor in a normal room in our house. We plotted the values in a graph and it was clear that the gas boiler (below the room we are testing in) was having an impact on the sensor values. It is very sensitive! In the graph below you can see when the boiler came on, was switched off and then switched back on again. It is raising the CO level slightly and the CO takes a while to disperse and the values to drop.

To try and understand the behaviour of the sensor better we put it inside a large upside-down jug with a burning nightlight candle. The values went up significantly. As the candle burnt up all the oxygen, it dimmed and eventually went out. This obviously produces carbon monoxide. We then left it to for the CO to diffuse through any gaps and logged the readings to see where settled. After some time, the value was down to around 800 and we then removed the jug. The values then fell rapidly and stopped at around 270.

This is a graph plotting values logged by our smart home over time:

Graph - T.B.C.

We assume the lowest value seen represents 0ppm but we don't know what the highest value seen is. We are also assuming the sensor provides a linear response to CO present. The challenge is to try and work out an algorithm that gives useful values. We made the assumption that the highest value we see in normal operation through the course of a few days would be about 5ppm. We have done this because our sensor doesn't have to be super accurate and there is an element of error in the sensor itself anyway. All we are trying to do is get a meaningful reading that we can use to assess how safe out home is.

Having established a basic algorithm we are going to leave the sensor for a few weeks and see how well it works. If we see a level above 9ppm then our Home Control System (HCS) will generate an alert and trigger the alarm system.

Summary

This sensor seems to work really well and it is very sensitive. Calibration aside, it is perfect for our smart home application as we are only looking to use it to detect abnormal CO levels.

Share ...
We are on ...
Facebook Twitter
YouTube Flickr Follow us on Pinterest