-
Notifications
You must be signed in to change notification settings - Fork 11
/
Seeed_BMP280.h
67 lines (58 loc) · 1.67 KB
/
Seeed_BMP280.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
#ifndef _SEEED_BMP280_H_
#define _SEEED_BMP280_H_
#include <Arduino.h>
#include <Wire.h>
#define BMP280_ADDRESS 0x77
#define BMP280_REG_DIG_T1 0x88
#define BMP280_REG_DIG_T2 0x8A
#define BMP280_REG_DIG_T3 0x8C
#define BMP280_REG_DIG_P1 0x8E
#define BMP280_REG_DIG_P2 0x90
#define BMP280_REG_DIG_P3 0x92
#define BMP280_REG_DIG_P4 0x94
#define BMP280_REG_DIG_P5 0x96
#define BMP280_REG_DIG_P6 0x98
#define BMP280_REG_DIG_P7 0x9A
#define BMP280_REG_DIG_P8 0x9C
#define BMP280_REG_DIG_P9 0x9E
#define BMP280_REG_CHIPID 0xD0
#define BMP280_REG_VERSION 0xD1
#define BMP280_REG_SOFTRESET 0xE0
#define BMP280_REG_CONTROL 0xF4
#define BMP280_REG_CONFIG 0xF5
#define BMP280_REG_PRESSUREDATA 0xF7
#define BMP280_REG_TEMPDATA 0xFA
class BMP280 {
public:
bool init(int i2c_addr = BMP280_ADDRESS);
float getTemperature(void);
uint32_t getPressure(void);
float calcAltitude(float p0);
float calcAltitude(float p0, float p1, float t);
private:
bool isTransport_OK;
int _devAddr;
// Calibratino data
uint16_t dig_T1;
int16_t dig_T2;
int16_t dig_T3;
uint16_t dig_P1;
int16_t dig_P2;
int16_t dig_P3;
int16_t dig_P4;
int16_t dig_P5;
int16_t dig_P6;
int16_t dig_P7;
int16_t dig_P8;
int16_t dig_P9;
int32_t t_fine;
// private functoins
uint8_t bmp280Read8(uint8_t reg);
uint16_t bmp280Read16(uint8_t reg);
uint16_t bmp280Read16LE(uint8_t reg);
int16_t bmp280ReadS16(uint8_t reg);
int16_t bmp280ReadS16LE(uint8_t reg);
uint32_t bmp280Read24(uint8_t reg);
void writeRegister(uint8_t reg, uint8_t val);
};
#endif