Closed Nic30 closed 1 month ago
it could be like:
`class MQ2GasSensor : public MQUnifiedsensor { public: MQ2GasSensor(const char board, float voltageResolution, int bitResolution, int pin, const char type) : MQUnifiedsensor(board, voltageResolution, bitResolution, pin, type) {}
float getPpmH2() {
setA(987.99);
setB(-2.162);
return readSensor();
}
float getPpmLPG() {
setA(574.25);
setB(-2.222);
return readSensor();
}
float getPpmCO() {
setA(36974);
setB(-3.109);
return readSensor();
}
float getPpmAlcohol() {
setA(3616.1);
setB(-2.675);
return readSensor();
}
float getPpmPropane() {
setA(658.71);
setB(-2.168);
return readSensor();
}
};`
Could you reply to all examples, and send us the pull or merge request? @Nic30 Thanks ;)
Closed due to the absence of an associated pull request for an extended period.
I would like to avoid duplication of constant in my project. What I did is to copy A,B interpolation coefficients from examples.
There are 2 things which can be done. 1st is to include some array which will contain coefficients or there could be class for every gas sensor with a proper method. Second variant seems to me as better because it is faster and intuitive.