Browse Source

MH-Z19 auto-calibration setting (#1580 , #1592)

rules-rpn
Eugene Schava 5 years ago
committed by Max Prokhorov
parent
commit
e62d0df9be
2 changed files with 11 additions and 1 deletions
  1. +2
    -0
      code/espurna/sensor.ino
  2. +9
    -1
      code/espurna/sensors/MHZ19Sensor.h

+ 2
- 0
code/espurna/sensor.ino View File

@ -638,6 +638,8 @@ void _sensorLoad() {
MHZ19Sensor * sensor = new MHZ19Sensor();
sensor->setRX(MHZ19_RX_PIN);
sensor->setTX(MHZ19_TX_PIN);
if (getSetting("mhz19CalibrateAuto", 0).toInt() == 1)
sensor->setCalibrateAuto(true);
_sensors.push_back(sensor);
}
#endif


+ 9
- 1
code/espurna/sensors/MHZ19Sensor.h View File

@ -78,7 +78,7 @@ class MHZ19Sensor : public BaseSensor {
_serial = new SoftwareSerial(_pin_rx, _pin_tx, false, 32);
_serial->enableIntTx(false);
_serial->begin(9600);
calibrateAuto(false);
calibrateAuto(_calibrateAuto);
_ready = true;
_dirty = false;
@ -139,6 +139,13 @@ class MHZ19Sensor : public BaseSensor {
_write(buffer);
}
void setCalibrateAuto(boolean value) {
_calibrateAuto = value;
if (_ready) {
calibrateAuto(value);
}
}
protected:
// ---------------------------------------------------------------------
@ -214,6 +221,7 @@ class MHZ19Sensor : public BaseSensor {
double _co2 = 0;
unsigned int _pin_rx;
unsigned int _pin_tx;
bool _calibrateAuto = false;
SoftwareSerial * _serial = NULL;
};


Loading…
Cancel
Save