MQ Sensor Curve

Hi guys

I have a MQ2 sensor and have been using the following tutorial (MQ-2 Smoke/LPG/CO Gas Sensor Module | Sandbox Electronics), which seems to be working fine, as is.

My question is with regards to the calculation of the curve for a particular gas. How have the curves being calculated?

float           LPGCurve[3]  =  {2.3,0.21,-0.47};  //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent"
                                                    //to the original curve. 
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) 
float           COCurve[3]  =  {2.3,0.72,-0.34};    //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent" 
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000,  0.15) 
float           SmokeCurve[3] ={2.3,0.53,-0.44};    //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent" 
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.53), point2: (lg10000,  -0.22)                                                     
float           Ro           =  10;                 //Ro is initialized to 10 kilo ohms

I have used web plot digitizer to extract the values from the graph (see attached), but I’m still am not sure how the curve was calculated.

If we take the LPG curve for example (float LPGCurve[3]={2.3,0.21,-0.47};), log(200) = 2.3, where are the values 0.21 and -0.47 derive from.

Any help will be hugely appreciated.

Thank you in advance!

MQ-2.pdf (60.6 KB)

A slope is typically deltaY/deltaX.

With the logarithmic X axis this could become
slope = (y2-y1)/(log(x2)-log(x1));
Check yourself.