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.
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.
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.
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.
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..
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.
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.