2018-06-23 12:32:55 +00:00
|
|
|
/* MHZ library
|
|
|
|
|
|
|
|
By Tobias Schürg
|
|
|
|
*/
|
|
|
|
#ifndef MHZ_H
|
|
|
|
#define MHZ_H
|
|
|
|
|
|
|
|
#if ARDUINO >= 100
|
|
|
|
#include "Arduino.h"
|
|
|
|
#else
|
|
|
|
#include "WProgram.h"
|
|
|
|
#endif
|
|
|
|
|
2018-07-07 14:05:40 +00:00
|
|
|
#include <SoftwareSerial.h>
|
2018-06-23 12:32:55 +00:00
|
|
|
|
2018-07-07 14:05:40 +00:00
|
|
|
// types of sensors.
|
|
|
|
extern const int MHZ14A;
|
|
|
|
extern const int MHZ19B;
|
2021-01-14 21:28:47 +00:00
|
|
|
extern const int MHZ_2K;
|
|
|
|
extern const int MHZ_5k;
|
|
|
|
extern const int MHZ_10K;
|
2018-07-07 14:05:40 +00:00
|
|
|
// status codes
|
|
|
|
extern const int STATUS_NO_RESPONSE;
|
|
|
|
extern const int STATUS_CHECKSUM_MISMATCH;
|
|
|
|
extern const int STATUS_INCOMPLETE;
|
|
|
|
extern const int STATUS_NOT_READY;
|
2018-06-23 12:32:55 +00:00
|
|
|
|
|
|
|
class MHZ {
|
2018-07-07 10:59:32 +00:00
|
|
|
public:
|
|
|
|
MHZ(uint8_t rxpin, uint8_t txpin, uint8_t pwmpin, uint8_t type);
|
2019-06-08 11:37:21 +00:00
|
|
|
MHZ(uint8_t rxpin, uint8_t txpin, uint8_t type);
|
|
|
|
MHZ(uint8_t pwmpin, uint8_t type);
|
2018-12-31 08:04:11 +00:00
|
|
|
MHZ(Stream * serial, uint8_t pwmpin, uint8_t type);
|
2019-06-08 11:37:21 +00:00
|
|
|
MHZ(Stream * serial, uint8_t type);
|
2018-06-23 12:32:55 +00:00
|
|
|
|
2018-07-07 10:59:32 +00:00
|
|
|
void setDebug(boolean enable);
|
2018-06-24 10:22:50 +00:00
|
|
|
|
2018-07-07 10:59:32 +00:00
|
|
|
boolean isPreHeating();
|
|
|
|
boolean isReady();
|
2021-01-14 21:28:47 +00:00
|
|
|
void setAutoCalibrate(boolean b);
|
|
|
|
void calibrateZero();
|
|
|
|
void setRange(int range);
|
|
|
|
// void calibrateSpan(int range); //only for professional use... see implementation and Dataheet.
|
2018-06-23 12:32:55 +00:00
|
|
|
|
2018-07-07 10:59:32 +00:00
|
|
|
int readCO2UART();
|
|
|
|
int readCO2PWM();
|
2019-06-08 11:37:21 +00:00
|
|
|
int getLastTemperature();
|
2018-06-24 10:22:50 +00:00
|
|
|
|
2018-07-07 10:59:32 +00:00
|
|
|
private:
|
2018-12-31 08:04:11 +00:00
|
|
|
uint8_t _pwmpin, _type, temperature;
|
2018-07-07 10:59:32 +00:00
|
|
|
boolean debug = false;
|
2018-06-23 12:32:55 +00:00
|
|
|
|
2018-12-31 08:04:11 +00:00
|
|
|
Stream * _serial;
|
2018-07-07 10:59:32 +00:00
|
|
|
byte getCheckSum(byte *packet);
|
2021-01-22 17:49:45 +00:00
|
|
|
|
|
|
|
unsigned long lastRequest = 0;
|
|
|
|
|
|
|
|
bool SerialConfigured = true;
|
|
|
|
bool PwmConfigured = true;
|
2018-07-07 10:59:32 +00:00
|
|
|
};
|
2018-06-23 12:32:55 +00:00
|
|
|
|
|
|
|
#endif
|