Go Down

Topic: Stable MQ2 readings even though no gas present...hardware or software flaw? (Read 624 times) previous topic - next topic

srpratt

Greetings!

I have built an exact replica of the MQ2 Smoke Sensor Breadboard setup from Derek Erb's post on the forum:
http://forum.arduino.cc/index.php?topic=150861.0

Here's where my problem lies:
* The values on my serial monitor are consistent, around 659 or so (assuming on analog scale of 0 to 1023) even when there is NO smoke in the room.  It would put it on a scale of 60% smoke density in the air...which definitely is NOT the case.
* When I remove the A0 input wire to the Arduino, the values drop and hover around 400...but shouldn't they go to zero?  Since there's no input?

I have my simple sketch below.

Code: [Select]
void setup()
{
  Serial.begin(9600); //Set serial baud rate to 9600 bps
}
void loop()
{
int val;
val=analogRead(A0); //Read Gas value from analog 0
Serial.println(val,DEC);//Print the value to serial port
delay(1000);
}


I feel like it's a hardware issue more than a software issue...anything see the problem?  I've attached a picture of the breadboard setup to this as well.


johnwasser

Did you let it heat for 24 hours before trying to get output?

Datasheet: http://www.seeedstudio.com/wiki/images/3/3f/MQ-2.pdf

        "Preheat time:  Over 24 hour"

http://playground.arduino.cc/Main/MQGasSensors
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

srpratt

Hey John.  I did an overnight burn to let it "set", and while it has been about 20 of the 24 hour burn-in time (the sensor does feel warm), I'm still getting similar values: 629, 630,628, etc.

Did you see anything in the wiring setup?




johnwasser

The wiring looks fine.

What number did you expect to get and why? 

Note that the resistance of different units can vary by a factor of 10 so you can't expect yours to provide the same numbers as anyone else's in clean air.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

knut_ny

What you experience is just as it should be: The resistance in that sensor is stable.  You can calculate it knowing the value of the serial resistor.
The datasheet will tell you how much R will change for a given ppm of 'gas'.
++++++++
That floating input can give any value. which is normal..
Ny

askjacob

Did you accidentally leave the internal pullup on for the input you are using? I did that my first time and got pretty much the same result... I think by default the pullup is enabled.

Try setting AO as an input no pullup just to force the issue and see how you get on.

somewhere in setup()

pinMode (AO, INPUT);

should do it.

Cheers
Jacob

knut_ny

I dont believe the above post is relevant, due to your saying that the 'open input'  indicates a floating.
Ny

askjacob

Well, in the simple sketch given above, pin AO status is not configured in any way... It is NOT safe to assume that just using readAnalog() will do anything with regards to port direction or pullup registers - it wont.

It cannot hurt to try what I suggested. I find sometimes it is best to not assume that the Arduino environment or microcontroller after reboot sets the pins in the state you want, but explicitly ensure they are in the state you need. Sure, once everything is working and you are struggling for code space you can start trimming it out and see if it still behaves, but for now be explicit.

Eliminate the possibilities and things you have control over when troubleshooting - then you can chase down all the other unknowns.


Go Up