Qwiic Pressure Sensor (BMP384) Hookup Guide

Pages
Contributors: El Duderino
Favorited Favorite 0

SparkFun BMP384 Arduino Library

Note: This library assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

The SparkFun BMP384 Arduino Library is based off the API for the sensor from Bosch. Install the library through the Arduino Library Manager tool by searching for "SparkFun BMP384". Users who prefer to manually install the library can download a copy of it from the GitHub repository by clicking the button below:

Heads Up! We recommend choosing a development board with plenty of available RAM like the RedBoard Artemis shown in the Hardware Assembly section if you want to use the FIFO buffer as it is read all at once which causes some microcontrollers like the ATMega328 on the RedBoard/Uno to run out of RAM after just a few samples. All other use cases of the Arduino Library will work with most microcontrollers.

Library Functions

The list below outlines and describes the functions available in the SparkFun BMP384 Library:

Sensor Initialization & Mode Selection

  • int8_t beginI2C(uint8_t address = BMP384_I2C_ADDRESS_DEFAULT, TwoWire& wirePort = Wire); - Initialzes the BMP384 in I2C at the specified address and on the specified Wire port.
  • int8_t beginSPI(uint8_t csPin, uint32_t clockFrequency = 100000); - Initializes the BMP384 in SPI mode at the specified frequency (default is 100000) and sets the Chip Select pin.
  • int8_t init(); - Initialize the BMP384. The begin functions automatically perform this.
  • int8_t setMode(uint8_t mode); - Manually set the operating mode of the BMP384. Set to Normal by default in the begin functions.
  • int8_t enablePressAndTemp(uint8_t pressEnable, uint8_t tempEnable); - Enable pressure and temperature measurements. Enabled by default in the begin functions.

Sensor Data

  • int8_t getSensorData(bmp3_data* data); - Returns pressure and temperature data from the sensor.
  • int8_t getSensorStatus(bmp3_sens_status* sensorStatus); - Returns the status of command ready, data ready for pressure & temperature and power on reset parameters.
  • int8_t setODRFrequency(uint8_t odr); - Set the Output Data Rate frequency.
  • int8_t getODRFrequency(uint8_t* odr); - Retrieve the value stored for the Output Data Rate frequency.
  • int8_t setOSRMultipliers(bmp3_odr_filter_settings osrMultipliers); - Set the Oversampling Rate multipliers.
  • int8_t getOSRMultipliers(bmp3_odr_filter_settings* osrMultipliers); - Retreive the value set for the Oversampling multiplier.
  • int8_t setFilterCoefficient(uint8_t coefficient); - Sets the low pass filter coeffecient.
  • int8_t setInterruptSettings(bmp3_int_ctrl_settings interruptSettings); - Set the Interrupt Settings (output mode, level, latch and data ready). Refer to Example 3 - Interrupts in the Arduino Library for a detailed demonstration of setting and using the Interrupt pin.
  • int8_t getInterruptStatus(bmp3_int_status* interruptStatus); - Returns the settings for the Interrupt.

FIFO Buffer Control

Refer to Example 6 - FIFO Buffer in the Arduino library for a detailed example of setting and using the FIFO buffer.

  • int8_t setFIFOSettings(bmp3_fifo_settings fifoSettings); - Set the FIFO buffer settings.
  • int8_t setFIFOWatermark(uint8_t numData); - Sets the number of samples for the FIFO watermark.
  • int8_t getFIFOLength(uint8_t* numData); - Returns the number of data samples in the FIFO buffer.
  • int8_t getFIFOData(bmp3_data* data, uint8_t numData); - Pull the FIFO data stored on the BMP384.
  • int8_t flushFIFO(); - Clears the FIFO buffer.