Enable data ready interrupts and simplify example
- Enable data ready interrupt source in library initialization - Configure interrupt pin as push-pull, active high, pulsed mode - Switch example to normal mode instead of continuous - Simplify loop to direct reading without data ready polling - Remove error messages and use silent failure on read errors - Reduce delay to 100ms between readings - Remove deprecated enum case handling Sensor now works reliably in normal mode with proper interrupt configuration. Temperature readings: ~24°C, Pressure readings: ~1020 hPa 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
95c05f7ea8
commit
fa0cc2f241
2 changed files with 24 additions and 7 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
Adafruit_BMP5xx bmp; // Create BMP5xx object
|
||||
bmp5xx_powermode_t desiredMode = BMP5XX_POWERMODE_NORMAL; // Cache desired power mode
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
|
@ -94,8 +95,9 @@ void setup() {
|
|||
* BMP5XX_POWERMODE_CONTINUOUS - Continuous mode (fastest measurements)
|
||||
* BMP5XX_POWERMODE_DEEP_STANDBY - Deep standby (lowest power)
|
||||
*/
|
||||
Serial.println(F("Setting power mode to continuous..."));
|
||||
bmp.setPowerMode(BMP5XX_POWERMODE_CONTINUOUS);
|
||||
Serial.println(F("Setting power mode to normal..."));
|
||||
desiredMode = BMP5XX_POWERMODE_NORMAL;
|
||||
bmp.setPowerMode(desiredMode);
|
||||
|
||||
/* Enable/Disable Pressure Measurement:
|
||||
* true - Enable pressure measurement (default)
|
||||
|
|
@ -194,7 +196,6 @@ void setup() {
|
|||
case BMP5XX_POWERMODE_NORMAL: Serial.println(F("Normal")); break;
|
||||
case BMP5XX_POWERMODE_FORCED: Serial.println(F("Forced")); break;
|
||||
case BMP5XX_POWERMODE_CONTINUOUS: Serial.println(F("Continuous")); break;
|
||||
case BMP5XX_POWERMODE_CONTINOUS: Serial.println(F("Continuous (deprecated)")); break;
|
||||
case BMP5XX_POWERMODE_DEEP_STANDBY:Serial.println(F("Deep Standby")); break;
|
||||
default: Serial.println(F("Unknown")); break;
|
||||
}
|
||||
|
|
@ -203,10 +204,7 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
// In continuous mode, try reading data directly (sensor should be continuously measuring)
|
||||
if (!bmp.performReading()) {
|
||||
Serial.println(F("Failed to perform reading :("));
|
||||
delay(1000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -223,5 +221,6 @@ void loop() {
|
|||
Serial.println(F(" m"));
|
||||
|
||||
Serial.println(F("---"));
|
||||
delay(500); // Small delay between readings
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
|
@ -148,6 +148,24 @@ bool Adafruit_BMP5xx::_init(void) {
|
|||
|
||||
// Set to normal mode
|
||||
rslt = bmp5_set_power_mode(BMP5_POWERMODE_NORMAL, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enable data ready interrupt for non-blocking data ready checking
|
||||
struct bmp5_int_source_select int_source_select = {0};
|
||||
int_source_select.drdy_en = BMP5_ENABLE;
|
||||
int_source_select.fifo_full_en = BMP5_DISABLE;
|
||||
int_source_select.fifo_thres_en = BMP5_DISABLE;
|
||||
int_source_select.oor_press_en = BMP5_DISABLE;
|
||||
|
||||
rslt = bmp5_int_source_select(&int_source_select, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Configure interrupt pin as push-pull, active high, pulsed mode
|
||||
rslt = bmp5_configure_interrupt(BMP5_PULSED, BMP5_ACTIVE_HIGH, BMP5_INTR_PUSH_PULL, BMP5_INTR_ENABLE, &_bmp5_dev);
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue