-
Notifications
You must be signed in to change notification settings - Fork 2
/
SHT31.h
53 lines (42 loc) · 1.14 KB
/
SHT31.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
#ifndef _SHT31_H_
#define _SHT31_H_
#include <Arduino.h>
#include <Wire.h>
#include "sensor.h"
#define SHT31_ADDR 0x44
#define SHT31_MEAS_HIGHREP_STRETCH 0x2C06
#define SHT31_MEAS_MEDREP_STRETCH 0x2C0D
#define SHT31_MEAS_LOWREP_STRETCH 0x2C10
#define SHT31_MEAS_HIGHREP 0x2400
#define SHT31_MEAS_MEDREP 0x240B
#define SHT31_MEAS_LOWREP 0x2416
#define SHT31_READSTATUS 0xF32D
#define SHT31_CLEARSTATUS 0x3041
#define SHT31_SOFTRESET 0x30A2
#define SHT31_HEATEREN 0x306D
#define SHT31_HEATERDIS 0x3066
/*
** User function:
**/
void SHT31_Init();
void SHT31_Handle();
class SHT31 {
public:
SHT31();
boolean begin(uint8_t i2caddr = SHT31_ADDR);
float getTemperature(void);
float getHumidity(void);
boolean getTempHum(void);//modify by wmy
uint16_t readStatus(void);
void reset(void);
void heater(boolean);
uint8_t crc8(const uint8_t *data, int len);
void StartMes(void);
private:
// boolean getTempHum(void);
void writeCommand(uint16_t cmd);
uint8_t _i2caddr;
float humidity, temp;
};
extern SHT31 sht31;
#endif