mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-07-04 03:11:03 +03:00
Compare commits
16 Commits
codex/actu
...
codex/veri
Author | SHA1 | Date | |
---|---|---|---|
d2e0be3651 | |||
3cd2fd8e7d | |||
2bdb91c1b5 | |||
42689ff5f3 | |||
ea48475a3c | |||
c066b2ec1c | |||
46d416abad | |||
f7fae4e03c | |||
c9c1549600 | |||
af291df03d | |||
748ff3055c | |||
a6abda567f | |||
92f3c30e82 | |||
da3adb7335 | |||
14b0f908f3 | |||
6376cfc11f |
@ -68,6 +68,7 @@ float ppmCH4 = MQ4.readSensor();
|
|||||||
* AO -> Analog Output of the sensor
|
* AO -> Analog Output of the sensor
|
||||||
##### Data of board that you should have
|
##### Data of board that you should have
|
||||||
* RL Value in KOhms
|
* RL Value in KOhms
|
||||||
|
* If the sensor uses a different supply voltage than the ADC reference, call `yourSensor.setVCC(<voltage>);`
|
||||||
##### Graph
|
##### Graph
|
||||||

|

|
||||||
#### RS/R0 value (From datasheet of your sensor)
|
#### RS/R0 value (From datasheet of your sensor)
|
||||||
@ -173,6 +174,10 @@ Examples/MQ-board.ino
|
|||||||
* [Data sheets](https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Datasheets) - Curves and behavior for each sensor, using logarithmic graphs.
|
* [Data sheets](https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Datasheets) - Curves and behavior for each sensor, using logarithmic graphs.
|
||||||
* [Main purpose](https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/bg.jpg) - Every sensor has high sensibility for a specific gas or material.
|
* [Main purpose](https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/bg.jpg) - Every sensor has high sensibility for a specific gas or material.
|
||||||
|
|
||||||
|
## Issues
|
||||||
|
|
||||||
|
Consulte [docs/issues.md](docs/issues.md) para un resumen de los problemas abiertos y sus soluciones.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Please read [CONTRIBUTING.md](https://github.com/miguel5612/MQSensorsLib/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
Please read [CONTRIBUTING.md](https://github.com/miguel5612/MQSensorsLib/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
||||||
|
33
docs/issues.md
Normal file
33
docs/issues.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Issues y soluciones
|
||||||
|
|
||||||
|
Este documento resume los problemas reportados en el repositorio y las soluciones propuestas o implementadas.
|
||||||
|
|
||||||
|
## Abiertos
|
||||||
|
|
||||||
|
### #75 MQ-3 sensor and CH4 gas reading 'ovf' failure
|
||||||
|
**Estado:** resuelto en la rama `main`
|
||||||
|
|
||||||
|
El usuario reporta desbordamiento ("ovf") al utilizar valores muy altos en `setA` y `setB` para leer CH4 con un sensor MQ-3. La solución propuesta es revisar los valores utilizados en `setA` y `setB`, ya que `2*10^31` en C++ no corresponde a `2e31`. Se recomienda usar notación exponencial (`2e31`) o `pow(10,31)` y comprobar que los parámetros no excedan el rango de `float`.
|
||||||
|
|
||||||
|
**Actualización:** se añadieron validaciones de entrada, predicción de desbordamiento mediante logaritmos y verificación del resultado final para evitar valores "ovf" incluso con coeficientes muy altos. Las nuevas funciones limitan `setA` y `setB` y emplean cálculos en doble precisión.
|
||||||
|
|
||||||
|
### #74 possible error in the calculation formula for `_RS_Calc`
|
||||||
|
**Estado:** resuelto en la rama `work`
|
||||||
|
|
||||||
|
Se detectó que la resistencia del sensor se calculaba con `_VOLT_RESOLUTION` en lugar del voltaje de alimentación real. Se añadieron los métodos `setVCC` y `getVCC` y se modificaron las ecuaciones para usar `VCC`. Esta corrección se refleja en la versión 3.0.1 de la biblioteca.
|
||||||
|
|
||||||
|
### #70 Parameters to model temperature and humidity dependence
|
||||||
|
**Estado:** abierto
|
||||||
|
|
||||||
|
Los usuarios solicitan factores de corrección para temperatura y humedad aplicables a otros sensores (MQ-4 y MQ-8) además del MQ-135. Aún no se han añadido estos parámetros. Se anima a la comunidad a contribuir con implementaciones y ejemplos.
|
||||||
|
|
||||||
|
### #67 Sensor won't finish the Calibration process if done in clean air
|
||||||
|
**Estado:** abierto
|
||||||
|
|
||||||
|
Se reporta que la calibración se detiene mostrando un mensaje de "Conection issue" cuando se intenta calibrar el sensor MQ-135 en aire limpio. La recomendación del mantenedor es revisar la conexión física y probar el sensor con un programa básico para asegurar su correcto funcionamiento antes de usar la librería. Aún no se ha implementado un cambio en el código.
|
||||||
|
|
||||||
|
|
||||||
|
## Cerrados destacados
|
||||||
|
|
||||||
|
Para obtener más información sobre todos los issues cerrados, consulte la página de [Issues en GitHub](https://github.com/miguel5612/MQSensorsLib/issues?q=is%3Aissue+is%3Aclosed).
|
||||||
|
|
@ -66,7 +66,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -80,8 +80,8 @@ void setup() {
|
|||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -79,8 +79,8 @@ void setup() {
|
|||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
@ -86,7 +86,7 @@ void setup()
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -100,8 +100,8 @@ void setup()
|
|||||||
MQ2.setR0(calcR0/10);
|
MQ2.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
//MQ2.serialDebug(true); uncomment if you want to print the table on the serial port
|
//MQ2.serialDebug(true); uncomment if you want to print the table on the serial port
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -79,8 +79,8 @@ void setup() {
|
|||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -59,8 +59,8 @@ void setup() {
|
|||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -67,7 +67,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -81,8 +81,8 @@ void setup() {
|
|||||||
MQ131.setR0(calcR0/10);
|
MQ131.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ131.serialDebug(true);
|
MQ131.serialDebug(true);
|
||||||
Serial.println("Ignore Ratio = RS/R0, for this example we will use readSensorR0Rs, the ratio calculated will be R0/Rs. Thanks :)");
|
Serial.println("Ignore Ratio = RS/R0, for this example we will use readSensorR0Rs, the ratio calculated will be R0/Rs. Thanks :)");
|
||||||
|
@ -55,7 +55,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -69,8 +69,8 @@ void setup() {
|
|||||||
MQ135.setR0(calcR0/10);
|
MQ135.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
Serial.println("** Values from MQ-135 ****");
|
Serial.println("** Values from MQ-135 ****");
|
||||||
Serial.println("| CO | Alcohol | CO2 | Toluen | NH4 | Aceton |");
|
Serial.println("| CO | Alcohol | CO2 | Toluen | NH4 | Aceton |");
|
||||||
|
@ -106,7 +106,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -120,8 +120,8 @@ void setup() {
|
|||||||
MQ135.setR0(calcR0/10);
|
MQ135.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ135.serialDebug(true);
|
MQ135.serialDebug(true);
|
||||||
// Set delay between sensor readings based on sensor details.
|
// Set delay between sensor readings based on sensor details.
|
||||||
|
@ -67,7 +67,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -81,8 +81,8 @@ void setup() {
|
|||||||
MQ135.setR0(calcR0/10);
|
MQ135.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ135.serialDebug(true);
|
MQ135.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -74,8 +74,8 @@ void setup() {
|
|||||||
MQ136.setR0(calcR0/10);
|
MQ136.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ136.serialDebug(true);
|
MQ136.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -78,8 +78,8 @@ void setup() {
|
|||||||
MQ2.setR0(calcR0/10);
|
MQ2.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
MQ2.serialDebug(true);
|
MQ2.serialDebug(true);
|
||||||
|
@ -66,7 +66,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -80,8 +80,8 @@ void setup() {
|
|||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -78,8 +78,8 @@ void setup() {
|
|||||||
MQ303.setR0(calcR0/10);
|
MQ303.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ303.serialDebug(true);
|
MQ303.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -81,8 +81,8 @@ void setup() {
|
|||||||
MQ309.setR0(calcR0/10);
|
MQ309.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ309.serialDebug(true);
|
MQ309.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -69,8 +69,8 @@ void setup() {
|
|||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
Serial.println("*************** Values from MQ-4 **********************");
|
Serial.println("*************** Values from MQ-4 **********************");
|
||||||
|
@ -54,7 +54,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -68,8 +68,8 @@ void setup() {
|
|||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
Serial.println("** Values from MQ-4**********");
|
Serial.println("** Values from MQ-4**********");
|
||||||
|
@ -65,7 +65,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -79,8 +79,8 @@ void setup() {
|
|||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ4.serialDebug(true);
|
MQ4.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -79,8 +79,8 @@ void setup() {
|
|||||||
MQ5.setR0(calcR0/10);
|
MQ5.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ5.serialDebug(true);
|
MQ5.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -79,8 +79,8 @@ void setup() {
|
|||||||
MQ6.setR0(calcR0/10);
|
MQ6.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ6.serialDebug(true);
|
MQ6.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -86,8 +86,8 @@ void setup() {
|
|||||||
MQ7.setR0(calcR0/10);
|
MQ7.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ7.serialDebug(true);
|
MQ7.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -80,8 +80,8 @@ void setup() {
|
|||||||
MQ8.setR0(calcR0/10);
|
MQ8.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ8.serialDebug(true);
|
MQ8.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -69,8 +69,8 @@ void setup() {
|
|||||||
MQ9.setR0(calcR0/10);
|
MQ9.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
Serial.println("** Values from MQ-9 ****");
|
Serial.println("** Values from MQ-9 ****");
|
||||||
Serial.println("| LPG | CH4 | CO |");
|
Serial.println("| LPG | CH4 | CO |");
|
||||||
|
@ -67,7 +67,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
// ISSUE 44 - MQ9 needs a low/high temperature cycle like MQ7 #44
|
// ISSUE 44 - MQ9 needs a low/high temperature cycle like MQ7 #44
|
||||||
@ -101,8 +101,8 @@ void setup() {
|
|||||||
MQ9.setR0(calcR0/10);
|
MQ9.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ9.serialDebug(true);
|
MQ9.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -158,8 +158,8 @@ void setup() {
|
|||||||
Serial.print(MQ8calcR0/10); Serial.print(" | ");
|
Serial.print(MQ8calcR0/10); Serial.print(" | ");
|
||||||
Serial.print(MQ9calcR0/10); Serial.println(" |");
|
Serial.print(MQ9calcR0/10); Serial.println(" |");
|
||||||
|
|
||||||
if(isinf(MQ2calcR0) || isinf(MQ3calcR0) || isinf(MQ4calcR0) || isinf(MQ5calcR0) || isinf(MQ6calcR0) || isinf(MQ7calcR0) || isinf(MQ8calcR0) || isinf(MQ9calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(MQ2calcR0) || isinf(MQ3calcR0) || isinf(MQ4calcR0) || isinf(MQ5calcR0) || isinf(MQ6calcR0) || isinf(MQ7calcR0) || isinf(MQ8calcR0) || isinf(MQ9calcR0)) {Serial.println("Warning: Connection issue found, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(MQ2calcR0 == 0 || MQ3calcR0 == 0 || MQ4calcR0 == 0 || MQ5calcR0 == 0 || MQ6calcR0 == 0 || MQ7calcR0 == 0 || MQ8calcR0 == 0 || MQ9calcR0 == 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);}
|
if(MQ2calcR0 == 0 || MQ3calcR0 == 0 || MQ4calcR0 == 0 || MQ5calcR0 == 0 || MQ6calcR0 == 0 || MQ7calcR0 == 0 || MQ8calcR0 == 0 || MQ9calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
//Print in serial monitor
|
//Print in serial monitor
|
||||||
|
@ -62,8 +62,8 @@ void setup(void)
|
|||||||
MQ135.setR0(calcR0/10);
|
MQ135.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
Serial.println("** Values from MQ-135 ****");
|
Serial.println("** Values from MQ-135 ****");
|
||||||
Serial.println("| CO | Alcohol | CO2 | Toluen | NH4 | Aceton |");
|
Serial.println("| CO | Alcohol | CO2 | Toluen | NH4 | Aceton |");
|
||||||
|
@ -246,6 +246,15 @@ test(MQ303A_Ethanol)
|
|||||||
assertEqual(PPM,ppmExp);
|
assertEqual(PPM,ppmExp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test(MQ303A_VoltResolution)
|
||||||
|
{
|
||||||
|
float vRes = 4.7;
|
||||||
|
MQ303A.setVoltResolution(vRes);
|
||||||
|
MQ303A.setADC(100); // provide dummy ADC value
|
||||||
|
MQ303A.readSensor(true); // dummy read for MQ303A
|
||||||
|
assertEqualFloat(MQ303A.getVoltResolution(), vRes);
|
||||||
|
}
|
||||||
|
|
||||||
test(MQ309A_CO)
|
test(MQ309A_CO)
|
||||||
{
|
{
|
||||||
MQ309A.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ309A.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define placa "Arduino UNO"
|
#define placa "Arduino UNO"
|
||||||
#define Voltage_Resolution 5
|
#define Voltage_Resolution 5
|
||||||
#define pin A0 //Analog input 0 -> This value can have any number, we recomend use A0
|
#define pin A0 //Analog input 0 -> This value can have any number, we recommend use A0
|
||||||
#define type "MQ-3 With A2D External connected" //MQ3
|
#define type "MQ-3 With A2D External connected" //MQ3
|
||||||
#define ADC_Bit_Resolution 10 // Resolution of your external A2D
|
#define ADC_Bit_Resolution 10 // Resolution of your external A2D
|
||||||
#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm
|
#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm
|
||||||
@ -74,7 +74,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -89,8 +89,8 @@ void setup() {
|
|||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
|
@ -59,7 +59,7 @@ void setup() {
|
|||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and on clean air (Calibration conditions), setting up R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend executing this routine only on setup in laboratory conditions.
|
// We recommend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
@ -73,8 +73,8 @@ void setup() {
|
|||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
Serial.println(" done!.");
|
||||||
|
|
||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Connection issue, R0 is infinite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Connection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ4.serialDebug(true);
|
MQ4.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
29
keywords.txt
Normal file
29
keywords.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
MQUnifiedsensor KEYWORD1
|
||||||
|
init KEYWORD2
|
||||||
|
update KEYWORD2
|
||||||
|
externalADCUpdate KEYWORD2
|
||||||
|
setR0 KEYWORD2
|
||||||
|
setRL KEYWORD2
|
||||||
|
setA KEYWORD2
|
||||||
|
setB KEYWORD2
|
||||||
|
setRegressionMethod KEYWORD2
|
||||||
|
setVoltResolution KEYWORD2
|
||||||
|
setVCC KEYWORD2
|
||||||
|
setPin KEYWORD2
|
||||||
|
setADC KEYWORD2
|
||||||
|
serialDebug KEYWORD2
|
||||||
|
calibrate KEYWORD2
|
||||||
|
readSensor KEYWORD2
|
||||||
|
readSensorR0Rs KEYWORD2
|
||||||
|
validateEcuation KEYWORD2
|
||||||
|
getVoltage KEYWORD2
|
||||||
|
setRsR0RatioGetPPM KEYWORD2
|
||||||
|
getRS KEYWORD2
|
||||||
|
stringTofloat KEYWORD2
|
||||||
|
getA KEYWORD2
|
||||||
|
getB KEYWORD2
|
||||||
|
getR0 KEYWORD2
|
||||||
|
getRL KEYWORD2
|
||||||
|
getVoltResolution KEYWORD2
|
||||||
|
getVCC KEYWORD2
|
||||||
|
getRegressionMethod KEYWORD2
|
@ -1,5 +1,5 @@
|
|||||||
name=MQUnifiedsensor
|
name=MQUnifiedsensor
|
||||||
version=3.0.0
|
version=3.0.3
|
||||||
author= Miguel Califa <miguelangel5612@gmail.com>, Yersson Carrillo<miguelangel5612@gmail.com>, Ghiordy Contreras<miguelangel5612@gmail.com>
|
author= Miguel Califa <miguelangel5612@gmail.com>, Yersson Carrillo<miguelangel5612@gmail.com>, Ghiordy Contreras<miguelangel5612@gmail.com>
|
||||||
maintainer= Miguel Califa <miguelangel5612@gmail.com>
|
maintainer= Miguel Califa <miguelangel5612@gmail.com>
|
||||||
sentence= This library allows you to read the MQ sensors very easily.
|
sentence= This library allows you to read the MQ sensors very easily.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#include "MQUnifiedsensor.h"
|
#include "MQUnifiedsensor.h"
|
||||||
|
#include <float.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#define retries 2
|
#define retries 2
|
||||||
#define retry_interval 20
|
#define retry_interval 20
|
||||||
@ -10,6 +12,7 @@ MQUnifiedsensor::MQUnifiedsensor(String Placa, float Voltage_Resolution, int ADC
|
|||||||
//this->_type = type; //MQ-2, MQ-3 ... MQ-309A
|
//this->_type = type; //MQ-2, MQ-3 ... MQ-309A
|
||||||
//this->_placa = Placa;
|
//this->_placa = Placa;
|
||||||
this-> _VOLT_RESOLUTION = Voltage_Resolution;
|
this-> _VOLT_RESOLUTION = Voltage_Resolution;
|
||||||
|
this-> _VCC = Voltage_Resolution;
|
||||||
this-> _ADC_Bit_Resolution = ADC_Bit_Resolution;
|
this-> _ADC_Bit_Resolution = ADC_Bit_Resolution;
|
||||||
}
|
}
|
||||||
MQUnifiedsensor::MQUnifiedsensor(String Placa, String type) {
|
MQUnifiedsensor::MQUnifiedsensor(String Placa, String type) {
|
||||||
@ -20,11 +23,39 @@ void MQUnifiedsensor::init()
|
|||||||
{
|
{
|
||||||
pinMode(_pin, INPUT);
|
pinMode(_pin, INPUT);
|
||||||
}
|
}
|
||||||
|
static inline double safePow(double base, double exp){
|
||||||
|
if(exp == 0.0) return 1.0;
|
||||||
|
if(exp == 1.0) return base;
|
||||||
|
if(exp == 2.0) return base * base;
|
||||||
|
return pow(base, exp);
|
||||||
|
}
|
||||||
|
static inline bool willOverflow(double log_ppm){
|
||||||
|
static const double maxLog = log10((double)FLT_MAX);
|
||||||
|
static const double minLog = log10((double)FLT_MIN);
|
||||||
|
return (log_ppm > maxLog || log_ppm < minLog);
|
||||||
|
}
|
||||||
|
|
||||||
void MQUnifiedsensor::setA(float a) {
|
void MQUnifiedsensor::setA(float a) {
|
||||||
|
if(isinf(a) || isnan(a)) {
|
||||||
|
this->_a = 0;
|
||||||
|
} else if(a > MQ_MAX_A) {
|
||||||
|
this->_a = MQ_MAX_A;
|
||||||
|
} else if(a < -MQ_MAX_A) {
|
||||||
|
this->_a = -MQ_MAX_A;
|
||||||
|
} else {
|
||||||
this->_a = a;
|
this->_a = a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void MQUnifiedsensor::setB(float b) {
|
void MQUnifiedsensor::setB(float b) {
|
||||||
|
if(isinf(b) || isnan(b)) {
|
||||||
|
this->_b = 0;
|
||||||
|
} else if(b > MQ_MAX_B) {
|
||||||
|
this->_b = MQ_MAX_B;
|
||||||
|
} else if(b < -MQ_MAX_B) {
|
||||||
|
this->_b = -MQ_MAX_B;
|
||||||
|
} else {
|
||||||
this->_b = b;
|
this->_b = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void MQUnifiedsensor::setR0(float R0) {
|
void MQUnifiedsensor::setR0(float R0) {
|
||||||
this->_R0 = R0;
|
this->_R0 = R0;
|
||||||
@ -41,6 +72,10 @@ void MQUnifiedsensor::setVoltResolution(float voltage_resolution)
|
|||||||
{
|
{
|
||||||
_VOLT_RESOLUTION = voltage_resolution;
|
_VOLT_RESOLUTION = voltage_resolution;
|
||||||
}
|
}
|
||||||
|
void MQUnifiedsensor::setVCC(float vcc)
|
||||||
|
{
|
||||||
|
_VCC = vcc;
|
||||||
|
}
|
||||||
void MQUnifiedsensor::setPin(int pin) {
|
void MQUnifiedsensor::setPin(int pin) {
|
||||||
this->_pin = pin;
|
this->_pin = pin;
|
||||||
}
|
}
|
||||||
@ -59,6 +94,10 @@ float MQUnifiedsensor::getVoltResolution()
|
|||||||
{
|
{
|
||||||
return _VOLT_RESOLUTION;
|
return _VOLT_RESOLUTION;
|
||||||
}
|
}
|
||||||
|
float MQUnifiedsensor::getVCC()
|
||||||
|
{
|
||||||
|
return _VCC;
|
||||||
|
}
|
||||||
String MQUnifiedsensor::getRegressionMethod()
|
String MQUnifiedsensor::getRegressionMethod()
|
||||||
{
|
{
|
||||||
if(_regressionMethod == 1) return "Exponential";
|
if(_regressionMethod == 1) return "Exponential";
|
||||||
@ -85,7 +124,8 @@ void MQUnifiedsensor::serialDebug(bool onSetup)
|
|||||||
Serial.println("Contributors: Andres A. Martinez - Juan A. Rodríguez - Mario A. Rodríguez O ");
|
Serial.println("Contributors: Andres A. Martinez - Juan A. Rodríguez - Mario A. Rodríguez O ");
|
||||||
|
|
||||||
Serial.print("Sensor: "); Serial.println(_type);
|
Serial.print("Sensor: "); Serial.println(_type);
|
||||||
Serial.print("Supply voltage: "); Serial.print(_VOLT_RESOLUTION); Serial.println(" VDC");
|
Serial.print("ADC voltage: "); Serial.print(_VOLT_RESOLUTION); Serial.println(" VDC");
|
||||||
|
Serial.print("Sensor supply (VCC): "); Serial.print(_VCC); Serial.println(" VDC");
|
||||||
Serial.print("ADC Resolution: "); Serial.print(_ADC_Bit_Resolution); Serial.println(" Bits");
|
Serial.print("ADC Resolution: "); Serial.print(_ADC_Bit_Resolution); Serial.println(" Bits");
|
||||||
Serial.print("R0: "); Serial.print(_R0); Serial.println(" KΩ");
|
Serial.print("R0: "); Serial.print(_R0); Serial.println(" KΩ");
|
||||||
Serial.print("RL: "); Serial.print(_RL); Serial.println(" KΩ");
|
Serial.print("RL: "); Serial.print(_RL); Serial.println(" KΩ");
|
||||||
@ -106,7 +146,7 @@ void MQUnifiedsensor::serialDebug(bool onSetup)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.print("|"); Serial.print(_adc); Serial.print("| v = ADC*"); Serial.print(_VOLT_RESOLUTION); Serial.print("/"); Serial.print((pow(2, _ADC_Bit_Resolution)) - 1); Serial.print(" | "); Serial.print(_sensor_volt);
|
Serial.print("|"); Serial.print(_adc); Serial.print("| v = ADC*"); Serial.print(_VOLT_RESOLUTION); Serial.print("/"); Serial.print((pow(2, _ADC_Bit_Resolution)) - 1); Serial.print(" | "); Serial.print(_sensor_volt);
|
||||||
Serial.print(" | RS = ((" ); Serial.print(_VOLT_RESOLUTION ); Serial.print("*RL)/Voltage) - RL| "); Serial.print(_RS_Calc); Serial.print(" | Ratio = RS/R0| ");
|
Serial.print(" | RS = ((" ); Serial.print(_VCC ); Serial.print("*RL)/Voltage) - RL| "); Serial.print(_RS_Calc); Serial.print(" | Ratio = RS/R0| ");
|
||||||
Serial.print(_ratio); Serial.print( " | ");
|
Serial.print(_ratio); Serial.print( " | ");
|
||||||
if(_regressionMethod == 1) Serial.print("ratio*a + b");
|
if(_regressionMethod == 1) Serial.print("ratio*a + b");
|
||||||
else Serial.print("pow(10, (log10(ratio)-b)/a)");
|
else Serial.print("pow(10, (log10(ratio)-b)/a)");
|
||||||
@ -124,59 +164,82 @@ void MQUnifiedsensor::externalADCUpdate(float volt)
|
|||||||
}
|
}
|
||||||
float MQUnifiedsensor::validateEcuation(float ratioInput)
|
float MQUnifiedsensor::validateEcuation(float ratioInput)
|
||||||
{
|
{
|
||||||
//Serial.print("Ratio input: "); Serial.println(ratioInput);
|
double ppm;
|
||||||
//Serial.print("a: "); Serial.println(_a);
|
if(_regressionMethod == 1){
|
||||||
//Serial.print("b: "); Serial.println(_b);
|
if(ratioInput <= 0 || _a == 0) return 0;
|
||||||
//Usage of this function: Unit test on ALgorithmTester example;
|
double logppm = log10((double)_a) + (double)_b * log10((double)ratioInput);
|
||||||
if(_regressionMethod == 1) _PPM= _a*pow(ratioInput, _b);
|
if(willOverflow(logppm)) ppm = (logppm > 0) ? FLT_MAX : 0.0;
|
||||||
|
else ppm = safePow(10.0, logppm);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// https://jayconsystems.com/blog/understanding-a-gas-sensor
|
if(ratioInput <= 0 || _a == 0) return 0;
|
||||||
double ppm_log = (log10(ratioInput)-_b)/_a; //Get ppm value in linear scale according to the the ratio value
|
double logppm = (log10((double)ratioInput)-(double)_b)/(double)_a;
|
||||||
_PPM = pow(10, ppm_log); //Convert ppm value to log scale
|
if(willOverflow(logppm)) ppm = (logppm > 0) ? FLT_MAX : 0.0;
|
||||||
|
else ppm = safePow(10.0, logppm);
|
||||||
}
|
}
|
||||||
//Serial.println("Regression Method: "); Serial.println(_regressionMethod);
|
if(isinf(ppm) || isnan(ppm)) ppm = FLT_MAX;
|
||||||
//Serial.println("Result: "); Serial.println(_PPM);
|
_PPM = (float)ppm;
|
||||||
return _PPM;
|
return _PPM;
|
||||||
}
|
}
|
||||||
float MQUnifiedsensor::readSensor(bool isMQ303A, float correctionFactor, bool injected)
|
float MQUnifiedsensor::readSensor(bool isMQ303A, float correctionFactor, bool injected)
|
||||||
{
|
{
|
||||||
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
|
|
||||||
|
float voltRes = _VOLT_RESOLUTION; // preserve global resolution
|
||||||
if(isMQ303A) {
|
if(isMQ303A) {
|
||||||
_VOLT_RESOLUTION = _VOLT_RESOLUTION - 0.45; //Calculations for RS using mq303a sensor look wrong #42
|
voltRes = voltRes - 0.45; //Calculations for RS using mq303a sensor look wrong #42
|
||||||
}
|
}
|
||||||
_RS_Calc = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas
|
_RS_Calc = ((_VCC*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas
|
||||||
if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
|
if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
|
||||||
if(!injected) _ratio = _RS_Calc / this->_R0; // Get ratio RS_gas/RS_air
|
if(!injected) _ratio = _RS_Calc / this->_R0; // Get ratio RS_gas/RS_air
|
||||||
_ratio += correctionFactor;
|
_ratio += correctionFactor;
|
||||||
if(_ratio <= 0) _ratio = 0; //No negative values accepted or upper datasheet recomendation.
|
if(_ratio <= 0) _ratio = 0; //No negative values accepted or upper datasheet recommendation.
|
||||||
if(_regressionMethod == 1) _PPM= _a*pow(_ratio, _b); // <- Source excel analisis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents
|
double ppm;
|
||||||
|
if(_regressionMethod == 1){
|
||||||
|
if(_ratio <= 0 || _a == 0) return 0;
|
||||||
|
double logppm = log10((double)_a) + (double)_b * log10((double)_ratio);
|
||||||
|
if(willOverflow(logppm)) ppm = (logppm > 0) ? FLT_MAX : 0.0;
|
||||||
|
else ppm = safePow(10.0, logppm);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// https://jayconsystems.com/blog/understanding-a-gas-sensor <- Source of linear ecuation
|
if(_ratio <= 0 || _a == 0) return 0;
|
||||||
double ppm_log = (log10(_ratio)-_b)/_a; //Get ppm value in linear scale according to the the ratio value
|
double logppm = (log10((double)_ratio)-(double)_b)/(double)_a;
|
||||||
_PPM = pow(10, ppm_log); //Convert ppm value to log scale
|
if(willOverflow(logppm)) ppm = (logppm > 0) ? FLT_MAX : 0.0;
|
||||||
|
else ppm = safePow(10.0, logppm);
|
||||||
}
|
}
|
||||||
if(_PPM < 0) _PPM = 0; //No negative values accepted or upper datasheet recomendation.
|
if(ppm < 0) ppm = 0; //No negative values accepted or upper datasheet recommendation.
|
||||||
//if(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recomendation.
|
if(isinf(ppm) || isnan(ppm)) ppm = FLT_MAX;
|
||||||
|
_PPM = (float)ppm;
|
||||||
|
//if(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recommendation.
|
||||||
return _PPM;
|
return _PPM;
|
||||||
}
|
}
|
||||||
float MQUnifiedsensor::readSensorR0Rs()
|
float MQUnifiedsensor::readSensorR0Rs()
|
||||||
{
|
{
|
||||||
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
_RS_Calc = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas
|
_RS_Calc = ((_VCC*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas
|
||||||
if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
|
if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
|
||||||
_ratio = this->_R0/_RS_Calc; // Get ratio RS_air/RS_gas <- INVERTED for MQ-131 issue 28 https://github.com/miguel5612/MQSensorsLib/issues/28
|
_ratio = this->_R0/_RS_Calc; // Get ratio RS_air/RS_gas <- INVERTED for MQ-131 issue 28 https://github.com/miguel5612/MQSensorsLib/issues/28
|
||||||
if(_ratio <= 0) _ratio = 0; //No negative values accepted or upper datasheet recomendation.
|
if(_ratio <= 0) _ratio = 0; //No negative values accepted or upper datasheet recommendation.
|
||||||
if(_regressionMethod == 1) _PPM= _a*pow(_ratio, _b); // <- Source excel analisis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents
|
double ppm;
|
||||||
|
if(_regressionMethod == 1){
|
||||||
|
if(_ratio <= 0 || _a == 0) return 0;
|
||||||
|
double logppm = log10((double)_a) + (double)_b * log10((double)_ratio);
|
||||||
|
if(willOverflow(logppm)) ppm = (logppm > 0) ? FLT_MAX : 0.0;
|
||||||
|
else ppm = safePow(10.0, logppm);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// https://jayconsystems.com/blog/understanding-a-gas-sensor <- Source of linear ecuation
|
if(_ratio <= 0 || _a == 0) return 0;
|
||||||
double ppm_log = (log10(_ratio)-_b)/_a; //Get ppm value in linear scale according to the the ratio value
|
double logppm = (log10((double)_ratio)-(double)_b)/(double)_a;
|
||||||
_PPM = pow(10, ppm_log); //Convert ppm value to log scale
|
if(willOverflow(logppm)) ppm = (logppm > 0) ? FLT_MAX : 0.0;
|
||||||
|
else ppm = safePow(10.0, logppm);
|
||||||
}
|
}
|
||||||
if(_PPM < 0) _PPM = 0; //No negative values accepted or upper datasheet recomendation.
|
if(ppm < 0) ppm = 0; //No negative values accepted or upper datasheet recommendation.
|
||||||
//if(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recomendation.
|
if(isinf(ppm) || isnan(ppm)) ppm = FLT_MAX;
|
||||||
|
_PPM = (float)ppm;
|
||||||
|
//if(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recommendation.
|
||||||
return _PPM;
|
return _PPM;
|
||||||
}
|
}
|
||||||
float MQUnifiedsensor::calibrate(float ratioInCleanAir) {
|
float MQUnifiedsensor::calibrate(float ratioInCleanAir) {
|
||||||
@ -194,7 +257,7 @@ float MQUnifiedsensor::calibrate(float ratioInCleanAir) {
|
|||||||
*/
|
*/
|
||||||
float RS_air; //Define variable for sensor resistance
|
float RS_air; //Define variable for sensor resistance
|
||||||
float R0; //Define variable for R0
|
float R0; //Define variable for R0
|
||||||
RS_air = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; //Calculate RS in fresh air
|
RS_air = ((_VCC*_RL)/_sensor_volt)-_RL; //Calculate RS in fresh air
|
||||||
if(RS_air < 0) RS_air = 0; //No negative values accepted.
|
if(RS_air < 0) RS_air = 0; //No negative values accepted.
|
||||||
R0 = RS_air/ratioInCleanAir; //Calculate R0
|
R0 = RS_air/ratioInCleanAir; //Calculate R0
|
||||||
if(R0 < 0) R0 = 0; //No negative values accepted.
|
if(R0 < 0) R0 = 0; //No negative values accepted.
|
||||||
@ -231,7 +294,7 @@ float MQUnifiedsensor:: setRsR0RatioGetPPM(float value)
|
|||||||
float MQUnifiedsensor::getRS()
|
float MQUnifiedsensor::getRS()
|
||||||
{
|
{
|
||||||
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
_RS_Calc = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas
|
_RS_Calc = ((_VCC*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas
|
||||||
if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
|
if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
|
||||||
return _RS_Calc;
|
return _RS_Calc;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,12 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <float.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
// Maximum coefficients allowed for the regression model
|
||||||
|
#define MQ_MAX_A 1e30
|
||||||
|
#define MQ_MAX_B 100.0
|
||||||
|
|
||||||
/***********************Software Related Macros************************************/
|
/***********************Software Related Macros************************************/
|
||||||
|
|
||||||
@ -22,6 +28,7 @@ class MQUnifiedsensor
|
|||||||
void setB(float b);
|
void setB(float b);
|
||||||
void setRegressionMethod(int regressionMethod);
|
void setRegressionMethod(int regressionMethod);
|
||||||
void setVoltResolution(float voltage_resolution = 5);
|
void setVoltResolution(float voltage_resolution = 5);
|
||||||
|
void setVCC(float vcc = 5);
|
||||||
void setPin(int pin = 1);
|
void setPin(int pin = 1);
|
||||||
void serialDebug(bool onSetup = false); //Show on serial port information about sensor
|
void serialDebug(bool onSetup = false); //Show on serial port information about sensor
|
||||||
void setADC(int value); //For external ADC Usage
|
void setADC(int value); //For external ADC Usage
|
||||||
@ -38,6 +45,7 @@ class MQUnifiedsensor
|
|||||||
float getR0();
|
float getR0();
|
||||||
float getRL();
|
float getRL();
|
||||||
float getVoltResolution();
|
float getVoltResolution();
|
||||||
|
float getVCC();
|
||||||
String getRegressionMethod();
|
String getRegressionMethod();
|
||||||
float getVoltage(bool read = true, bool injected = false, int value = 0);
|
float getVoltage(bool read = true, bool injected = false, int value = 0);
|
||||||
float stringTofloat(String & str);
|
float stringTofloat(String & str);
|
||||||
@ -51,6 +59,7 @@ class MQUnifiedsensor
|
|||||||
byte _pin = 1;
|
byte _pin = 1;
|
||||||
byte _firstFlag = false;
|
byte _firstFlag = false;
|
||||||
float _VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
|
float _VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
|
||||||
|
float _VCC = 5.0; // Sensor supply voltage
|
||||||
float _RL = 10; //Value in KiloOhms
|
float _RL = 10; //Value in KiloOhms
|
||||||
byte _ADC_Bit_Resolution = 10;
|
byte _ADC_Bit_Resolution = 10;
|
||||||
byte _regressionMethod = 1; // 1 -> Exponential || 2 -> Linear
|
byte _regressionMethod = 1; // 1 -> Exponential || 2 -> Linear
|
||||||
|
Reference in New Issue
Block a user