-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathSparkFun_Si7021_Breakout_Library.h
executable file
·92 lines (68 loc) · 2.21 KB
/
SparkFun_Si7021_Breakout_Library.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
SparkFun Si7021 Temperature and Humidity Breakout
By: Joel Bartlett
SparkFun Electronics
Date: December 10, 2015
This is an Arduino library for the Si7021 Temperature and Humidity Sensor Breakout
This library is based on the following libraries:
HTU21D Temperature / Humidity Sensor Library
By: Nathan Seidle
https://github.com/sparkfun/HTU21D_Breakout/tree/master/Libraries
Arduino Si7010 relative humidity + temperature sensor
By: Jakub Kaminski, 2014
https://github.com/teoqba/ADDRESS
This Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
For a copy of the GNU General Public License, see
<http://www.gnu.org/licenses/>.
*/
#ifndef SparkFun_Si7021_Breakout_Library_h
#define SparkFun_Si7021_Breakout_Library_h
#include <Arduino.h>
/****************Si7021 & HTU21D Definitions***************************/
#define ADDRESS 0x40
#define TEMP_MEASURE_HOLD 0xE3
#define HUMD_MEASURE_HOLD 0xE5
#define TEMP_MEASURE_NOHOLD 0xF3
#define HUMD_MEASURE_NOHOLD 0xF5
#define TEMP_PREV 0xE0
#define WRITE_USER_REG 0xE6
#define READ_USER_REG 0xE7
#define SOFT_RESET 0xFE
#define HTRE 0x02
#define _BV(bit) (1 << (bit))
#define CRC_POLY 0x988000 // Shifted Polynomial for CRC check
// Error codes
#define I2C_TIMEOUT 998
#define BAD_CRC 999
/****************Si7021 & HTU21D Class**************************************/
class Weather
{
public:
// Constructor
Weather();
int begin();
// Si7021 & HTU21D Public Functions
float getRH();
float readTemp();
float getTemp();
float readTempF();
float getTempF();
void heaterOn();
void heaterOff();
void changeResolution(uint8_t i);
void reset();
uint8_t checkID();
private:
//Si7021 & HTU21D Private Functions
uint16_t makeMeasurment(uint8_t command);
void writeReg(uint8_t value);
uint8_t readReg();
};
#endif