-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathSI7021.h
52 lines (45 loc) · 1.07 KB
/
SI7021.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
/*
Copyright 2014 Marcus Sorensen <[email protected]>
This program is licensed under the GNU LGPL v2.1
*/
#ifndef si7021_h
#define si7021_h
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#ifdef __AVR_ATtiny85__
#include "TinyWireM.h"
#define Wire TinyWireM
#else
#include <avr/pgmspace.h>
#include <Wire.h>
#endif
typedef struct si7021_env {
int celsiusHundredths;
int fahrenheitHundredths;
unsigned int humidityBasisPoints;
} si7021_env;
class SI7021
{
public:
SI7021();
bool begin();
bool sensorExists();
int getFahrenheitHundredths();
int getCelsiusHundredths();
unsigned int getHumidityPercent();
unsigned int getHumidityBasisPoints();
struct si7021_env getHumidityAndTemperature();
int getSerialBytes(byte * buf);
int getEightByteSerial(byte * buf);
int getDeviceId();
void setHeater(bool on);
private:
void _command(byte * cmd, byte * buf );
void _writeReg(byte * reg, int reglen);
int _readReg(byte * reg, int reglen);
int _getCelsiusPostHumidity();
};
#endif