Compare commits

..

12 Commits

Author SHA1 Message Date
c066b2ec1c Correct typos in source and example files 2025-06-04 18:09:40 -05:00
c927504bf5 Update readme and contributing files 2023-10-04 16:21:25 -05:00
337d962862 Merge pull request #64 from adrcunha/master
Allow setting the ADC pin of a MQUnifiedsensor object.
2023-05-16 11:21:45 -05:00
f7f2c1f3f4 Allow setting the ADC pin of a MQUnifiedsensor object.
The ADC pin can only be set when using the full/long constructor, causing the short constructor (name/type only) useless because the pin is unset.

Also default the ADC pin to 1 for consistency sake.
2023-04-11 14:30:49 -07:00
1c131eed65 Merge pull request #61 from adrcunha/master
Cleanup general definitions in MQUnifiedSensor.h
2023-04-11 07:13:18 -05:00
b6bff185f3 Cleanup general definitions in MQUnifiedSensor.h
ADC_RESOLUTION is unused, and retries and retry_interval are only used by getVoltage().
Thus, remove ADC_RESOLUTION and move retries and retry_interval to MQUnifiedsensor.cpp.
Furthermore, these three definitions have generic names so it's easy to have them
conflict with a user's sketch that imports MQUnifiedSensor.h.
2023-04-03 08:53:13 -07:00
a7e89570fd Merge pull request #53 from SMH17/patch-1
Update README.md
2023-03-15 16:35:38 -05:00
35180270ac Merge pull request #56 from PsySc0rpi0n/patch-2
Update MQUnifiedsensor.cpp
2023-03-15 16:35:26 -05:00
52bccfbff1 Merge pull request #57 from PsySc0rpi0n/patch-3
Update MQUnifiedsensor.h
2023-03-15 16:35:12 -05:00
3368613dd7 Update MQUnifiedsensor.h 2022-09-07 22:24:54 +01:00
9f41530cda Update MQUnifiedsensor.cpp
Change the `_type` array size from 6 to 7 so that it can display sensor name's with 6 characters or more.
2022-09-07 22:23:27 +01:00
e862774fe0 Update README.md
These sensors are all made by HANWEI Electronics, Sparkfun etc. are just resellers.
2022-08-03 01:53:49 +02:00
32 changed files with 118 additions and 109 deletions

View File

@ -12,6 +12,8 @@ Please delete options that are not relevant.
- [ ] New feature (non-breaking change which adds functionality) - [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update - [ ] This change requires a documentation update
- [ ] I have updated the version in `library.properties` to reflect my changes (advance by 0.01 for minor changes, or a whole number for new features)
- [ ] I have submitted the pull request
# How Has This Been Tested? # How Has This Been Tested?

View File

@ -20,3 +20,7 @@ Pull request will be check by three main authors who are linked in
[REAMDE.md](https://github.com/miguel5612/MQSensorsLib/README.md) and they determine to merge to [REAMDE.md](https://github.com/miguel5612/MQSensorsLib/README.md) and they determine to merge to
master branch. Later than assessment and debbuging procedures was completed, the contribution master branch. Later than assessment and debbuging procedures was completed, the contribution
will be released. will be released.
## Versioning
When making a pull request, please remember to update the `library.properties` file to reflect the changes you've made. If your change is minor, consider advancing the version by 0.01. If you're adding a new feature, you may want to advance the version by a whole number.

View File

@ -121,15 +121,15 @@ You'll need Arduino desktop app 1.8.9 or later.
### Sensor manufacturers: ### Sensor manufacturers:
| Sensor | Manufacture | URL Datasheet | | Sensor | Manufacture | URL Datasheet |
|----------|----------|----------| |----------|----------|----------|
| MQ-2 | Pololulu| [datasheet](https://www.pololu.com/file/0J309/MQ2.pdf) | | MQ-2 | HANWEI Electronics| [datasheet](https://www.pololu.com/file/0J309/MQ2.pdf) |
| MQ-3 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/MQ-3.pdf) | | MQ-3 | HANWEI Electronics | [datasheet](https://www.sparkfun.com/datasheets/Sensors/MQ-3.pdf) |
| MQ-4 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-4.pdf) | | MQ-4 | HANWEI Electronics | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-4.pdf) |
| MQ-5 | parallax | [datasheet](https://www.parallax.com/sites/default/files/downloads/605-00009-MQ-5-Datasheet.pdf) | | MQ-5 | HANWEI Electronics | [datasheet](https://www.parallax.com/sites/default/files/downloads/605-00009-MQ-5-Datasheet.pdf) |
| MQ-6 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-6.pdf) | | MQ-6 | HANWEI Electronics | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-6.pdf) |
| MQ-7 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-7.pdf) | | MQ-7 | HANWEI Electronics | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-7.pdf) |
| MQ-8 | Sparkfun | [datasheet](https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Biometric/MQ-8.pdf) | | MQ-8 | HANWEI Electronics | [datasheet](https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Biometric/MQ-8.pdf) |
| MQ-9 | Haoyuelectronics | [datasheet](http://www.haoyuelectronics.com/Attachment/MQ-9/MQ9.pdf) | | MQ-9 | HANWEI Electronics | [datasheet](http://www.haoyuelectronics.com/Attachment/MQ-9/MQ9.pdf) |
| MQ-131 | Sensorsportal | [datasheet](http://www.sensorsportal.com/DOWNLOADS/MQ131.pdf) | | MQ-131 | HANWEI Electronics | [datasheet](http://www.sensorsportal.com/DOWNLOADS/MQ131.pdf) |
| MQ-135 | HANWEI Electronics | [datasheet](https://www.electronicoscaldas.com/datasheet/MQ-135_Hanwei.pdf) | | MQ-135 | HANWEI Electronics | [datasheet](https://www.electronicoscaldas.com/datasheet/MQ-135_Hanwei.pdf) |
| MQ-136 | HANWEI Electronics | [datasheet](https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/Datasheets/MQ136%20-%20Hanwei.pdf) | | MQ-136 | HANWEI Electronics | [datasheet](https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/Datasheets/MQ136%20-%20Hanwei.pdf) |
| MQ-303A | HANWEI Electronics | [datasheet](http://www.kosmodrom.com.ua/pdf/MQ303A.pdf) | | MQ-303A | HANWEI Electronics | [datasheet](http://www.kosmodrom.com.ua/pdf/MQ303A.pdf) |

View File

@ -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 ********************************************/
} }

View File

@ -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

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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 ********************************************/
/* /*

View File

@ -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 :)");

View File

@ -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 |");

View File

@ -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.

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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);

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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 **********************");

View File

@ -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**********");

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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 |");

View File

@ -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);
} }

View File

@ -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

View File

@ -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 |");

View File

@ -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);

View File

@ -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);
} }

View File

@ -1,9 +1,12 @@
#include "MQUnifiedsensor.h" #include "MQUnifiedsensor.h"
#define retries 2
#define retry_interval 20
MQUnifiedsensor::MQUnifiedsensor(String Placa, float Voltage_Resolution, int ADC_Bit_Resolution, int pin, String type) { MQUnifiedsensor::MQUnifiedsensor(String Placa, float Voltage_Resolution, int ADC_Bit_Resolution, int pin, String type) {
this->_pin = pin; this->_pin = pin;
Placa.toCharArray(this->_placa, 20); Placa.toCharArray(this->_placa, 20);
type.toCharArray(this->_type, 6); type.toCharArray(this->_type, 7);
//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;
@ -11,7 +14,7 @@ MQUnifiedsensor::MQUnifiedsensor(String Placa, float Voltage_Resolution, int ADC
} }
MQUnifiedsensor::MQUnifiedsensor(String Placa, String type) { MQUnifiedsensor::MQUnifiedsensor(String Placa, String type) {
Placa.toCharArray(this->_placa, 20); Placa.toCharArray(this->_placa, 20);
type.toCharArray(this->_type, 6); type.toCharArray(this->_type, 7);
} }
void MQUnifiedsensor::init() void MQUnifiedsensor::init()
{ {
@ -38,6 +41,9 @@ void MQUnifiedsensor::setVoltResolution(float voltage_resolution)
{ {
_VOLT_RESOLUTION = voltage_resolution; _VOLT_RESOLUTION = voltage_resolution;
} }
void MQUnifiedsensor::setPin(int pin) {
this->_pin = pin;
}
void MQUnifiedsensor::setRegressionMethod(int regressionMethod) void MQUnifiedsensor::setRegressionMethod(int regressionMethod)
{ {
//this->_regressionMethod = regressionMethod; //this->_regressionMethod = regressionMethod;
@ -143,16 +149,16 @@ float MQUnifiedsensor::readSensor(bool isMQ303A, float correctionFactor, bool in
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 if(_regressionMethod == 1) _PPM= _a*pow(_ratio, _b); // <- Source excel analysis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents
else else
{ {
// https://jayconsystems.com/blog/understanding-a-gas-sensor <- Source of linear ecuation // https://jayconsystems.com/blog/understanding-a-gas-sensor <- Source of linear equation
double ppm_log = (log10(_ratio)-_b)/_a; //Get ppm value in linear scale according to the the ratio value double ppm_log = (log10(_ratio)-_b)/_a; //Get ppm value in linear scale according to the the ratio value
_PPM = pow(10, ppm_log); //Convert ppm value to log scale _PPM = pow(10, ppm_log); //Convert ppm value to log scale
} }
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(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recommendation.
return _PPM; return _PPM;
} }
float MQUnifiedsensor::readSensorR0Rs() float MQUnifiedsensor::readSensorR0Rs()
@ -161,16 +167,16 @@ float MQUnifiedsensor::readSensorR0Rs()
_RS_Calc = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas _RS_Calc = ((_VOLT_RESOLUTION*_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 if(_regressionMethod == 1) _PPM= _a*pow(_ratio, _b); // <- Source excel analysis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents
else else
{ {
// https://jayconsystems.com/blog/understanding-a-gas-sensor <- Source of linear ecuation // https://jayconsystems.com/blog/understanding-a-gas-sensor <- Source of linear equation
double ppm_log = (log10(_ratio)-_b)/_a; //Get ppm value in linear scale according to the the ratio value double ppm_log = (log10(_ratio)-_b)/_a; //Get ppm value in linear scale according to the the ratio value
_PPM = pow(10, ppm_log); //Convert ppm value to log scale _PPM = pow(10, ppm_log); //Convert ppm value to log scale
} }
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(_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) {

View File

@ -6,10 +6,6 @@
/***********************Software Related Macros************************************/ /***********************Software Related Macros************************************/
#define ADC_RESOLUTION 10 // for 10bit analog to digital converter.
#define retries 2
#define retry_interval 20
class MQUnifiedsensor class MQUnifiedsensor
{ {
public: public:
@ -26,6 +22,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 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
@ -51,7 +48,7 @@ class MQUnifiedsensor
private: private:
/************************Private vars************************************/ /************************Private vars************************************/
byte _pin; 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 _RL = 10; //Value in KiloOhms float _RL = 10; //Value in KiloOhms
@ -61,7 +58,7 @@ class MQUnifiedsensor
float _adc, _a, _b, _sensor_volt; float _adc, _a, _b, _sensor_volt;
float _R0, RS_air, _ratio, _PPM, _RS_Calc; float _R0, RS_air, _ratio, _PPM, _RS_Calc;
char _type[6]; char _type[7];
char _placa[20]; char _placa[20];
}; };