mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-31 21:20:04 +03:00
Multiple fixes
This commit is contained in:
parent
669783ddf1
commit
8f6b9d4358
BIN
.vscode/ipch/107d7fcd69521c40/mmap_address.bin
vendored
Normal file
BIN
.vscode/ipch/107d7fcd69521c40/mmap_address.bin
vendored
Normal file
Binary file not shown.
BIN
.vscode/ipch/61771500a4c0a721/mmap_address.bin
vendored
Normal file
BIN
.vscode/ipch/61771500a4c0a721/mmap_address.bin
vendored
Normal file
Binary file not shown.
BIN
.vscode/ipch/6ef2562d6eab9b2c/DHT.ipch
vendored
Normal file
BIN
.vscode/ipch/6ef2562d6eab9b2c/DHT.ipch
vendored
Normal file
Binary file not shown.
BIN
.vscode/ipch/6ef2562d6eab9b2c/mmap_address.bin
vendored
Normal file
BIN
.vscode/ipch/6ef2562d6eab9b2c/mmap_address.bin
vendored
Normal file
Binary file not shown.
BIN
.vscode/ipch/a3c6acb37808b72f/mmap_address.bin
vendored
Normal file
BIN
.vscode/ipch/a3c6acb37808b72f/mmap_address.bin
vendored
Normal file
Binary file not shown.
@ -8,51 +8,63 @@
|
|||||||
//Set _MQ variable with MQ sensor selected
|
//Set _MQ variable with MQ sensor selected
|
||||||
if(_type == 2)
|
if(_type == 2)
|
||||||
{
|
{
|
||||||
_MQ = MQ2;
|
memcpy(_MQ, MQ2, sizeof(MQ2));
|
||||||
|
//_MQ = MQ2;
|
||||||
}
|
}
|
||||||
else if(_type == 3)
|
else if(_type == 3)
|
||||||
{
|
{
|
||||||
_MQ = MQ3;
|
memcpy(_MQ, MQ3, sizeof(MQ3));
|
||||||
|
//_MQ = MQ3;
|
||||||
}
|
}
|
||||||
else if(_type == 4)
|
else if(_type == 4)
|
||||||
{
|
{
|
||||||
_MQ = MQ4;
|
memcpy(_MQ, MQ4, sizeof(MQ4));
|
||||||
|
//_MQ = MQ4;
|
||||||
}
|
}
|
||||||
else if(_type == 5)
|
else if(_type == 5)
|
||||||
{
|
{
|
||||||
_MQ = MQ5;
|
memcpy(_MQ, MQ5, sizeof(MQ5));
|
||||||
|
//_MQ = MQ5;
|
||||||
}
|
}
|
||||||
else if(_type == 6)
|
else if(_type == 6)
|
||||||
{
|
{
|
||||||
_MQ = MQ6;
|
memcpy(_MQ, MQ6, sizeof(MQ6));
|
||||||
|
//_MQ = MQ6;
|
||||||
}
|
}
|
||||||
else if(_type == 7)
|
else if(_type == 7)
|
||||||
{
|
{
|
||||||
_MQ = MQ7;
|
memcpy(_MQ, MQ7, sizeof(MQ7));
|
||||||
|
//_MQ = MQ7;
|
||||||
}
|
}
|
||||||
else if(_type == 8)
|
else if(_type == 8)
|
||||||
{
|
{
|
||||||
_MQ = MQ8;
|
memcpy(_MQ, MQ8, sizeof(MQ8));
|
||||||
|
//_MQ = MQ8;
|
||||||
}
|
}
|
||||||
else if(_type == 9)
|
else if(_type == 9)
|
||||||
{
|
{
|
||||||
_MQ = MQ9;
|
memcpy(_MQ, MQ9, sizeof(MQ9));
|
||||||
|
//_MQ = MQ9;
|
||||||
}
|
}
|
||||||
else if(_type == 131)
|
else if(_type == 131)
|
||||||
{
|
{
|
||||||
_MQ = MQ131;
|
memcpy(_MQ, MQ131, sizeof(MQ131));
|
||||||
|
//_MQ = MQ131;
|
||||||
}
|
}
|
||||||
else if(_type == 135)
|
else if(_type == 135)
|
||||||
{
|
{
|
||||||
_MQ = MQ135;
|
memcpy(_MQ, MQ135, sizeof(MQ135));
|
||||||
|
//_MQ = MQ135;
|
||||||
}
|
}
|
||||||
else if(_type == 303)
|
else if(_type == 303)
|
||||||
{
|
{
|
||||||
_MQ = MQ303A;
|
memcpy(_MQ, MQ303A, sizeof(MQ303A));
|
||||||
|
//_MQ = MQ303A;
|
||||||
}
|
}
|
||||||
else if(_type == 309)
|
else if(_type == 309)
|
||||||
{
|
{
|
||||||
_MQ = MQ309;
|
memcpy(_MQ, MQ309A, sizeof(MQ309A));
|
||||||
|
//_MQ = MQ309;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,10 +72,20 @@ void MQUnifiedsensor::setR0(double R0) {
|
|||||||
this->_R0 = R0;
|
this->_R0 = R0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MQUnifiedsensor::readSensor(String nameLectureRequeired = "")
|
int MQUnifiedsensor::readSensor(String nameLectureRequeired, bool print)
|
||||||
{
|
{
|
||||||
setSensorCharacteristics(nameLectureRequeired);
|
setSensorCharacteristics(nameLectureRequeired);
|
||||||
return readPPM(_m, _b);
|
_PPM =readPPM(_m, _b);
|
||||||
|
if(print)
|
||||||
|
{
|
||||||
|
Serial.print("Medicion: ");
|
||||||
|
Serial.println(_PPM);
|
||||||
|
Serial.print("Slope: ");
|
||||||
|
Serial.print(String(_m));
|
||||||
|
Serial.print("B point: ");
|
||||||
|
Serial.println(String(_b));
|
||||||
|
}
|
||||||
|
return _PPM;
|
||||||
}
|
}
|
||||||
void MQUnifiedsensor::inicializar()
|
void MQUnifiedsensor::inicializar()
|
||||||
{
|
{
|
||||||
@ -133,8 +155,8 @@ void MQUnifiedsensor::setSensorCharacteristics(String nameLectureRequeired)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_m = MQ[indexSlopeLectures[wantedpos]];
|
_m = _MQ[indexSlopeLectures[wantedpos]];
|
||||||
_b = MQ[indexBPointLectures[wantedpos]];
|
_b = _MQ[indexBPointLectures[wantedpos]];
|
||||||
}
|
}
|
||||||
|
|
||||||
double MQUnifiedsensor::calibrate() {
|
double MQUnifiedsensor::calibrate() {
|
||||||
|
@ -12,11 +12,11 @@ class MQUnifiedsensor
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
void MQUnifiedsensor(int pin, int type);
|
MQUnifiedsensor(int pin, int type);
|
||||||
void setR0(double R0);
|
void setR0(double R0);
|
||||||
void setSensorCharacteristics(int MQ[38], String nameLectureReqeuired);
|
void setSensorCharacteristics(String nameLectureReqeuired);
|
||||||
|
|
||||||
int readSensor(String nameLectureReqeuired = "");
|
int readSensor(String nameLectureRequeired = "", bool print = false);
|
||||||
int readPPM(int m, int b);
|
int readPPM(int m, int b);
|
||||||
void inicializar();
|
void inicializar();
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class MQUnifiedsensor
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _pin, _type;
|
int _pin, _type, _PPM;
|
||||||
double _R0, _m, _b, _MQ[38];
|
double _R0, _m, _b, _MQ[38];
|
||||||
const float VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
|
const float VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
|
||||||
const int ADC_RESOLUTION = 10; // for 10bit analog to digital converter.
|
const int ADC_RESOLUTION = 10; // for 10bit analog to digital converter.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user