Adafruit DPS310 Arduino Library
Adafruit_DPS310.h
Go to the documentation of this file.
1 /**************************************************************************/
12 /**************************************************************************/
13 
14 #ifndef ADAFRUIT_DPS310_H
15 #define ADAFRUIT_DPS310_H
16 
17 #include <Adafruit_BusIO_Register.h>
18 #include <Adafruit_I2CDevice.h>
19 #include <Adafruit_SPIDevice.h>
20 #include <Adafruit_Sensor.h>
21 #include <Wire.h>
22 
23 /*=========================================================================
24 I2C ADDRESS/BITS
25 -----------------------------------------------------------------------*/
26 #define DPS310_I2CADDR_DEFAULT (0x77)
27 /*=========================================================================*/
28 
29 #define DPS310_PRSB2 0x00
30 #define DPS310_TMPB2 0x03
31 #define DPS310_PRSCFG 0x06
32 #define DPS310_TMPCFG 0x07
33 #define DPS310_MEASCFG 0x08
34 #define DPS310_CFGREG 0x09
35 #define DPS310_RESET 0x0C
36 #define DPS310_PRODREVID 0x0D
37 #define DPS310_TMPCOEFSRCE 0x28
38 
39 typedef enum {
49 
51 typedef enum {
61 
63 typedef enum {
64  DPS310_IDLE = 0b000,
68  DPS310_CONT_TEMP = 0b110,
71 
72 class Adafruit_DPS310;
73 
75 class Adafruit_DPS310_Temp : public Adafruit_Sensor {
76 public:
79  Adafruit_DPS310_Temp(Adafruit_DPS310 *parent) { _theDPS310 = parent; }
80  bool getEvent(sensors_event_t *);
81  void getSensor(sensor_t *);
82 
83 private:
84  int _sensorID = 310;
85  Adafruit_DPS310 *_theDPS310 = NULL;
86 };
87 
89 class Adafruit_DPS310_Pressure : public Adafruit_Sensor {
90 public:
93  Adafruit_DPS310_Pressure(Adafruit_DPS310 *parent) { _theDPS310 = parent; }
94  bool getEvent(sensors_event_t *);
95  void getSensor(sensor_t *);
96 
97 private:
98  int _sensorID = 311;
99  Adafruit_DPS310 *_theDPS310 = NULL;
100 };
101 
104 public:
105  Adafruit_DPS310(void);
106  ~Adafruit_DPS310(void);
107 
108  bool begin_I2C(uint8_t i2c_addr = DPS310_I2CADDR_DEFAULT,
109  TwoWire *wire = &Wire);
110  bool begin_SPI(uint8_t cs_pin, SPIClass *theSPI = &SPI);
111  bool begin_SPI(int8_t cs_pin, int8_t sck_pin, int8_t miso_pin,
112  int8_t mosi_pin);
113 
114  void reset(void);
115  void setMode(dps310_mode_t mode);
116 
117  void configurePressure(dps310_rate_t rate, dps310_oversample_t os);
118  void configureTemperature(dps310_rate_t rate, dps310_oversample_t os);
119 
120  bool pressureAvailable(void);
121  bool temperatureAvailable(void);
122 
123  float readAltitude(float seaLevelhPa = 1013.25);
124 
125  Adafruit_Sensor *getTemperatureSensor(void);
126  Adafruit_Sensor *getPressureSensor(void);
127 
128  bool getEvents(sensors_event_t *temp_event, sensors_event_t *pressure_event);
129 
130 private:
131  bool _init(void);
132  void _readCalibration(void);
133  void _read();
134 
135  int16_t _c0, _c1, _c01, _c11, _c20, _c21, _c30;
136  int32_t _c00, _c10;
137 
138  int32_t raw_pressure, raw_temperature;
139  float _temperature, _scaled_rawtemp, _pressure;
140  int32_t temp_scale, pressure_scale;
141 
142  Adafruit_I2CDevice *i2c_dev = NULL;
143  Adafruit_SPIDevice *spi_dev = NULL;
144 
145  Adafruit_DPS310_Temp *temp_sensor = NULL;
146  Adafruit_DPS310_Pressure *pressure_sensor = NULL;
147 
148  int32_t _sensorID;
149 };
150 
151 #endif
dps310_rate_t
Definition: Adafruit_DPS310.h:39
4 Hz
Definition: Adafruit_DPS310.h:54
dps310_oversample_t
Definition: Adafruit_DPS310.h:51
void getSensor(sensor_t *)
Gets the sensor_t data for the DPS310&#39;s temperature sensor.
Definition: Adafruit_DPS310.cpp:472
4 Hz
Definition: Adafruit_DPS310.h:42
Continuous pressure measurements.
Definition: Adafruit_DPS310.h:67
Definition: Adafruit_DPS310.h:75
32 Hz
Definition: Adafruit_DPS310.h:45
16 Hz
Definition: Adafruit_DPS310.h:44
2 Hz
Definition: Adafruit_DPS310.h:53
Adafruit_DPS310_Pressure(Adafruit_DPS310 *parent)
Create an Adafruit_Sensor compatible object for the pressure sensor.
Definition: Adafruit_DPS310.h:93
#define DPS310_I2CADDR_DEFAULT
Default breakout addres.
Definition: Adafruit_DPS310.h:26
64 Hz
Definition: Adafruit_DPS310.h:58
Continuous temp+pressure measurements.
Definition: Adafruit_DPS310.h:69
bool getEvent(sensors_event_t *)
Gets the temperature as a standard sensor event.
Definition: Adafruit_DPS310.cpp:495
Stopped/idle.
Definition: Adafruit_DPS310.h:64
Continuous pressure measurements.
Definition: Adafruit_DPS310.h:68
Adafruit_DPS310_Temp(Adafruit_DPS310 *parent)
Create an Adafruit_Sensor compatible object for the temp sensor.
Definition: Adafruit_DPS310.h:79
1 Hz
Definition: Adafruit_DPS310.h:52
8 Hz
Definition: Adafruit_DPS310.h:55
1 Hz
Definition: Adafruit_DPS310.h:40
dps310_mode_t
Definition: Adafruit_DPS310.h:63
Take single temperature measurement.
Definition: Adafruit_DPS310.h:66
2 Hz
Definition: Adafruit_DPS310.h:41
64 Hz
Definition: Adafruit_DPS310.h:46
32 Hz
Definition: Adafruit_DPS310.h:57
Definition: Adafruit_DPS310.h:89
Take single pressure measurement.
Definition: Adafruit_DPS310.h:65
128 Hz
Definition: Adafruit_DPS310.h:59
Definition: Adafruit_DPS310.h:103
128 Hz
Definition: Adafruit_DPS310.h:47
16 Hz
Definition: Adafruit_DPS310.h:56
8 Hz
Definition: Adafruit_DPS310.h:43