ostaquet / Arduino-MQ131-driver

Arduino driver for gas sensor MQ131 (Ozone / O3)
MIT License
65 stars 19 forks source link

Wrong Readings PPB #57

Closed Sebastian08155 closed 11 months ago

Sebastian08155 commented 1 year ago

Hello,

i use your code to simulate the Sensor (LOW CONSENTRATION).

But i got not exactly the same values (PPB) like you.

Here is the code:

--------------------------------------------------------------------------------------------------
// ----------O3 SENSOR-----------

int           sensorPin        = A0;        // Analog Input Pin A0.
float         R0               = 1917.22;   // R0 
float         sensorRead       = 0.0;    // Define variable for analog readings
float         RS               = 0;             // Define variable for sensor resistance
float         EnvCorrectRatio  = 0;   // Temperatur und Luftfeuchtigkeit korrektur.
float         ratio            = 0;           // Define variable for resistance ratio
float         VRL              = 0;          // Define variable for sensor voltage
float         VC               = 5.0;        // Supply Voltage
float         RL               = 1000000;   // Load Resistance(Units are Kilo Ohms)
double        O3               = 0;         // Ozon in Particles per Million
// ----------O3 SENSOR-----------

int Temperature = 20;
int Humidity = 65;

void setup(){
Serial.begin(115200);

}

void loop(){

sensorRead_O3 = analogRead(sensorPin_O3);
    VRL_O3 = sensorRead_O3 / 1024.0 * 5.0;

Serial.print("Spannung RL_O3 = ");
Serial.print(VRL_O3);
Serial.print(" Volt_O3\n");

    RS_O3 = (5.0 / VRL_O3 - 1.0) * RL_O3;

Serial.print("Widerstand RS_03 = ");
Serial.print(RS_O3);
Serial.print(" OHM_O3\n");

    if (Humidity == 60 && Temperature == 20) {
        EnvCorrectRatio_O3 = 1.0;
        }

    if (Humidity > 75) {                                      // For humidity > 75%, use the 85% curve 
        EnvCorrectRatio_O3 = -0.0141 * Temperature + 1.3109;
        }  
    if (Humidity  < 75 && Humidity > 45) {                    // For humidity > 45%, use the 55% curve
        EnvCorrectRatio_O3 = -0.0147 * Temperature + 1.377;
        }  
    if  (Humidity < 45 && Humidity > 30) {                    // For humidity > 30%, use the 40% curve
        EnvCorrectRatio_O3 = -0.0136 * Temperature + 1.4991;
        } 
        if  (Humidity < 30) {                                     // For humidity < 30%, use the 20% curve
        EnvCorrectRatio_O3 = -0.0141 * Temperature + 1.5623;
        }

  EnvCorrectRatio_O3 = 1.0;

Serial.print("EnvCorrectRatio_O3 = ");
Serial.print(EnvCorrectRatio_O3);
Serial.print("\n");

        ratio_O3 = RS_O3 / R0_O3 * EnvCorrectRatio_O3;
        O3 = (9.4783 * pow(ratio_O3, 2.3348));

Serial.print("O3 = ");
Serial.print(O3);
Serial.print(" PPB\n");

        O3 = O3 / 1000;

Serial.print("O3 = ");
Serial.print(O3);
Serial.print(" PPM\n");

delay(5000);  
}
------------------------------------------------------------------------------------

I got 25.68 PPB.

in your picture you got 7.95 PPB.

Please help !

if is possible for you to create a library for the MQ-7 Sensor too?

Many Thanks, Sir !

ostaquet commented 1 year ago

Hi @Sebastian08155,

The MQ-131 is a semiconductor sensor. It detect gases by a chemical reaction that takes place when the gas comes in direct contact with the sensor. By burning the gas (the air), some particle of the resulting reaction are in contact with the sensor and the resistance of the sensor evolves.

It means it is important to preheat the sensor to remove all manufacturing residues. Did you preheat your sensor?

You must also perform a calibration of your R0 (the basic resistance of the sensor). I see in your code that your are using a R0 of 1917.22 Ohms. It is the default value of the library (which is coming from the calibration of my sensor). It is unlikely that you have the exact same calibration curve than mine ;-). Did you proceed to the calibration of your sensor?

KR, Olivier