Pages: [1]   Go Down
Author Topic: MQ-2 Gas sensor , how to get sensor value  (Read 1636 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:

void setup() {
  Serial.begin(9600);
}

void loop() {

 sensorValue = analogRead(A0);  //tried 14 with same results...         
 Serial.print("sensor = " );                       
 Serial.println(sensorValue);     
  delay(10);                     
}


At my serial box i get only 1023.... this is it... If i messure the voltage with voltmeter , it works , it increases volts when it detects gas... from 5.10V it goes to 5.16V

How can i make it work ? thanks !
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:

void setup() {
  Serial.begin(9600);
}

void loop() {

 sensorValue = analogRead(A0);  //tried 14 with same results...         
 Serial.print("sensor = " );                       
 Serial.println(sensorValue);     
  delay(10);                     
}


At my serial box i get only 1023.... this is it... If i messure the voltage with voltmeter , it works , it increases volts when it detects gas... from 5.10V it goes to 5.16V

How can i make it work ? thanks !

That sounds a little confusing. Any voltage equal to or over 5.000 VDC applied to a analog input pin will return only 1023 counts. Valid DC voltage range for a analog input pin is 0 to 5vdc only. So 5.1V and 5.16V will both return 1023 values. Maybe a link to your sensor will help us help you.

Lefty
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tutorial http://arduinotronics.blogspot.gr/2012/03/gas-sensor-tutorial.html
Datasheet http://www.pololu.com/file/0J309/MQ2.pdf
Tutorial http://www.geeetech.com/wiki/index.php/Gas_Sensor_-_MQ-2
« Last Edit: December 07, 2012, 07:50:29 pm by invader7 » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What value load resistor are you using with your sensor? Sounds like it's best to use a 20K pot as a load resistor so you can 'calibrate' the sensor such that it's maximum value will be less the 5vdc output that the arduino analog input pin can handle correctly.

Lefty

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used 20kΩ resistor... im woried about connecting it correct... which way is the correct ?

this http://arduinotronics.blogspot.gr/2012/03/gas-sensor-tutorial.html is a littel confusing...
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you can post a drawing on how you specifically wired it up including wiring to the arduino board and any external DC power supply, perhaps we can find a problem.

Lefty
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1016
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think your resistor is too high. Try using 2k.
Do you know the basic information ? http://playground.arduino.cc/Main/MQGasSensors
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was missing the 20k resistor between "Out" pin and GND , now i get value 730-780 when using analogread and >1000 when sensor is detecting a gas ! thanks guys , my bad....
Logged

Pages: [1]   Go Up
Jump to: