Qwiic Pressure Sensor (BMP581) Hookup Guide

Contributors: El Duderino
Favorited Favorite 0

SparkFun BMP581 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 BMP581 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 BMP581". 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 BMP581 Library:

  • int8_t beginI2C(uint8_t address = BMP581_I2C_ADDRESS_DEFAULT, TwoWire& wirePort = Wire); - Initialize the BMP581 at the default I2C address on the specified Wire port.
  • int8_t beginSPI(uint8_t csPin, uint32_t clockFrequency = 100000); - Initialize the BMP581 over SPI using the defined Chip Select pin and set clock frequency (default 100kHz).
  • int8_t init(); - Initialize the BMP581 sensor. The begin function handles this automatically.
  • int8_t setMode(bmp5_powermode mode); - Set the operating mode. Valid options are: . The begin function handles this automatically.
  • int8_t getMode(bmp5_powermode* mode); - Returns the value set for the operating mode.
  • int8_t enablePress(uint8_t pressEnable); - Enable pressure and temperature sensing. The begin function handles this automatically.

Sensor Data and Settings

  • int8_t getSensorData(bmp5_sensor_data* data); - Pulls pressure and temperature data from the sensor.
  • int8_t setODRFrequency(uint8_t odr); - Set the output data rate frequency.
  • int8_t getODRFrequency(uint8_t* odr); - Returns the value set for the output data rate frequency
  • int8_t setOSRMultipliers(bmp5_osr_odr_press_config* config); - Set the oversampling multiplier.
  • int8_t getOSRMultipliers(bmp5_osr_odr_press_config* config); - Returns the value stored for the oversampling multiplier.
  • int8_t getOSREffective(bmp5_osr_odr_eff* osrOdrEffective);
  • int8_t setFilterConfig(bmp5_iir_config* iirConfig); - Set the IIR filter configuration.
  • int8_t setOORConfig(bmp5_oor_press_configuration* oorConfig); - Set the OOR (Out-of-Range) configuration.
  • int8_t setInterruptConfig(BMP581_InterruptConfig* config); - 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(uint8_t* status); - 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 setFIFOConfig(bmp5_fifo* fifoConfig); - Set the FIFO buffer settings.
  • int8_t getFIFOLength(uint8_t* numData); - Set the number of samples stored in the FIFO buffer at a time.
  • int8_t getFIFOData(bmp5_sensor_data* data, uint8_t numData); - Pull the FIFO data stored on the BMP581.
  • int8_t flushFIFO(); - Flush the FIFO buffer.

NVM Control

  • int8_t readNVM(uint8_t addr, uint16_t* data); - Read data stored in the non-volatile memory.
  • int8_t writeNVM(uint8_t addr, uint16_t data); - Write data to the non-volatile memory.

Error Codes

Most of the functions in this list return specific error codes (instead of a true/false boolean) if called properly. The examples demonstrate how to set up and call error codes. For information on the error codes, refer to the BMP581 defs.h file in the BMP581 API.