Skip to content

7semi-solutions/7Semi-BMP348

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

7Semi BMP384 Library

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.


Features

  • 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

Installation

Arduino IDE

  1. Download ZIP from GitHub
  2. Go to Sketch → Include Library → Add .ZIP Library
  3. Select the ZIP file

Manual

Copy library into:

Documents/Arduino/libraries/

Wiring

I2C

BMP384 MCU
VCC 3.3V
GND GND
SDA SDA
SCL SCL

I2C Address:

  • 0x77 (default)
  • 0x76 (SDO = GND)

SPI

BMP384 MCU
VCC 3.3V
GND GND
SCK SCK
SDI MISO
SDO MOSI
CS Any GPIO

Quick Start

I2C Example

#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);
}

API Overview

Initialization

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.


Sensor Control

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.


Data Configuration

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.

Data Reading

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.


FIFO (Advanced)

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.


Interrupts

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.


Status Monitoring

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.


Utility

softReset()

Performs a software reset, restoring default sensor settings.

readChipId()

Returns the sensor chip ID (useful for device verification).


Troubleshooting

Sensor not detected

  • Check wiring
  • Verify I2C address (0x76 / 0x77)
  • Ensure correct voltage

Invalid configuration

  • Reduce ODR
  • Lower OSR

No data / FIFO empty

  • Ensure sensor is in NORMAL mode and ODR and OSR
  • Check interrupt/FIFO configuration

License

MIT License

About

Lightweight and efficient Arduino library for Bosch BMP384 sensor with I2C/SPI support, FIFO, interrupts, filtering, and altitude calculation.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors