mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-15 05:17:30 +03:00
Added test equation
This commit is contained in:
parent
b992078540
commit
a4ea39b2f4
@ -36,6 +36,8 @@ MQUnifiedsensor MQ7(placa, Voltage_Resolution, ADC_Bit_Resolution, pin7, type);
|
|||||||
MQUnifiedsensor MQ8(placa, Voltage_Resolution, ADC_Bit_Resolution, pin8, type);
|
MQUnifiedsensor MQ8(placa, Voltage_Resolution, ADC_Bit_Resolution, pin8, type);
|
||||||
MQUnifiedsensor MQ9(placa, Voltage_Resolution, ADC_Bit_Resolution, pin9, type);
|
MQUnifiedsensor MQ9(placa, Voltage_Resolution, ADC_Bit_Resolution, pin9, type);
|
||||||
|
|
||||||
|
int ratio[10] = {};
|
||||||
|
int expectedValue[10] = {};
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -87,6 +89,24 @@ void setup()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
// Testing MQ2 LPG
|
||||||
|
ratio = {};
|
||||||
|
expectedValue = {};
|
||||||
|
|
||||||
|
// Testing MQ3 Benzene
|
||||||
|
|
||||||
|
// Testing MQ4 CH4
|
||||||
|
|
||||||
|
// Testing MQ5 H2
|
||||||
|
|
||||||
|
// Testing MQ6 CH4
|
||||||
|
|
||||||
|
// Testing MQ7 CO
|
||||||
|
|
||||||
|
// Testing MQ8 H2
|
||||||
|
|
||||||
|
// Testing MQ9 LPG
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,12 @@ void MQUnifiedsensor::update()
|
|||||||
{
|
{
|
||||||
_sensor_volt = this->getVoltage();
|
_sensor_volt = this->getVoltage();
|
||||||
}
|
}
|
||||||
|
float MQUnifiedsensor::calculatePPM(double ratio)
|
||||||
|
{
|
||||||
|
if(_regressionMethod == "Exponential") _PPM= _a*pow(ratio, _b);
|
||||||
|
if(_regressionMethod == "Linear") _PPM= _a*ratio + _b;
|
||||||
|
return _PPM;
|
||||||
|
}
|
||||||
float MQUnifiedsensor::readSensor()
|
float MQUnifiedsensor::readSensor()
|
||||||
{
|
{
|
||||||
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
|
@ -29,6 +29,7 @@ class MQUnifiedsensor
|
|||||||
//user functions
|
//user functions
|
||||||
float calibrate(float ratioInCleanAir);
|
float calibrate(float ratioInCleanAir);
|
||||||
float readSensor();
|
float readSensor();
|
||||||
|
float calculatePPM(double ratio = 0);
|
||||||
|
|
||||||
//get function for info
|
//get function for info
|
||||||
double getR0();
|
double getR0();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user