MH-Z-CO2-Sensors/MHZ.h

48 lines
824 B
C
Raw Normal View History

/* 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-07-07 14:05:40 +00:00
// types of sensors.
extern const int MHZ14A;
extern const int MHZ19B;
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;
class MHZ {
public:
MHZ(uint8_t rxpin, uint8_t txpin, uint8_t pwmpin, uint8_t type);
void setDebug(boolean enable);
boolean isPreHeating();
boolean isReady();
int readCO2UART();
int readCO2PWM();
uint8_t getLastTemperature();
private:
uint8_t _rxpin, _txpin, _pwmpin, _type, temperature;
boolean debug = false;
SoftwareSerial co2Serial;
byte getCheckSum(byte *packet);
};
#endif