myPressure.setModeBarometer();// Measure pressure in Pascals from 20 to 110 kPa
myPressure.setOversampleRate(7);// Set Oversample to the recommended 128
myPressure.enableEventFlags();// Enable all three pressure and temp event flags
pinMode(ledGood,OUTPUT);
pinMode(ledWarning,OUTPUT);
//Set math model to calculate the PPM concentration and the value of constants
MQ135.setRegressionMethod(1);//_PPM = a*ratio^b
MQ135.init();
Serial.print("Calibrating please wait.");
floatcalcR0=0;
for(inti=1;i<=10;i++)
{
MQ135.update();// Update data, the arduino will be read the voltage on the analog pin
calcR0+=MQ135.calibrate(RatioMQ135CleanAir);
Serial.print(".");
}
MQ135.setR0(calcR0/10);
Serial.println(" done!.");
if(isinf(calcR0)){Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply");while(1);}
if(calcR0==0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply");while(1);}