Enable Calibration on Sensair S8

This commit is contained in:
seiichiro 2021-04-06 16:09:08 +02:00
parent b02df7d69b
commit 36963daac6
3 changed files with 20 additions and 3 deletions

View file

@ -53,7 +53,7 @@ void MHZ19C::calibrate(void) {
digitalWrite(calpin, LOW);
delay(7500);
digitalWrite(calpin, HIGH);
pinMode(PIN_PB4, INPUT_PULLUP);
pinMode(calpin, INPUT_PULLUP);
}
uint8_t MHZ19C::getSensorData(char * payload, uint8_t startbyte) {

View file

@ -49,6 +49,22 @@ uint8_t SENSAIRS8::getSensorData(char *payload, uint8_t startbyte) {
return startbyte+2;
}
void SENSAIRS8::calibrate(void) {
pinMode(calpin, OUTPUT);
digitalWrite(calpin, LOW);
delay(5000);
digitalWrite(calpin, HIGH);
pinMode(calpin, INPUT_PULLUP);
}
void SENSAIRS8::initialize(void) {
// Disable Auto Background Calibration
uint8_t _cmd[8] = {0xFE, 0x06, 0x00, 0x01F, 0x00, 0x00, 0xAC, 0x03};
while (Serial.available() > 0) Serial.read();
Serial.write(_cmd, 8);
Serial.flush();
}
// Read a Sensor Response
uint8_t SENSAIRS8::read() {
// Number of returned Bytes

View file

@ -35,6 +35,7 @@
class SENSAIRS8 : public AttSensor {
private:
uint8_t buffer[SER_BUF_LEN];
pin_size_t calpin = PIN_PB4; // PB4 is the Calibration Pin on the Addon PCB
uint8_t read();
void zeroBuffer(void);
@ -43,8 +44,8 @@ class SENSAIRS8 : public AttSensor {
public:
SENSAIRS8(void);
uint8_t getSensorData(char *payload, uint8_t startbyte);
void calibrate(void) {};
void initialize(void) {};
void calibrate(void);
void initialize(void);
uint8_t numBytes(void) {return 2;};
};