-
Notifications
You must be signed in to change notification settings - Fork 0
/
MHZ.h
51 lines (39 loc) · 976 Bytes
/
MHZ.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* MHZ library
By Tobias Schürg
*/
#ifndef MHZ_H
#define MHZ_H
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <SoftwareSerial.h>
// types of sensors.
extern const int MHZ14A;
extern const int MHZ19B;
// 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);
MHZ(uint8_t rxpin, uint8_t txpin, uint8_t type);
MHZ(uint8_t pwmpin, uint8_t type);
MHZ(Stream * serial, uint8_t pwmpin, uint8_t type);
MHZ(Stream * serial, uint8_t type);
void setDebug(boolean enable);
boolean isPreHeating();
boolean isReady();
int readCO2UART();
int readCO2PWM();
int getLastTemperature();
private:
uint8_t _pwmpin, _type, temperature;
boolean debug = false;
Stream * _serial;
byte getCheckSum(byte *packet);
};
#endif