Lightweight, high-performance Arduino library for the Bosch BMP384 pressure & temperature sensor.
Built for embedded efficiency, clean API design, and advanced control including FIFO, interrupts, and configuration.
- I2C & SPI interface support
- High-speed SPI (up to 10 MHz)
- Temperature & Pressure measurement
- Altitude calculation
- FIFO support (batch data read)
- Interrupt support:
- Data Ready (DRDY)
- FIFO Full
- FIFO Watermark
- Full configuration control:
- ODR (Output Data Rate)
- OSR (Oversampling)
- IIR Filter
- Power Modes
- Sensor status & error monitoring
- Clean and minimal API
- Download ZIP from GitHub
- Go to Sketch → Include Library → Add .ZIP Library
- Select the ZIP file
Copy library into:
Documents/Arduino/libraries/
| BMP384 | MCU |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | SDA |
| SCL | SCL |
I2C Address:
0x77(default)0x76(SDO = GND)
| BMP384 | MCU |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SCK | SCK |
| SDI | MISO |
| SDO | MOSI |
| CS | Any GPIO |
#include <7Semi_BMP384.h>
BMP384_7Semi bmp;
void setup()
{
Serial.begin(115200);
if (!bmp.beginI2C(0x77, Wire, 400000))
{
Serial.println("Init failed");
while (1);
}
}
void loop()
{
float t, p;
if (bmp.readData(t, p))
{
Serial.print("Temp: ");
Serial.print(t);
Serial.print(" °C Pressure: ");
Serial.println(p);
}
delay(500);
}beginI2C(address, wire, speed, sda = 255, scl = 255)Initializes the sensor over I2C. Supports custom SDA/SCL pins (ESP32) and verifies device communication.
beginSPI(cs, spi, speed, sck = 255, miso = 255, mosi = 255)Initializes the sensor over SPI with optional custom pins. Uses SPI transactions for stable high-speed communication.
setOperationMode(mode)Sets the power mode of the sensor (sleep, forced, normal). Required before taking measurements.
getPowerMode(mode)Reads the current operating mode of the sensor.
enableSensor(temp, press)Enables or disables temperature and pressure measurements independently.
setODR(odr)Sets the Output Data Rate (how frequently new data is generated).
getODR(odr)Read the currently configured Output Data Rate.
setOSR(tempOSR, pressOSR)Sets oversampling for temperature and pressure to control accuracy vs speed.
getOSR(tempOSR, pressOSR)Reads current oversampling settings.
setIIR(coeff)Configures the IIR filter to smooth sensor data and reduce noise.
getIIR(coeff)Returns the current IIR filter coefficient.
Note:Not all ODR values are valid with every OSR configuration.
If ODR is too high for the selected oversampling, the sensor may reject the setting or produce no data.
Always balance ODR and OSR to ensure stable operation.
readData(temp, pressure)Reads the latest temperature (°C) and pressure (Pa) values from the sensor.
getAltitude(altitude, seaLevelPressure)Calculates altitude (meters) using pressure and a provided sea-level reference.
enableFIFO(temp, press, timestamp)Enables FIFO buffer and selects which data (temperature, pressure, timestamp) to store.
setFIFOConfig(mode, stopOnFull, subsampling, filter)Configures FIFO behavior including mode, subsampling, and filtering options.
getFIFOConfig(mode, stopOnFull, subsampling, filter)Reads current FIFO configuration settings.
setFIFOWatermark(frames)Sets the FIFO watermark level to trigger interrupts when a certain number of frames is reached.
readFIFO(data, frames)Reads and parses FIFO data into usable sensor frames.
flushFIFO()Clears all data from the FIFO buffer.
setInterruptConfig(openDrain, activeHigh, latching)Configures interrupt pin behavior (output type, polarity, and latching).
getInterruptConfig(openDrain, activeHigh, latching)Reads current interrupt pin configuration.
enableInterrupt(drdy, fifoFull, fifoWatermark)Enables interrupt sources like data-ready and FIFO events.
readInterruptStatus(drdy, fifoFull, fifoWatermark)Reads interrupt flags indicating triggered events.
readSensorStatus(tempReady, pressReady, cmdReady)Checks if new temperature/pressure data is ready and if commands are processed.
readErrorStatus(confErr, cmdErr, fatalErr)Reads sensor error flags including configuration, command, and fatal errors.
getStatus()Returns the last status code from the Bosch driver.
softReset()Performs a software reset, restoring default sensor settings.
readChipId()Returns the sensor chip ID (useful for device verification).
- Check wiring
- Verify I2C address (
0x76/0x77) - Ensure correct voltage
- Reduce ODR
- Lower OSR
- Ensure sensor is in NORMAL mode and ODR and OSR
- Check interrupt/FIFO configuration
MIT License