Go Down

Topic: Help with methane gas sensor MQ-4 (Read 417 times) previous topic - next topic


Aug 22, 2019, 11:43 pm Last Edit: Aug 22, 2019, 11:48 pm by ItaloXXXX
Hi, I need your help. How can I transform the value analog output voltage (0 to 1023) to PPM (parts per million)?


Aug 22, 2019, 11:54 pm Last Edit: Aug 22, 2019, 11:58 pm by jremington
You have to first "burn in" the sensor for 72 hours or more, as described in the MQ-4 data sheet, then calibrate it by exposing it to known concentrations of methane in dry air.

The sensor responds to other gases, which if present will make the calibration useless.


Thank you. But, how can I show, mathematically, the result (analog value) in PPM?


Aug 23, 2019, 05:33 am Last Edit: Aug 23, 2019, 05:34 am by jremington
To convert analog readings to PPM, you use the scale factor and offset that you determine when you calibrate the sensor.

Code: [Select]
float ppm = scale*analogRead(pin)+offset;


Seems the sensor is not that linear (never used one).
With the graph from the datasheet you can try to convert to PPM with multiMap, before final calibration.


The nonlinearity in response is the least of the sensor's problems.


I'd agree - these are really combustible gas sensors , they suffer with drift and don't return to the same output after detecting gas ( esp high concentrations ) . I would only use to detect a rapid change where absolute values don't matter .

Go Up