
Right from the time of industrial age, we mankind have been rapidly developing. With every progress we also pollute our environment and eventually degrading it. Now global warming is an alarming threat and even the air that we breathe are getting critical. So air quality monitoring has also started to gain importance. So in this article we will learn how to use any MQ series gas sensor with Arduino and showing the output in PPM (parts per million). PPM is also expressed as milligrams per litre (mg/L). These sensors are commonly available and are also reliable for measuring different types of gas shown below
MQ-series Gas sensors
- Carbon Dioxide (CO2) : MG-811
- Carbon Monoxide (CO): MQ-9
- Total Volatile Organic Compounds (TVOCs): CCS811
- Equivalent Carbon Dioxide (eCO2): CCS811
- Metal Oxide (MOX): CCS811
- Ammonia: MQ-137
- Air Quality: MQ-135
- LPG, Alcohol, Smoke: MQ2
We have already used MQ2 for smoke sensing and MQ-135 for Air quality monitoring project. Here I will be using the MQ-137 sensor from sainsmart to measure ammonia in ppm. With the sensor in hand I went through all the available tutorials and found that there has no proper documentation on how to measure the gas in ppm. Most tutorials either deal with only the Analog values or introduce some constants which are not reliable for measuring all type of gas. So after fiddling around online for a long time I finally found how to use these MQ series gas sensors to measure ppm using Arduino. I am explaining things from the bottom without any libraries so that you can use this article for any Gas sensor available with you.
Preparing your Hardware:
The MQ gas sensors can either purchased as a module or just as a sensor alone. If your purpose is to measure only ppm then it’s best to buy the sensor alone since the module is good for only using the Digital pin. So if you have purchased the module already then you have to perform a small hack which will be discussed further. For now, let’s assume you have purchased the sensor. The pinout and connection of the sensor is shown below
As you can see you just have to connect one end of ‘H’ to supply and the other end of ‘H’ to ground. Then combine both A’s and both B’s. Connect one set to supply voltage and the other to your analog pin. The resistor RL plays a very important role in making the sensor work. So make a note of which value you are using, a value of 47k is recommended.
If you have already purchased a module, then you should track your PCB traces to find the value of your RL in the board. Grauonline has already done this work for us and the circuit diagram of the MQ gas sensor board is given below.
As you can see the resistor RL (R2) is connected between the Aout pin and the ground, so if you are having a module the value of RL can be measured by using a multimeter in resistance mode across Vout pin and Vcc pin of the module. In my sainsmart MQ-137 gas sensor the value of RL was 1Kand was located here as shown in the picture below.
However, the website claims that it provides a variable pot of RL which is not true as you can clearly see in the circuit diagram, the pot is used to set the variable voltage for op-amp and has nothing to do with RL. So we have to manually solder the SMD resistor (1K) shown above and we have to use our own resistor across the Ground and Vout pin which will act as RL. The best value for RL will be 47K as suggested by datasheet hence we are going to use the same.
Approach to Measure PPM from MQ Gas Sensors:
Now that we know the value of RL lets proceed on how to actually measure ppm from these sensors. Like all sensors the place to start is its datasheet. The MQ-137 Datasheet is given here but make sure you find the correct datasheet for your sensor. Inside the datasheet we are need only one graph which will be plotted against (Rs/Ro) VS PPM this is the one that we need for our calculations. So gab it and keep it someplace handy. The one for my sensor is shown below.