MatrixMiniR4 1.1.4
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
MiniR4_GroveI2C_BME280.h
Go to the documentation of this file.
1
15#ifndef _MiniR4_GroveI2C_BME280_H_
16#define _MiniR4_GroveI2C_BME280_H_
17
18#include <Arduino.h>
19#include <Wire.h>
20
21#ifndef ADDR_PCA954X
22# define ADDR_PCA954X 0x70
23#endif
24
25#define BME280_ADDRESS 0x76
26
27#define BME280_REG_DIG_T1 0x88
28#define BME280_REG_DIG_T2 0x8A
29#define BME280_REG_DIG_T3 0x8C
30
31#define BME280_REG_DIG_P1 0x8E
32#define BME280_REG_DIG_P2 0x90
33#define BME280_REG_DIG_P3 0x92
34#define BME280_REG_DIG_P4 0x94
35#define BME280_REG_DIG_P5 0x96
36#define BME280_REG_DIG_P6 0x98
37#define BME280_REG_DIG_P7 0x9A
38#define BME280_REG_DIG_P8 0x9C
39#define BME280_REG_DIG_P9 0x9E
40
41#define BME280_REG_DIG_H1 0xA1
42#define BME280_REG_DIG_H2 0xE1
43#define BME280_REG_DIG_H3 0xE3
44#define BME280_REG_DIG_H4 0xE4
45#define BME280_REG_DIG_H5 0xE5
46#define BME280_REG_DIG_H6 0xE7
47
48#define BME280_REG_CHIPID 0xD0
49#define BME280_REG_VERSION 0xD1
50#define BME280_REG_SOFTRESET 0xE0
51
52#define BME280_REG_CAL26 0xE1
53
54#define BME280_REG_CONTROLHUMID 0xF2
55#define BME280_REG_CONTROL 0xF4
56#define BME280_REG_CONFIG 0xF5
57#define BME280_REG_PRESSUREDATA 0xF7
58#define BME280_REG_TEMPDATA 0xFA
59#define BME280_REG_HUMIDITYDATA 0xFD
60
69 private:
70 int _devAddr;
71 bool isTransport_OK;
72 // Calibration data
73 uint16_t dig_T1;
74 int16_t dig_T2;
75 int16_t dig_T3;
76 uint16_t dig_P1;
77 int16_t dig_P2;
78 int16_t dig_P3;
79 int16_t dig_P4;
80 int16_t dig_P5;
81 int16_t dig_P6;
82 int16_t dig_P7;
83 int16_t dig_P8;
84 int16_t dig_P9;
85 uint8_t dig_H1;
86 int16_t dig_H2;
87 uint8_t dig_H3;
88 int16_t dig_H4;
89 int16_t dig_H5;
90 int8_t dig_H6;
91 int32_t t_fine;
92
93 // private functions
94 uint8_t BME280Read8(uint8_t reg);
95 uint16_t BME280Read16(uint8_t reg);
96 uint16_t BME280Read16LE(uint8_t reg);
97 int16_t BME280ReadS16(uint8_t reg);
98 int16_t BME280ReadS16LE(uint8_t reg);
99 uint32_t BME280Read24(uint8_t reg);
100 void writeRegister(uint8_t reg, uint8_t val);
101
102 void i2cMUXSelect();
103
104 public:
105 uint8_t _ch=0;
106 TwoWire* _pWire;
107
114 bool begin(int i2c_addr = BME280_ADDRESS);
120 float getTemperature(void);
121
127 float getPressure(void);
128
134 float getHumidity(void);
135
142 float calcAltitude(float pressure);
143
144};
145
146#endif
#define BME280_ADDRESS
A class for interfacing with the BME280 sensor.
float getTemperature(void)
Reads the temperature from the BME280 sensor.
bool begin(int i2c_addr=BME280_ADDRESS)
Initializes the BME280 sensor.
float calcAltitude(float pressure)
Calculates the altitude based on the pressure reading.
float getHumidity(void)
Reads the humidity from the BME280 sensor.
float getPressure(void)
Reads the pressure from the BME280 sensor.