mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-15 05:17:30 +03:00
Fixed overflow
This commit is contained in:
parent
abac48da38
commit
1b351f9495
@ -38,17 +38,22 @@ void setup() {
|
||||
Remarks: This function create the sensor object.
|
||||
************************************************************************************/
|
||||
MQ3.setRegressionMethod("Exponential");
|
||||
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configurate the ecuation values
|
||||
|
||||
/*
|
||||
//Si el valor de RL es diferente a 10K por favor asigna tu valor de RL con el siguiente metodo:
|
||||
MQ3.setRL(10);
|
||||
*/
|
||||
|
||||
MQ3.init();
|
||||
MQ3.serialDebug(true);
|
||||
//pinMode(calibration_button, INPUT);
|
||||
}
|
||||
|
||||
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);
|
||||
*/
|
||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
MQ3.readSensor(); // Sensor will read PPM concentration using the a and b values setted before or on setup
|
||||
MQ3.serialDebug(); // Will print the table on the serial port
|
||||
/*
|
||||
//Rutina de calibracion - Uncomment if you need (setup too and header)
|
||||
if(calibration_button)
|
||||
@ -57,6 +62,7 @@ void loop() {
|
||||
MQ3.setR0(R0);
|
||||
}
|
||||
*/
|
||||
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -66,6 +72,7 @@ void loop() {
|
||||
//Lecture will be saved in lecture variable
|
||||
//float lecture = MQ3.readSensor("", true); // Return Alcohol concentration
|
||||
// Options, uncomment where you need
|
||||
/*
|
||||
MQ3.setA(2*10^31); MQ3.setB(19.01); // Configurate the ecuation values
|
||||
CH4 = MQ3.readSensor(); // Return CH4 concentration
|
||||
|
||||
@ -83,6 +90,7 @@ void loop() {
|
||||
|
||||
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configurate the ecuation values
|
||||
Benzine = MQ3.readSensor(); // Return Benzene concentration
|
||||
*/
|
||||
|
||||
/*
|
||||
Serial.println("***************************");
|
||||
@ -97,5 +105,4 @@ void loop() {
|
||||
Serial.print("Benzine: ");Serial.print(Benzine,2);Serial.println(" mg/L");
|
||||
Serial.println("***************************");
|
||||
*/
|
||||
MQ3.serialDebug();
|
||||
}
|
@ -41,6 +41,7 @@ void MQUnifiedsensor::serialDebug(bool onSetup)
|
||||
{
|
||||
if(onSetup)
|
||||
{
|
||||
Serial.println();
|
||||
Serial.println("************************************************************************************************************************************************");
|
||||
Serial.println("MQ sensor reading library for arduino");
|
||||
|
||||
@ -93,7 +94,7 @@ float MQUnifiedsensor::readSensor()
|
||||
if(_regressionMethod == "Exponential") _PPM= _a*pow(_ratio, _b);
|
||||
if(_regressionMethod == "Linear") _PPM= _a*_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(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recomendation.
|
||||
return _PPM;
|
||||
}
|
||||
float MQUnifiedsensor::calibrate() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user