48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
|
/*
|
||
|
* si7021 library
|
||
|
* SI7021 Temperature and Humidity Sensor @ ESP32 i2c
|
||
|
*
|
||
|
* copyright: Jannik Beyerstedt | http://jannikbeyerstedt.de | code@jannikbeyerstedt.de
|
||
|
* license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
|
||
|
*/
|
||
|
|
||
|
#ifndef SI7021_H
|
||
|
#define SI7021_H
|
||
|
|
||
|
#include <cstdint>
|
||
|
|
||
|
#define SI7021_DEFAULT_ADDRESS (0x40)
|
||
|
|
||
|
#define SI7021_MEASRH_HOLD_CMD 0xE5
|
||
|
#define SI7021_MEASTEMP_HOLD_CMD 0xE3
|
||
|
#define SI7021_MEASRH_NOHOLD_CMD 0xF5
|
||
|
#define SI7021_MEASTEMP_NOHOLD_CMD 0xF3
|
||
|
#define SI7021_READPREVTEMP_CMD 0xE0
|
||
|
#define SI7021_RESET_CMD 0xFE
|
||
|
#define SI7021_READRHT_REG_CMD 0xE7
|
||
|
// #define SI7021_WRITERHT_REG_CMD 0xE6
|
||
|
// #define SI7021_READHEATER_REG_CMD 0x11
|
||
|
// #define SI7021_WRITEHEATER_REG_CMD 0x51
|
||
|
// #define SI7021_ID1_CMD 0xFA0F
|
||
|
// #define SI7021_ID2_CMD 0xFCC9
|
||
|
// #define SI7021_FIRMVERS_CMD 0x84B8
|
||
|
|
||
|
class Si7021 {
|
||
|
public:
|
||
|
Si7021(void);
|
||
|
bool begin(void);
|
||
|
void reset(void);
|
||
|
|
||
|
bool measure(void);
|
||
|
float temperature;
|
||
|
float humidity;
|
||
|
|
||
|
private:
|
||
|
// void writeRegister8(uint8_t reg, uint8_t value);
|
||
|
uint8_t readRegister8(uint8_t reg);
|
||
|
|
||
|
int8_t _i2caddr;
|
||
|
};
|
||
|
|
||
|
#endif // SI7021_H
|