Compare commits

...

9 Commits
1.0.3 ... 1.0.4

Author SHA1 Message Date
3261318577 Fixed merge conflict 2019-09-28 11:21:23 -05:00
e5578c199f Updated version in library.prop 2019-09-28 11:20:37 -05:00
ff002f9993 Updated examples, added new method explanation 2019-09-28 11:18:28 -05:00
b85e7520d4 Merge pull request #14 from miguel5612/develop
Value of _RLValue - Added getRL and setRL method
2019-09-28 11:07:40 -05:00
0f912a3c4a Value of _RLValue - Added getRL and setRL method 2019-09-28 11:05:55 -05:00
b2616295a3 Respect upper and down limits from datasheet indicating 0 PPM or 9999 PPM 2019-09-08 12:49:02 -05:00
886bfd9981 Merge pull request #9 from aetilius/master
Correct data type for voltage resolution
2019-09-07 17:08:15 -05:00
cfe8ccc6ad Correct data type for voltage resolution 2019-09-07 13:20:13 -07:00
a9aba676e2 Update README.md 2019-09-02 20:00:44 -05:00
16 changed files with 122 additions and 28 deletions

View File

@ -1,4 +1,4 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3384299.svg)](https://doi.org/10.5281/zenodo.3384299)
[![DOI](https://zenodo.org/badge/170540207.svg)](https://zenodo.org/badge/latestdoi/170540207)
![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)
# MQSensorsLib
@ -94,14 +94,44 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md
## Cite as
* Plain text: Miguel Angel Califa Urquiza. (2019, September 3). Ghiordy/MQSensorsLib: Arduino Preview V1.0.3 (Version 1.0.3). Zenodo. http://doi.org/10.5281/zenodo.3384299
* Plain text: Califa Urquiza, Miguel Angel, Contreras Contreras, Ghiordy, & Carrillo Amado, Yerson Ramiro. (2019, September 3). miguel5612/MQSensorsLib: Arduino Preview V1.03 (Version 1.0.3). Zenodo. http://doi.org/10.5281/zenodo.3384301
* CSL: {
"publisher": "Zenodo",
"DOI": "10.5281/zenodo.3384301",
"title": "miguel5612/MQSensorsLib: Arduino Preview V1.03",
"issued": {
"date-parts": [
[
2019,
9,
3
]
]
},
"abstract": "<p>Publishing on Zenodo platform as software in order to extend its applications for other works allowing to recognize MQSensorLib&#39;s Authors this work into scientific community using Digital Object Identifier System (DOI).</p>",
"author": [
{
"family": "Califa Urquiza, Miguel Angel"
},
{
"family": "Contreras Contreras, Ghiordy"
},
{
"family": "Carrillo Amado, Yerson Ramiro"
}
],
"version": "1.0.3",
"type": "article",
"id": "3384301"
}
* BibTeX:
@misc{miguel_angel_califa_urquiza_2019_3384299,
author = {Miguel Angel Califa Urquiza},
title = {Ghiordy/MQSensorsLib: Arduino Preview V1.0.3},
@misc{califa_urquiza_miguel_angel_2019_3384301,
author = {Califa Urquiza, Miguel Angel and
Contreras Contreras, Ghiordy and
Carrillo Amado, Yerson Ramiro},
title = {miguel5612/MQSensorsLib: Arduino Preview V1.03},
month = sep,
year = 2019,
doi = {10.5281/zenodo.3384299},
url = {https://doi.org/10.5281/zenodo.3384299}
doi = {10.5281/zenodo.3384301},
url = {https://doi.org/10.5281/zenodo.3384301}
}

View File

@ -41,12 +41,16 @@ void setup() {
void loop() {
MQ131.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
// Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ131.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ131.calibrate();
MQ131.setR0(R0):
MQ131.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -41,6 +41,10 @@ void setup() {
void loop() {
MQ135.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ135.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)

View File

@ -41,12 +41,16 @@ void setup() {
void loop() {
MQ2.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ2.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ2.calibrate();
MQ2.setR0(R0):
MQ2.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -41,12 +41,16 @@ void setup() {
void loop() {
MQ3.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ3.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ3.calibrate();
MQ3.setR0(R0):
MQ3.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -41,12 +41,16 @@ void setup() {
void loop() {
MQ303.update();
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ303.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ303.calibrate();
MQ303.setR0(R0):
MQ303.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -41,12 +41,16 @@ void setup() {
void loop() {
MQ309.update();
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ309.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ309.calibrate();
MQ309.setR0(R0):
MQ309.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -42,11 +42,15 @@ void setup() {
void loop() {
MQ4.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ4.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ4.calibrate();
MQ4.setR0(R0):
MQ4.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -42,12 +42,16 @@ void setup() {
void loop() {
MQ5.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ5.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ5.calibrate();
MQ5.setR0(R0):
MQ5.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -41,6 +41,10 @@ void setup() {
void loop() {
MQ6.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ6.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)

View File

@ -44,12 +44,16 @@ void setup() {
void loop() {
MQ7.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ7.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ7.calibrate();
MQ7.setR0(R0):
MQ7.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -41,12 +41,16 @@ void setup() {
void loop() {
MQ8.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ8.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ8.calibrate();
MQ8.setR0(R0):
MQ8.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -41,12 +41,16 @@ void setup() {
void loop() {
MQ9.update(); // Update data, the arduino will be read the voltaje in the analog pin
/*
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
MQ9.setRL(10);
*/
/*
//Rutina de calibracion - Uncomment if you need (setup too and header)
if(calibration_button)
{
float R0 = MQ9.calibrate();
MQ9.setR0(R0):
MQ9.setR0(R0);
}
*/
/***************************** MQReadSensor ****************************************

View File

@ -1,5 +1,5 @@
name=MQUnifiedsensor
version=1.0.2
version=1.0.4
author= Miguel Califa <miguelangel5612@gmail.com>, Yersson Carrillo <miguelangel5612@gmail.com>, Ghiordy Contreras <miguelangel5612@gmail.com>
maintainer= Miguel Califa <miguelangel5612@gmail.com>
sentence= This library allows you to read the MQ sensors very easily.

View File

@ -107,8 +107,12 @@ float MQUnifiedsensor::readSensor(String nameLectureRequeired, bool print)
setSensorCharacteristics(nameLectureRequeired, print); //In this function update _a and _b
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
_RS_Calc = ((_VOLT_RESOLUTION*_RLValue)/_sensor_volt)-_RLValue; //Get value of RS in a gas
if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
_ratio = _RS_Calc / this->_R0; // Get ratio RS_gas/RS_air
if(_ratio <= 0 || _ratio>100) _ratio = 0.01; //No negative values accepted or upper datasheet recomendation.
_PPM= _a*pow(_ratio, _b);
if(_PPM < 0) _PPM = 0; //No negative values accepted or upper datasheet recomendation.
if(_PPM > 10000) _PPM = 9999; //No negative values accepted or upper datasheet recomendation.
if(print)
{
@ -522,7 +526,9 @@ float MQUnifiedsensor::calibrate(boolean print) {
float RS_air; //Define variable for sensor resistance
float R0; //Define variable for R0
RS_air = ((_VOLT_RESOLUTION*_RLValue)/_sensor_volt)-_RLValue; //Calculate RS in fresh air
if(RS_air < 0) RS_air = 0; //No negative values accepted.
R0 = RS_air/_ratioInCleanAir; //Calculate R0
if(R0 < 0) R0 = 0; //No negative values accepted.
if(print)
{
Serial.println("*******Calibrating*********");
@ -562,6 +568,14 @@ void MQUnifiedsensor::setR0(double R0) {
double MQUnifiedsensor::getR0() {
return _R0;
}
void MQUnifiedsensor::setRL(double RL) {
this->_RLValue = RL;
}
double MQUnifiedsensor::getRL() {
return _RLValue;
}
void MQUnifiedsensor::setDefaultGas()
{
if(_type == 2)

View File

@ -255,6 +255,7 @@ class MQUnifiedsensor
void inicializar();
void update();
void setR0(double R0 = 10);
void setRL(double RL = 10);
void setVoltResolution(float voltaje = 5);
void setSensorCharacteristics(String nameLectureReqeuired = "", bool print = false);
void setDefaultGas();
@ -265,6 +266,7 @@ class MQUnifiedsensor
//get function for info
double getR0();
double getRL();
double getVoltage(int read = true);
double stringToDouble(String & str);
String getnameLecture();
@ -273,14 +275,14 @@ class MQUnifiedsensor
private:
/************************Private vars************************************/
int _pin, _type, _lecturePosInArray;
double _R0;
byte _pin, _type, _lecturePosInArray;
byte _VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
byte _ratioInCleanAir, _sensor_volt;
byte _RLValue = 10; //Value in KiloOhms
float _R0, RS_air, _ratio, _PPM, _RS_Calc;
float _b;
double _a;
String _nameLectureRequeired;
int _VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
int _RLValue = 10; //Value in KiloOhms
float _PPM, _RS_Calc;
float _ratioInCleanAir, _sensor_volt, RS_air, _a, _b, _ratio;
};
#endif //MQUnifiedsensor_H