-
Determining PPM Equation

Sensitivity curve of the MQ-4
This graph, taken from the device datasheet, depicts the MQ-4's sensitivity to gases. It's especially sensitive to CH4, the molecular term for methane, as shown above. Propane and butane gases are not included in the curve, even though they are both known components of LPG (which is second to methane in this curve).
The graph depicts the relationship between RS/R0 and gas concentration in parts-per-million on a log-log scale (PPM). The ratio of sensor resistance at target gas (RS) to sensor resistance in clean air (R0) is RS/R0 (R0). As a result, knowing RS/R0 allows us to calculate the gas concentration in PPM.
To derive a formula, we take two points on this graph. Later on, we'll use this formula in our Arduino sketch.
When RS/R0 = 1 and PPM = 1000, the most evident point appears. When RS/R0 is around 0.58 and PPM = 5000, the second point is reached. The formula begins with:

From the first point, we'll assign Y1 = 1, X1 = 1000, and from the second point, Y2 = 0.58, X2 = 5000. Substituting these values into the previous equation:

Changing Y to RS/R0 and X to PPM and solving for PPM:

In the presence of methane, the sensor resistance is RS, while in clean air, the sensor resistance is R0. R0 would be the simplest to figure out of the two. Using an ohmmeter, we measure the resistance of electrodes 1-6 or 4-3.

MQ4 Arduino Diagram
As can be seen, Aout is connected to one of the electrodes and a resistor RL in parallel. This indicates that the electrode resistance generates a voltage divider with RL, resulting in the following voltage at Aout:

The resistance of our target electrode, RS, fluctuates depending on the amount of methane present.
RL is an SMD resistor with the designation 102, by the way. This is equivalent to a 1k resistance.
So we apply this formula to get RS.