MQ-6 Sensor (Flammable Gases and other gases) usage with Arduino R4 Wi-Fi

AndroidCrypto
4 min readAug 11, 2024

--

The Arduino Rev 4 Wi-Fi microcontroller is the perfect choice when collecting and analyzing sensor data from the MQ-6 sensor module. This article is part of several tutorials about connecting MQ-x sensors to the Arduino device. You find an overview about the series and available articles here.

MQ-6 Sensor (Front and Back)

Please find the technical data and wiring of the sensor and the OLED display in the overview article.

Arduino Uno R4 Wi-Fi and MQ-6 Sensor setup

Detectable gases with this Sensor

The sensor is designed to detect these gases and their concentration in the air: Hydrogen (H2), Liquid Petroleum Gas (LPG), Methane (CH4), Carbon Monoxide (CO) and Alcohol.

Reading the gas concentration

The MQ-Sensor series offers to read several gases with one sensor, but how does this work ? I write an article about this topic: MQ Sensors Series Read the Gas Concentration with Arduino R4 Wi-Fi. I know it sounds strange, but it is really important to read the datasheet for your specific sensor to understand what gases it can detect.

Type of Sensor

This sensor is using a heater to bring the sensor plate in a defined temperature mode for measuring. As it takes some time to heat the sensor, this sensor is not suitable for a “sleeping mode” of the microcontroller device. Secondly, the heater’s power consumption less than 950 mW, so it seems not a good choice for battery or solar-powered devices. Due to these facts, the sensor should be driven by a regular power supply.

Important Burn-In Period of new MQ-6 Sensors

You may think that it is not important to run a “Burn-In-Period” but this is essential to get good results. An MQ-6 Sensor is a sensor with a heater element with a resistor that resistance depends on the gas concentration in the air. When these sensors are “off” electricity for some days or months (e.g. produced in China, stored for some months, send by ship to Europe) the surface of the resistor isn’t calibrated anymore. You need to run the sensor for about 48 hours (2 days !) with 5 Volt to “burn-in” the resistor (again). Don’t trust the measures of the sensor without the burn-in period.

Usage of the MQ-6 Sensor together with other sensors like a DHT11 Temperature Sensor

As the MQ-6 Sensor is using a heater (the sensor itself can heat up to 55–60 degrees Celsius), you should NOT place a temperature sensor beneath the MQ-6 Sensor to avoid any wrong measurements.

General note on different gases measurement with one Sensor

Although the MQ-6 gas sensor detects 5 different gases, the base for all values is one value (the resistance of the sensor that results in different voltage levels). The concentration of a specific gas is calculated by the sensor profile, but if e.g. the Carbon Monoxide gas concentration goes up for 10 percent, the value for Alcohol will rise for 10 percent as well. This sensor can be used as a smoke sensor. Please keep in mind that the alcohol concentration in the breath air will be different to the one in the blood, so don’t rely on the measured values.

Display a Timeline of Sensor data on ThingSpeak.com

The sketch includes code for periodically uploading the measured gas values to a ThingSpeak channel. This gives an easy way to monitor your sensor from anywhere. If you don’t want to use the service, or you cannot connect your Arduino with a local Wi-Fi network, simply comment out the WI-FI-connection and “updateThingSpeakChannel” calls. For details, see the overview article.

MQ-6 Sensor LPG gas reading

This is a typical curve when the sensor wasn’t used for some time — the first readings are always much too high. After some hours, the data will normalize (“burn-in”).

Output on the Serial Monitor

|    H2    |    LPG   |   CH4    |    CO    |  Alcohol |
| 0.67 | 0.75 | 1.29 | 6.66 | 7.56 |
| 0.67 | 0.75 | 1.29 | 6.63 | 7.53 |

How can I test the sensor ?

The easiest way to test the sensor is by using an opened bottle with high concentrated alcohol near to the sensor. Just hold the sensor to the bottle opening and see that the gas readings will rise. Another way is by using a cigarette lighter and push the gas button near the sensor.

Where can I buy the sensor ?

My favorite seller for these sensors is AliExpress — here is a link to a search page for an MQ-6 sensor module (please don’t buy the bare sensor to avoid additional wiring).

Get the complete source code of this tutorial

The code is available in my GitHub repository https://github.com/AndroidCrypto/Arduino_Uno_R4_WiFi_MQ_Sensors_Series/tree/main/ArdUno4_MqUnifiedSensors_MQ_6_ALL_OLED_ThingSpeak

Thank you for reading and “Happy coding”.

--

--