Friday, May 2, 2014

Propane Gas Sensor Using the Arduino Uno

In this latest project I use the MQ6 propane gas sensor with the Arduino Uno to sense propane gas concentration in the air.

This sensor has a heater that requires about 150mA for 90s to take a reading. The Uno can't supply this current so I use a KA278R05 voltage regulator to provide it, with a 12v DC power supply providing the input power for the voltage regulator. The KA278R05 has an enable pin which I drive high using digital pin 8 of the Uno to enable the sensor for the 90 seconds it needs to be on in order to take a stable reading. I read the voltage level signal output of the MQ6 each second and the final stable value right at the 90s point after activating the sensor using analog input pin 0.

The schematic for the circuit I used:

The breadboard layout using the great tool from Fritzing:

The first set of results from clean air (no propane) graphed in excel. Here the measurement stabilized at around 256 after 90s:

The second set of results from air with a bit of propane graphed in excel. I put the sensor inside a grill with the lid closed and gave a small puff of propane, and without any flame. I recommend extreme caution if you try this. Just a tiny puff of propane, and in an outside area with good ventilation is how I did it. Have all the circuitry except the sensor outside the grill area. With this test the measurement stabilized at around 739 after 90s, which is almost 3 times higher than with clean air. Keeping in mind this was a very small puff of propane, this sensor is very sensitive:

Below is the sketch I used to drive the Uno for this test. I use a simple finite state machine to manage the state of the sensor.

#define MQ6_HEATER_TIME_MILLIS 90000

int lpGas;

typedef enum {

MQ6_STATE mq6State = ST_MQ6_OFF;

unsigned long mq6SwitchTimeMillis;
unsigned long mq6NextReadingTimeMillis;
unsigned long lpGasStartTimeMillis;
unsigned long startMillis;

void setup(){
  startMillis = millis();
  // start 10s after power up
  lpGasStartTimeMillis = 10000; 

  // print headers for CSV output
  Serial.println("LP Gas Level");

void loop(){

// uses a simple finite state machine to manage states of the MQ6 sensor
void readLPGas(){
    case ST_MQ6_OFF :
      if(millis() > lpGasStartTimeMillis){
        digitalWrite(MQ6_POWER_ON_DIGITAL_OUT_PIN, HIGH);

        mq6State = ST_MQ6_CYCLE_0_HIGH;
        mq6SwitchTimeMillis = millis() + MQ6_HEATER_TIME_MILLIS;

    case ST_MQ6_CYCLE_0_HIGH :
      if(millis() > mq6NextReadingTimeMillis) {
        lpGas = analogRead(MQ6_LP_GAS_LEVEL_MEASURE_ANALOG_IN_PIN);

        Serial.print((millis() - startMillis)/1000);

        mq6NextReadingTimeMillis = millis() + MQ6_SAMPLE_PERIOD_MILLIS;

      if(millis() > mq6SwitchTimeMillis){
        digitalWrite(MQ6_POWER_ON_DIGITAL_OUT_PIN, LOW);

        mq6State = ST_MQ6_DONE;

    case ST_MQ6_DONE :


If you are interested in how this type of sensor can be integrated into a broader solution that includes notification of combustible gasses on a users Android phone see Receive Alerts of Combustible Gasses

You can find a PCB breakout for this sensor if you are ready to create something more polished.

Let me know if you build any cool enhancements to this. Have fun!


  1. Would this setup work for the mq methane or mq131 ozone sensors?

  2. Hi Alexis, I briefly checked out the MQ4 / MQ135 at and it also needs a 5V heater voltage and has an comparable internal heater resistance of 33 ohms so the setup above for the MQ6 should work fine. You will have to experiment with the length of time it takes for your measurement value to stabilize. 90s worked well for my application of the MQ6, but you may find a different time works for your project / sensor. I also had a look at the MQ131 at and it needs 5V for its 31 ohm resistance so my circuit would work for that as well. Don't forget to preheat your sensors for the recommended times shown in each datasheet. Have fun.

  3. Tank Level Sensor are commonly used for tank level measurement and control. They offer cost-effective, continuous level measurement and a wide range of features to handle almost any tank level management task. A wide variety of material combinations make them compatible with most liquid media and challenging fluids. Tank Level Sensors are available in multiple sensing technologies including float, radar and ultrasonic liquid level sensing.
    Tank Level Sensor

  4. Are you looking for a level sensor. You will find various types of Tank level sensor in market, where some of them are cheap and some of them are too costly to buy and also you have to think about price. Icon process Control offering you the best quality Tank Level Sensor with an affordable price.