Hummingbird Flight Software
Flight software for the Hummingbird FCU quadcopter flight controller. Designed to run on the Teensy 4.1. Developed with VSCode+PlatformIO.
bmp388_barometer.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // BMP388 BAROMETRIC ALTIMETER AND TEMPERATURE SENSOR
3 //
4 // Code By: Michael Wrona
5 // Created: 25 Feb 2021
6 // ----------------------------------------------------------------------------
12 #pragma once
13 
14 
15 #include <Arduino.h>
16 #include <Wire.h>
17 #include "hummingbird_config.h"
18 #include "debugging.h"
19 // #include "constants.h"
20 #include "Adafruit_Sensor.h"
21 #include "Adafruit_BMP3XX.h"
22 
23 #if defined(DEBUG)
24  #define BMP388_DEBUG // Enable/disable debug print messages
25 #endif
26 
27 
28 class BMP388Baro:
29 public Adafruit_BMP3XX
30 {
31 public:
32  BMP388Baro(TwoWire *wireInput = &SENSOR_I2C);
33  bool Initialize(uint8_t presOS=BMP3_NO_OVERSAMPLING, uint8_t tempOS=BMP3_NO_OVERSAMPLING,
34  uint8_t iirCoef=BMP3_IIR_FILTER_COEFF_3, uint8_t odr=BMP3_ODR_50_HZ);
35  bool ReadSensor();
36  float GetPressure();
37  float GetTemperature();
38  uint32_t prevMeasMicros; // [us] Previous measurement micros()
39 protected:
40 private:
41  bool connected; // Whether or not a good connection was made
42  float _t; // [C] Raw temperature
43  float _p; // [Pa] Raw pressure
44  TwoWire *_SensorWire; // I2C interface that the sensor is connected to.
45 };
This is driver code for the BMP388 temp/pres sensor.
Definition: bmp388_barometer.h:30
BMP388Baro(TwoWire *wireInput=&SENSOR_I2C)
This is driver code for the BMP388 temp/pres sensor.
Definition: bmp388_barometer.cpp:23
float GetPressure()
Return atmospheric pressure in [Pa].
Definition: bmp388_barometer.cpp:146
bool Initialize(uint8_t presOS=BMP3_NO_OVERSAMPLING, uint8_t tempOS=BMP3_NO_OVERSAMPLING, uint8_t iirCoef=BMP3_IIR_FILTER_COEFF_3, uint8_t odr=BMP3_ODR_50_HZ)
Use Adafruit's BMP388 library to configure the BMP388.
Definition: bmp388_barometer.cpp:47
bool connected
Definition: bmp388_barometer.h:41
bool ReadSensor()
Use Adafruit's BMP388 library to read temperature and pressure registers.
Definition: bmp388_barometer.cpp:118
TwoWire * _SensorWire
Definition: bmp388_barometer.h:44
float _t
Definition: bmp388_barometer.h:42
uint32_t prevMeasMicros
Definition: bmp388_barometer.h:38
float _p
Definition: bmp388_barometer.h:43
float GetTemperature()
Return atmospheric temperature in [C].
Definition: bmp388_barometer.cpp:160
#define SENSOR_I2C
UBER-EXTREME CAUTION SHOULD BE USED CHANGING PARAMETERS IN THIS FILE.
Definition: hummingbird_config.h:26