mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-07-26 06:01:03 +03:00
Extend API for optional correction factor
This commit is contained in:
@ -79,6 +79,7 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||
float correctionFactor = 0; // Optional environmental correction
|
||||
|
||||
/*
|
||||
Exponential regression:
|
||||
@ -90,19 +91,19 @@ void loop() {
|
||||
smoke | 30000000 | -8.308
|
||||
*/
|
||||
MQ4.setA(3811.9); MQ4.setB(-3.113); // Configure the equation to to calculate CH4 concentration
|
||||
float LPG = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
float LPG = MQ4.readSensor(false, correctionFactor); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
|
||||
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configure the equation to to calculate CH4 concentration
|
||||
float CH4 = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
float CH4 = MQ4.readSensor(false, correctionFactor); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
|
||||
MQ4.setA(200000000000000); MQ4.setB(-19.05); // Configure the equation to to calculate CH4 concentration
|
||||
float CO = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
float CO = MQ4.readSensor(false, correctionFactor); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
|
||||
MQ4.setA(60000000000); MQ4.setB(-14.01); // Configure the equation to to calculate CH4 concentration
|
||||
float Alcohol = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
float Alcohol = MQ4.readSensor(false, correctionFactor); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
|
||||
MQ4.setA(30000000); MQ4.setB(-8.308); // Configure the equation to to calculate CH4 concentration
|
||||
float Smoke = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
float Smoke = MQ4.readSensor(false, correctionFactor); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||
|
||||
Serial.print("| "); Serial.print(LPG);
|
||||
Serial.print(" | "); Serial.print(CH4);
|
||||
|
Reference in New Issue
Block a user