I've connected it like this
pin H(left,middle) to 5V on arduino.
pin H(right,middle) to GND on arduino
pin A(left,top) to GND on arduino
pin B(right,top) to analog 0 on arduino with a 100K resistor
I am using this code:
unsigned int val = 0;
unsigned char PIN = 0;
void setup() {
Serial.begin(9600);
pinMode(PIN,INPUT);
}
void loop() {
val = analogRead(PIN);
Serial.println(val);
delay(500);
}
Don't set Pin 0 as an INPUT. The ANALOG INPUT pins (A0-A5) are set as inputs if you use them with analogRead().
I agree that your code is otherwise O.K. and you have a wiring problem. If the load resistor (RL) is set to 0 Ohms that will short the input to Ground and cause a 0 reading. If you have the pins confused you could have the input connected to a Heater terminal (H) with the other end of the heater connected to Ground. That would cause a 0 reading,
Ahh I see two problems. The analog in should be tied to V+, not ground. And unless you're testing this out hammered drunk, you'll want a resistor in the 5k-20k range. Also also, double check the datasheet, this is supposed to be driven at less that 5v; like 2.1v iirc...but it'll run at 5v.
It could of course be that you've burned out the platinum catalytic doped element due to either over-excitation or by introducing excessive "gas" (be it methane, ethane or whatever).
Also true, but IME it would have been very hard to burn it out under these conditions. I've splashed one with EtOH, ran it at 12VDC, etc etc, and I've yet to destroy one.
These do also have a 'burn in period if you want any sort of accuracy; 24-48 hours with the heater running.
There is a lot confusing information in this thread!
I have made a page in the Playground to avoid this kind of confusion: Arduino Playground - MQGasSensors
The MQ-3 requires +5V
The MQ303A requires 0.9V
Use a multimeter to test the resistance. The heater should have a some resistance, and the two 'A' pins and two 'B' pins should have almost no resistance.
Suppose the sensor is a MQ-3. The heater should be connected to 5V. If the heater is connected, the sensor should get warm after a few minutes. The +5V should be able to supply the current.
Connect both (not just one) 'A' pins to +5V, and connect both (not just one) 'B' pins to a resistor (resistor to ground). Start with 2k. After the burn-in time, you could make it 10k or more. The voltage over the resistor is connected to the analog input pin of the Arduino.
Hi,
as says the datasheet: http://www.sparkfun.com/datasheets/Sensors/MQ-3.pdf the preheat time must be over 24 hours (sensor connected to 5V )and after that you can start measure with the sensor, only than you can say it's stable.