Showing posts with label MQ2. Show all posts
Showing posts with label MQ2. Show all posts

Tuesday, September 6, 2016

Arduino_MQ2_gas_sensor

The MQ2 gas sensor is sensible to Methane, Butane, LPG and Smoke and is the first sensor from the Arduino Gas sensor kit for Arduino that i tested.

The script below (also avalable as codebender to run immediate) is used to read the analog value (A0) and the digital signal (connected to D12)


/* 2016 MQ-2 GAS Sensor  JanJeronimus
Gets digital and analog value from gas sensor every second
Writes time [ uptime millis() ]  , 
 digital gas sensor and
 analog gas sensor value to the serial port
*/

const int gasPinA = A0 ; //GAS sensor Analog output pin to Arduino analog A0 pin
const int gasPinD = 12; //GAS sensor Digital output pin to Arduino

int val = 0;     // variable to store the Digital read value

void setup()
{
pinMode(gasPinD, INPUT);
Serial.begin(9600); //Initialize serial port - 9600 bps
}

void loop()
{
Serial.print( "Time " ) ;
Serial.print( millis() ) ;
Serial.print( " , Digital " ) ;
Serial.print( val ) ;
Serial.print( " , Analog " ) ;
Serial.println( analogRead(gasPinA) );
delay(1000); // Print value every 1 sec.
}
To get a reliable signal a burn-in time is needed.
When using the sensor for the first time (without burn-in time) the analog signal indicates a value of 130 and in a few minutes dropping to 80 and slowly dropping more.
If opening gas from a cigarette lighter near the sensor the signal rises to +/- 340. This indicates that the sensor is working. After a few hours the analog signal has dropped to 27. If spraying some aftershave on my hand and immediate putting my hand near the sensor the signal also rises to this value. In this case it takes more time before the signals drops down again.

Monday, September 5, 2016

Arduino_Gas_Sensor_set

Received a set of 9 gas sensor for Arduino from Aliexpress ( China ).
You can find a table with some details of the gas sensors in this post.
MQ-8 MQ-9 MQ-135





MQ-4 MQ-5 MQ-6


MQ-2 MQ-3 MQ-4

The  PCBs for the sensors all look the same with pins
  • A0 Analog signal
  • D0 Digital signal (treshhold controlled by pot meter)
  • GND Ground
  • VCC Power (+5V)
The PCB has a pot meter and two leds
  • Power led
  • D0 level led
The D0 level led turns on if the analog signal comes above the threshold regulated by the pot meter. 
< ThresholdLed OffD0 pin signal  1
>ThresholdLed OnD0 pin signal 0

Quick scanning the info also learned me that the MQ-7 needs alternating 60 seconds 5v, 90 seconds 1.4 volt ( http://forum.arduino.cc/index.php?topic=239693.0 ) . The hardware for all the sensors looks the same but it seem there are some differences! 
Also storage conditions (when not in use) of these sensors seem to be important.
When starting this project i expected that i could test some of these sensors and publish this the same day on my blog. After collecting some info i decided to make this a general info start article and publish the test in separated articles.

Burn-in time

Reading more information i found that also  burn-in time is needed for this sensors Some datasheets use the term "preheat", but it is the time to burn-in the sensor. This is meant to make the sensor readings more consistent. 
A time of 12 or 24 hours is usually used for the burn-in time.The Burn-in is achieved by applying normal power to the sensor (to the heater and with the 'A' and 'B' pins connected, and with a load-resistor). In some special cases a specific burn-in is needed. See the datasheet if the sensor needs such a specific burn-in.
After the "burn-in time", the heater needs to be on for about 3 minutes before the readings become stable.
The sensors that use 5V or 6V for the internal heater do get warm. They can easily get 50 or 60 degrees Celsius. If it is used in a battery operated device, a transistor or logic-level mosfet could also be used to switch the heater on and off. I also want to "burn-in" with a power supply and not with batteries
After creating the circuit it could take more than 24 hours to get the first consistent measurements. 
As details can be found in the datasheets of the sensors (Links included in the table in this article).

Test gas

To test the sensors some gasses would be needed. Some ideas to test:
Ethanol (Alcohol) 
Butane (Weed burner gas)
Gas from a cigarette lighter
Smoke ( from a fire )
Perfume / Aftershave
Ammonia
Car exhaust
Car fuel
Hydrogen (created by electrolysis or metal with strong acid)

My gas sensors:

SensorGasDatasheetTested
MQ2Methane, Butane, LPG, Smoke Datasheet
Y
MQ3Alcohol, Ethanol, SmokeDatasheet
n
MQ4Methane, CNG GasDatasheet
n
MQ5Liquified gas, Coal gasDatasheet
n
MQ6LPG, Isobutane, PropaneDatasheet
n
MQ7Sensitive Detector CO gas
(Needs alternating 60 seconds 5v, 90 seconds 1.4 volt)
http://forum.arduino.cc/index.php?topic=239693.0

Datasheet
n
MQ8HydrogenDatasheet
n
MQ9CO, Flammable gassesDatasheet
n
MQ135Air quality / Hazardous gas
(Benzene, Alcohol, smoke, NH3)
Datasheet
n

Item in the first column "Sensor" will links to the "blog label" of the sensor to find all articles in this blog labeled with this sensor
"Datasheet" will link to a datasheet of the sensor.
"Tested" will updated with a link to the blog article with the test.
I hope to publish in the next blog article a small test of the MQ2 sensor!

Links