Skip to content

Commit 82248d6

Browse files
authored
Merge pull request #805 from adafruit/add-bmp581
add(bmp581): initial work
2 parents 9b79afc + e604ee8 commit 82248d6

File tree

5 files changed

+157
-3
lines changed

5 files changed

+157
-3
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper
77
category=Communication
88
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
99
architectures=*
10-
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit MLX90632 Library, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit AS5600 Library, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306
10+
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit MLX90632 Library, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit AS5600 Library, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit BMP5xx Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306

platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ lib_deps =
3636
adafruit/Adafruit BME280 Library
3737
adafruit/Adafruit BMP280 Library
3838
adafruit/Adafruit BMP3XX Library
39+
adafruit/Adafruit BMP5XX Library
3940
adafruit/Adafruit DPS310
4041
adafruit/Adafruit DS248x
4142
adafruit/Adafruit INA219

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,27 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
282282
(strcmp("bmp390", msgDeviceInitReq->i2c_device_name) == 0)) {
283283
_bmp3xx = new WipperSnapper_I2C_Driver_BMP3XX(this->_i2c, i2cAddress);
284284
if (!_bmp3xx->begin()) {
285-
WS_DEBUG_PRINTLN("ERROR: Failed to initialize BMP388!");
285+
WS_DEBUG_PRINTLN("ERROR: Failed to initialize BMP3xx!");
286286
_busStatusResponse =
287287
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
288288
return false;
289289
}
290290
_bmp3xx->configureDriver(msgDeviceInitReq);
291291
drivers.push_back(_bmp3xx);
292-
WS_DEBUG_PRINTLN("BMP388 Initialized Successfully!");
292+
WS_DEBUG_PRINTLN("BMP3xx Initialized Successfully!");
293+
} else if ((strcmp("bmp580", msgDeviceInitReq->i2c_device_name) == 0) ||
294+
(strcmp("bmp581", msgDeviceInitReq->i2c_device_name) == 0) ||
295+
(strcmp("bmp585", msgDeviceInitReq->i2c_device_name) == 0)) {
296+
_bmp5xx = new WipperSnapper_I2C_Driver_BMP5XX(this->_i2c, i2cAddress);
297+
if (!_bmp5xx->begin()) {
298+
WS_DEBUG_PRINTLN("ERROR: Failed to initialize BMP5xx!");
299+
_busStatusResponse =
300+
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
301+
return false;
302+
}
303+
_bmp5xx->configureDriver(msgDeviceInitReq);
304+
drivers.push_back(_bmp5xx);
305+
WS_DEBUG_PRINTLN("BMP5xx Initialized Successfully!");
293306
} else if ((strcmp("bme680", msgDeviceInitReq->i2c_device_name) == 0) ||
294307
(strcmp("bme688", msgDeviceInitReq->i2c_device_name) == 0)) {
295308
_bme680 = new WipperSnapper_I2C_Driver_BME680(this->_i2c, i2cAddress);

src/components/i2c/WipperSnapper_I2C.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "drivers/WipperSnapper_I2C_Driver_BME680.h"
2929
#include "drivers/WipperSnapper_I2C_Driver_BMP280.h"
3030
#include "drivers/WipperSnapper_I2C_Driver_BMP3XX.h"
31+
#include "drivers/WipperSnapper_I2C_Driver_BMP5XX.h"
3132
#include "drivers/WipperSnapper_I2C_Driver_D6T1A.h"
3233
#include "drivers/WipperSnapper_I2C_Driver_DPS310.h"
3334
#include "drivers/WipperSnapper_I2C_Driver_DS2484.h"
@@ -169,6 +170,7 @@ class WipperSnapper_Component_I2C {
169170
WipperSnapper_I2C_Driver_BME280 *_bme280 = nullptr;
170171
WipperSnapper_I2C_Driver_BMP280 *_bmp280 = nullptr;
171172
WipperSnapper_I2C_Driver_BMP3XX *_bmp3xx = nullptr;
173+
WipperSnapper_I2C_Driver_BMP5XX *_bmp5xx = nullptr;
172174
WipperSnapper_I2C_Driver_BME680 *_bme680 = nullptr;
173175
WipperSnapper_I2C_Driver_HDC302X *_hdc302x = nullptr;
174176
WipperSnapper_I2C_Driver_HTS221 *_hts221 = nullptr;
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*!
2+
* @file WipperSnapper_I2C_Driver_BMP5XX.h
3+
*
4+
* Device driver for a BMP5XX precision pressure sensor breakout.
5+
*
6+
* Adafruit invests time and resources providing this open source code,
7+
* please support Adafruit and open-source hardware by purchasing
8+
* products from Adafruit!
9+
*
10+
* Copyright (c) Tyeth Gundry 2025 for Adafruit Industries.
11+
*
12+
* MIT license, all text here must be included in any redistribution.
13+
*
14+
*/
15+
16+
#ifndef WipperSnapper_I2C_Driver_BMP5XX_H
17+
#define WipperSnapper_I2C_Driver_BMP5XX_H
18+
19+
#include <Adafruit_BMP5xx.h>
20+
21+
#include "WipperSnapper_I2C_Driver.h"
22+
23+
#define SEALEVELPRESSURE_HPA (1013.25) ///< Default sea level pressure, in hPa
24+
25+
/**************************************************************************/
26+
/*!
27+
@brief Class that provides a sensor driver for the BMP5XX temperature
28+
and pressure sensor.
29+
*/
30+
/**************************************************************************/
31+
class WipperSnapper_I2C_Driver_BMP5XX : public WipperSnapper_I2C_Driver {
32+
public:
33+
/*******************************************************************************/
34+
/*!
35+
@brief Constructor for an BMP5XX sensor.
36+
@param i2c
37+
The I2C interface.
38+
@param sensorAddress
39+
7-bit device address.
40+
*/
41+
/*******************************************************************************/
42+
WipperSnapper_I2C_Driver_BMP5XX(TwoWire *i2c, uint16_t sensorAddress)
43+
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
44+
_bmp5xx = nullptr;
45+
}
46+
47+
/*******************************************************************************/
48+
/*!
49+
@brief Destructor for an BMP5XX sensor.
50+
*/
51+
/*******************************************************************************/
52+
~WipperSnapper_I2C_Driver_BMP5XX() {
53+
if (_bmp5xx) {
54+
delete _bmp5xx;
55+
_bmp5xx = nullptr;
56+
}
57+
}
58+
59+
/*******************************************************************************/
60+
/*!
61+
@brief Initializes the BMP5XX sensor and begins I2C.
62+
@returns True if initialized successfully, False otherwise.
63+
*/
64+
/*******************************************************************************/
65+
bool begin() {
66+
_bmp5xx = new Adafruit_BMP5xx();
67+
if (!_bmp5xx->begin(_sensorAddress, _i2c)) {
68+
delete _bmp5xx;
69+
_bmp5xx = nullptr;
70+
return false;
71+
}
72+
73+
// Set up oversampling and filter initialization
74+
return _bmp5xx->setTemperatureOversampling(BMP5XX_OVERSAMPLING_8X) &&
75+
_bmp5xx->setPressureOversampling(BMP5XX_OVERSAMPLING_16X) &&
76+
_bmp5xx->setIIRFilterCoeff(BMP5XX_IIR_FILTER_COEFF_3) &&
77+
_bmp5xx->setOutputDataRate(BMP5XX_ODR_50_HZ) &&
78+
_bmp5xx->setPowerMode(BMP5XX_POWERMODE_NORMAL) &&
79+
_bmp5xx->enablePressure(true);
80+
}
81+
82+
/*******************************************************************************/
83+
/*!
84+
@brief Gets the BMP5XX's current temperature.
85+
@param tempEvent
86+
Pointer to an Adafruit_Sensor event.
87+
@returns True if the temperature was obtained successfully, False
88+
otherwise.
89+
*/
90+
/*******************************************************************************/
91+
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
92+
if (!_bmp5xx->performReading()) {
93+
return false;
94+
}
95+
tempEvent->temperature = _bmp5xx->temperature;
96+
return true;
97+
}
98+
99+
/*******************************************************************************/
100+
/*!
101+
@brief Reads a pressure sensor and converts
102+
the reading into the expected SI unit.
103+
@param pressureEvent
104+
Pointer to an Adafruit_Sensor event.
105+
@returns True if the sensor event was obtained successfully, False
106+
otherwise.
107+
*/
108+
/*******************************************************************************/
109+
bool getEventPressure(sensors_event_t *pressureEvent) {
110+
if (!_bmp5xx->performReading()) {
111+
return false;
112+
}
113+
pressureEvent->pressure = _bmp5xx->pressure;
114+
return true;
115+
}
116+
117+
/*******************************************************************************/
118+
/*!
119+
@brief Reads a the BMP5XX's altitude sensor into an event.
120+
@param altitudeEvent
121+
Pointer to an adafruit sensor event.
122+
@returns True if the sensor event was obtained successfully, False
123+
otherwise.
124+
*/
125+
/*******************************************************************************/
126+
bool getEventAltitude(sensors_event_t *altitudeEvent) {
127+
if (!_bmp5xx->performReading()) {
128+
return false;
129+
}
130+
altitudeEvent->altitude = _bmp5xx->readAltitude(SEALEVELPRESSURE_HPA);
131+
return true;
132+
}
133+
134+
protected:
135+
Adafruit_BMP5xx *_bmp5xx; ///< BMP5xx object
136+
};
137+
138+
#endif // WipperSnapper_I2C_Driver_BMP5XX

0 commit comments

Comments
 (0)