Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper
category=Communication
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
architectures=*
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
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
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ lib_deps =
adafruit/Adafruit BME280 Library
adafruit/Adafruit BMP280 Library
adafruit/Adafruit BMP3XX Library
adafruit/Adafruit BMP5XX Library
adafruit/Adafruit DPS310
adafruit/Adafruit DS248x
adafruit/Adafruit INA219
Expand Down
17 changes: 15 additions & 2 deletions src/components/i2c/WipperSnapper_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,27 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
(strcmp("bmp390", msgDeviceInitReq->i2c_device_name) == 0)) {
_bmp3xx = new WipperSnapper_I2C_Driver_BMP3XX(this->_i2c, i2cAddress);
if (!_bmp3xx->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize BMP388!");
WS_DEBUG_PRINTLN("ERROR: Failed to initialize BMP3xx!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_bmp3xx->configureDriver(msgDeviceInitReq);
drivers.push_back(_bmp3xx);
WS_DEBUG_PRINTLN("BMP388 Initialized Successfully!");
WS_DEBUG_PRINTLN("BMP3xx Initialized Successfully!");
} else if ((strcmp("bmp580", msgDeviceInitReq->i2c_device_name) == 0) ||
(strcmp("bmp581", msgDeviceInitReq->i2c_device_name) == 0) ||
(strcmp("bmp585", msgDeviceInitReq->i2c_device_name) == 0)) {
_bmp5xx = new WipperSnapper_I2C_Driver_BMP5XX(this->_i2c, i2cAddress);
if (!_bmp5xx->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize BMP5xx!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_bmp5xx->configureDriver(msgDeviceInitReq);
drivers.push_back(_bmp5xx);
WS_DEBUG_PRINTLN("BMP5xx Initialized Successfully!");
} else if ((strcmp("bme680", msgDeviceInitReq->i2c_device_name) == 0) ||
(strcmp("bme688", msgDeviceInitReq->i2c_device_name) == 0)) {
_bme680 = new WipperSnapper_I2C_Driver_BME680(this->_i2c, i2cAddress);
Expand Down
2 changes: 2 additions & 0 deletions src/components/i2c/WipperSnapper_I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "drivers/WipperSnapper_I2C_Driver_BME680.h"
#include "drivers/WipperSnapper_I2C_Driver_BMP280.h"
#include "drivers/WipperSnapper_I2C_Driver_BMP3XX.h"
#include "drivers/WipperSnapper_I2C_Driver_BMP5XX.h"
#include "drivers/WipperSnapper_I2C_Driver_D6T1A.h"
#include "drivers/WipperSnapper_I2C_Driver_DPS310.h"
#include "drivers/WipperSnapper_I2C_Driver_DS2484.h"
Expand Down Expand Up @@ -169,6 +170,7 @@ class WipperSnapper_Component_I2C {
WipperSnapper_I2C_Driver_BME280 *_bme280 = nullptr;
WipperSnapper_I2C_Driver_BMP280 *_bmp280 = nullptr;
WipperSnapper_I2C_Driver_BMP3XX *_bmp3xx = nullptr;
WipperSnapper_I2C_Driver_BMP5XX *_bmp5xx = nullptr;
WipperSnapper_I2C_Driver_BME680 *_bme680 = nullptr;
WipperSnapper_I2C_Driver_HDC302X *_hdc302x = nullptr;
WipperSnapper_I2C_Driver_HTS221 *_hts221 = nullptr;
Expand Down
138 changes: 138 additions & 0 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_BMP5XX.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/*!
* @file WipperSnapper_I2C_Driver_BMP5XX.h
*
* Device driver for a BMP5XX precision pressure sensor breakout.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) Tyeth Gundry 2025 for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/

#ifndef WipperSnapper_I2C_Driver_BMP5XX_H
#define WipperSnapper_I2C_Driver_BMP5XX_H

#include <Adafruit_BMP5xx.h>

#include "WipperSnapper_I2C_Driver.h"

#define SEALEVELPRESSURE_HPA (1013.25) ///< Default sea level pressure, in hPa

/**************************************************************************/
/*!
@brief Class that provides a sensor driver for the BMP5XX temperature
and pressure sensor.
*/
/**************************************************************************/
class WipperSnapper_I2C_Driver_BMP5XX : public WipperSnapper_I2C_Driver {
public:
/*******************************************************************************/
/*!
@brief Constructor for an BMP5XX sensor.
@param i2c
The I2C interface.
@param sensorAddress
7-bit device address.
*/
/*******************************************************************************/
WipperSnapper_I2C_Driver_BMP5XX(TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
_bmp5xx = nullptr;
}

/*******************************************************************************/
/*!
@brief Destructor for an BMP5XX sensor.
*/
/*******************************************************************************/
~WipperSnapper_I2C_Driver_BMP5XX() {
if (_bmp5xx) {
delete _bmp5xx;
_bmp5xx = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastic defensive programming 👍

}
}

/*******************************************************************************/
/*!
@brief Initializes the BMP5XX sensor and begins I2C.
@returns True if initialized successfully, False otherwise.
*/
/*******************************************************************************/
bool begin() {
_bmp5xx = new Adafruit_BMP5xx();
if (!_bmp5xx->begin(_sensorAddress, _i2c)) {
delete _bmp5xx;
_bmp5xx = nullptr;
return false;
}

// Set up oversampling and filter initialization
return _bmp5xx->setTemperatureOversampling(BMP5XX_OVERSAMPLING_8X) &&
_bmp5xx->setPressureOversampling(BMP5XX_OVERSAMPLING_16X) &&
_bmp5xx->setIIRFilterCoeff(BMP5XX_IIR_FILTER_COEFF_3) &&
_bmp5xx->setOutputDataRate(BMP5XX_ODR_50_HZ) &&
_bmp5xx->setPowerMode(BMP5XX_POWERMODE_NORMAL) &&
_bmp5xx->enablePressure(true);
}

/*******************************************************************************/
/*!
@brief Gets the BMP5XX's current temperature.
@param tempEvent
Pointer to an Adafruit_Sensor event.
@returns True if the temperature was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
if (!_bmp5xx->performReading()) {
return false;
}
tempEvent->temperature = _bmp5xx->temperature;
return true;
}

/*******************************************************************************/
/*!
@brief Reads a pressure sensor and converts
the reading into the expected SI unit.
@param pressureEvent
Pointer to an Adafruit_Sensor event.
@returns True if the sensor event was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventPressure(sensors_event_t *pressureEvent) {
if (!_bmp5xx->performReading()) {
return false;
}
pressureEvent->pressure = _bmp5xx->pressure;
return true;
}

/*******************************************************************************/
/*!
@brief Reads a the BMP5XX's altitude sensor into an event.
@param altitudeEvent
Pointer to an adafruit sensor event.
@returns True if the sensor event was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventAltitude(sensors_event_t *altitudeEvent) {
if (!_bmp5xx->performReading()) {
return false;
}
altitudeEvent->altitude = _bmp5xx->readAltitude(SEALEVELPRESSURE_HPA);
return true;
}

protected:
Adafruit_BMP5xx *_bmp5xx; ///< BMP5xx object
};

#endif // WipperSnapper_I2C_Driver_BMP5XX
Loading