MQ-2 gas sensor readings all wrong on Photon but on Arduino its reading fine?

Look at the datasheet. The specs state the sensor is meant for 5V and all diagrams and tables are based on the correct supply voltage.
Just because you get some readings does not mean that they are anywhere correct.
You need a defined temperature on the sensing setup to get defined results, other (lower) temperatures might produce some ionisation, but most definetly not enough to be relyable.

And in fact you are using a voltage divider, since your sensor represents an “inner resistance” (3k-30k) and your “load resistance” in shape of your pot.
So the sensed voltage will be the ratio between these two resistors where the sensor is a dynamic one.

Given these figures (min sensor resistance RS = 3k) your load resistor (RL) should not be any higher than 6.8k.

Vs = 5V * [RL / (RL + RS)]  // for RS = 3k & RL = 6.8k Vs will be 3.47V

4.7k would give you a range 3.09V (analogRead 3835) down to 0.67V (analogRead 830).

4 Likes

@ScruffR Thanks so much for this explanation! I am studying more about voltage dividers now. And what you said makes perfect sense. I’m guessing that If I take out the trimpot and place a 4.7k resistor, it should work right?

I’d say so, but to test is best :wink:
But with this you should at least be safe to not fry your pins.

1 Like

I am trying to integrate the MQ2 with a particle electron for air quality analysis. I have the following connections:

Sensor -> Electron
Vcc -> Vin (5V)
GND -> GND
AD -> B1
AD -> 4.7k Resistor -> GND
The Pot on the MQ2 is at the minimum 3k ohm position.

All I want is the ADC value from analogRead(B1); [ expecting values from 0-4095]

I am constantly getting a 0. Any thoughts?

Much appreciate the help.

My bad, it was a connection error.

Can RS/R0 be >10 in normal air?

R0 = RS_air/10.0; // The ratio of RS/R0 is 10 in a clear air

This statement confuses me. I am getting the RS/R0 ratio to be over 10 .

Setup:
4.7K resistor between AD of sensor and GND.
Pot on Sensor set to min (3K) position.