27 #include <mraa/i2c.hpp>
28 #include <mraa/spi.hpp>
29 #include <mraa/gpio.hpp>
31 #include "upm/iPressureSensor.hpp"
32 #include "upm/iTemperatureSensor.hpp"
34 #define BMP280_DEFAULT_I2C_BUS 0
35 #define BMP280_DEFAULT_SPI_BUS 0
36 #define BMP280_DEFAULT_ADDR 0x77
37 #define BMP280_DEFAULT_CHIPID 0x58
78 const uint8_t BMP280_RESET_BYTE = 0xb6;
81 const int CALIBRATION_BYTES = 26;
86 typedef enum : uint8_t {
120 REG_CTRL_MEAS = 0xf4,
123 REG_PRESSURE_MSB = 0xf7,
124 REG_PRESSURE_LSB = 0xf8,
125 REG_PRESSURE_XLSB = 0xf9,
127 REG_TEMPERATURE_MSB = 0xfa,
128 REG_TEMPERATURE_LSB = 0xfb,
129 REG_TEMPERATURE_XLSB = 0xfc
136 CONFIG_SPI3W_EN = 0x01,
140 CONFIG_FILTER0 = 0x04,
141 CONFIG_FILTER1 = 0x08,
142 CONFIG_FILTER2 = 0x10,
143 _CONFIG_FILTER_MASK = 7,
144 _CONFIG_FILTER_SHIFT = 2,
149 _CONFIG_T_SB_MASK = 7,
150 _CONFIG_T_SB_SHIFT = 5
183 CTRL_MEAS_MODE0 = 0x01,
184 CTRL_MEAS_MODE1 = 0x02,
185 _CTRL_MEAS_MODE_MASK = 3,
186 _CTRL_MEAS_MODE_SHIFT = 0,
188 CTRL_MEAS_OSRS_P0 = 0x04,
189 CTRL_MEAS_OSRS_P1 = 0x08,
190 CTRL_MEAS_OSRS_P2 = 0x10,
191 _CTRL_MEAS_OSRS_P_MASK = 7,
192 _CTRL_MEAS_OSRS_P_SHIFT = 2,
194 CTRL_MEAS_OSRS_T0 = 0x04,
195 CTRL_MEAS_OSRS_T1 = 0x08,
196 CTRL_MEAS_OSRS_T2 = 0x10,
197 _CTRL_MEAS_OSRS_T_MASK = 7,
198 _CTRL_MEAS_OSRS_T_SHIFT = 5
216 OSRS_P_OVERSAMPLING_1 = 1,
217 OSRS_P_OVERSAMPLING_2 = 2,
218 OSRS_P_OVERSAMPLING_4 = 3,
219 OSRS_P_OVERSAMPLING_8 = 4,
220 OSRS_P_OVERSAMPLING_16 = 5
228 OSRS_T_OVERSAMPLING_1 = 1,
229 OSRS_T_OVERSAMPLING_2 = 2,
230 OSRS_T_OVERSAMPLING_4 = 3,
231 OSRS_T_OVERSAMPLING_8 = 4,
232 OSRS_T_OVERSAMPLING_16 = 5
239 STATUS_IM_UPDATE = 0x01,
241 STATUS_MEASURING = 0x08
251 USAGE_MODE_HANDHELD_LOW_POWER = 0,
252 USAGE_MODE_HANDHELD_DYNAMIC = 1,
253 USAGE_MODE_WEATHER_MONITOR = 2,
254 USAGE_MODE_FLOOR_CHG_DETECT = 3,
255 USAGE_MODE_DROP_DETECT = 4,
256 USAGE_MODE_INDOOR_NAV = 5
275 BMP280(
int bus=BMP280_DEFAULT_I2C_BUS,
int addr=BMP280_DEFAULT_ADDR,
276 int cs=-1, uint8_t theChipID=BMP280_DEFAULT_CHIPID);
396 int getTemperatureCelsius()
409 mraa::Gpio *m_gpioCS;
445 int readRegs(uint8_t reg, uint8_t *buffer,
int len);
453 void writeReg(uint8_t reg, uint8_t val);
459 virtual void readCalibrationData();
487 int32_t bmp280_compensate_T_int32(int32_t adc_T);
488 uint32_t bmp280_compensate_P_int64(int32_t adc_P);
void writeReg(uint8_t reg, uint8_t val)
Definition: bmp280.cxx:266
CONFIG_BITS_T
Definition: bmp280.hpp:135
BMP280(int bus=BMP280_DEFAULT_I2C_BUS, int addr=BMP280_DEFAULT_ADDR, int cs=-1, uint8_t theChipID=BMP280_DEFAULT_CHIPID)
Definition: bmp280.cxx:55
int readRegs(uint8_t reg, uint8_t *buffer, int len)
Definition: bmp280.cxx:223
float getAltitude(float seaLevelhPA=1013.25)
Definition: bmp280.cxx:190
float getPressure()
Definition: bmp280.cxx:397
BMP280_REGS_T
Definition: bmp280.hpp:86
OSRS_T_T
Definition: bmp280.hpp:226
virtual void setUsageMode(USAGE_MODE_T mode)
Definition: bmp280.cxx:458
uint8_t readReg(uint8_t reg)
Definition: bmp280.cxx:196
Interface for Temperature Sensors.
Definition: iTemperatureSensor.hpp:34
OSRS_P_T
Definition: bmp280.hpp:214
void setMeasureMode(MODES_T mode)
Definition: bmp280.cxx:422
void reset()
Definition: bmp280.cxx:319
T_SB_T
Definition: bmp280.hpp:167
void setOversampleRatePressure(OSRS_P_T rate)
Definition: bmp280.cxx:433
virtual void update()
Definition: bmp280.cxx:139
virtual ~BMP280()
Definition: bmp280.cxx:127
STATUS_T
Definition: bmp280.hpp:238
CTRL_MEAS_T
Definition: bmp280.hpp:182
const char * getModuleName()
Definition: bmp280.hpp:391
void setTimerStandby(T_SB_T tsb)
Definition: bmp280.cxx:412
FILTER_T
Definition: bmp280.hpp:156
void setOversampleRateTemperature(OSRS_T_T rate)
Definition: bmp280.cxx:443
USAGE_MODE_T
Definition: bmp280.hpp:250
float getTemperature(bool fahrenheit=false)
Definition: bmp280.cxx:389
API for the BMP280 Digital Pressure Sensor.
Definition: bmp280.hpp:75
void setFilter(FILTER_T filter)
Definition: bmp280.cxx:402
uint8_t getChipID()
Definition: bmp280.cxx:313
MODES_T
Definition: bmp280.hpp:204
Interface for Pressue Sensors.
Definition: iPressureSensor.hpp:38