-
Notifications
You must be signed in to change notification settings - Fork 2
/
Si7021.h
56 lines (45 loc) · 1.1 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
52
53
54
55
56
/*
Added by Liuji Shang
*/
#ifndef SI7021_H
#define SI7021_H
#include "Arduino.h"
/* Si7021 CMD Code */
#define Measure_RH_M 0xE5
#define Measure_RH_NM 0xF5
#define Measure_T_M 0xE3
#define Measure_T_M 0xF3
#define Read_Temp_RH 0xE0
#define RESET 0xFE
#define Write_RH_T_REG 0xE6
#define Read_RH_T_REG 0xE7
#define Read_ID_1_1 0xFA
#define Read_ID_1_2 0x0F
#define Read_ID_2_1 0xFC
#define Read_ID_2_2 0xC9
#define Read_Rev_1 0x84
#define Read_Rev_2 0xB8
/* ID Register */
#define ID_SI7021 0x15
#define WAKE_UP_TIME 15
#define SI7021_ADR 0x40
/* Coefficients */
#define TEMPERATURE_OFFSET 46.85
#define TEMPERATURE_MULTIPLE 175.72
#define TEMPERATURE_SLOPE 65536
#define HUMIDITY_OFFSET 6
#define HUMIDITY_MULTIPLE 125
#define HUMIDITY_SLOPE 65536
class Si7021
{
public:
Si7021();
bool detectSensor( );
float getTemperature( );
float getHumidity( );
private:
float _last_temperature;
unsigned int _tempMeasurement();
unsigned int _RHMeasurement();
};
#endif // SI7021_H