Introduction

This is a high-precision barometric pressure and temperature sensor designed around the Bosch BMP581, a new-generation high-performance digital barometric pressure sensor. It can simultaneously and directly output atmospheric pressure, temperature, and calculated altitude data. Compared to its predecessors, its core advantages include higher absolute accuracy (±0.3 hPa), lower operating power consumption (approx. 700μA), lower noise (< 0.1 Pa), and superior long-term stability.

It incorporates advanced digital temperature and linearity compensation algorithms, along with an integrated FIFO buffer and a configurable IIR filter. Through hardware-level data buffering and real-time filtering, it significantly suppresses data jitter caused by environmental disturbances, thereby delivering more reliable and stable measurement output in dynamic application scenarios.

The product supports I2C and UART communication for flexible integration and comes with open-source Arduino and Python libraries, greatly simplifying the testing and validation workflow. Thanks to its high accuracy, wide measurement range, low power consumption, and reliable stability, this sensor is exceptionally well-suited for various demanding projects such as drone altitude hold, outdoor navigation, indoor/outdoor positioning fusion, meteorological monitoring, and GPS navigation enhancement.

Features

  • Wide Voltage Compatibility: Supports 3.3V and 5V logic levels.
  • Multi-Protocol Interface: Supports I2C and UART communication for flexible adaptation.
  • Multi-Parameter Synchronous Output: Directly measures barometric pressure, temperature, and calculates altitude.
  • High-Precision Measurement: Absolute accuracy of ±0.3 hPa ensures reliable data.
  • Low Operating Power Consumption: Operating current of approximately 700μA for extended runtime.
  • Low-Noise Output: Noise below 0.1 Pa RMS ensures stable output.
  • Programmable Interrupt: Supports threshold alarms, facilitating event-driven design.
  • User Configuration Storage: Built-in 6 Bytes of non-volatile memory for saving custom configurations.
  • Hardware FIFO Buffer: Reduces host polling frequency, saving system power.
  • Integrated Programmable Filter: Configurable low-pass filter effectively suppresses high-frequency noise.

Applications

  • Outdoor Environmental Monitoring
  • Drone Altitude Hold & Obstacle Avoidance
  • Mountain Climbing Altitude Measurement
  • Indoor Floor Height Detection
  • Outdoor Navigation
  • Outdoor Weather Station

Specifications

Basic Parameters

  • Operating Voltage: DC 3.3~5V
  • Operating Current: 700μA
  • Communication Interface: I2C / UART
  • Interface Form: PH2.0-4P (Gravity Pinout) / 2.54mm Pin Header Socket
  • I2C Address: 0x47 (Default) / 0x46

BMP581 Parameters

  • Pressure Measurement Range: 30 ~ 125 kPa
  • Temperature Measurement Range: 0 ~ 65 °C
  • Absolute Pressure Accuracy: ±0.3 hPa (Typ.)
  • Relative Pressure Accuracy: ±0.06 hPa / 10 kPa (Typ.)
  • Relative Altitude Accuracy: ±0.5 m / 10 kPa
  • Temperature Drift Coefficient: ±0.5 Pa / K
  • Pressure Data Resolution: 1 / 64
  • Ultra-Low Noise: < 0.1 Pa (RMS, without low-pass filter enabled)

Physical Dimensions

  • PCB Dimensions: 32 × 27 × 7.18 mm
  • Mounting Hole Spacing: 25×20 mm
  • Mounting Hole Diameter: 3.0 mm

Dimensions

Unit: mm

Functional Diagram

Interface Pin Description

Pin Silkscreen Function Description
D/T Multiplexed Pin: Data Line (SDA) in I2C mode, Transmit Terminal (TXD) in UART mode
C/R Multiplexed Pin: Clock Line (SCL) in I2C mode, Receive Terminal (RXD) in UART mode
GND Power Negative (Ground)
VCC Power Positive (Supply Input: 3.3 ~ 5V)
INT Interrupt Output Pin (General-Purpose)

Notes:

  • The setting of the "I2C/UART Switch" persists after power-off, and the new mode takes effect after device restart.

Tutorial for Using Arduino IDE

  • Hardware Preparation
  • Software Preparation
    • Download and install Arduino IDE: [Download Link]
    • Download dependent libraries:
    • Library Installation Guide: [View Installation Tutorial](https://wiki.dfrobot.com/Arduino libraries installed)

Example 1: Continuous Reading of Pressure, Temperature, and Altitude Data via I2C

Objective

Establish communication between the ESP32-E and the Gravity: BMP581 Barometric Pressure Sensor through the I2C interface to continuously acquire pressure, temperature, and altitude data.

Step 1: Wiring Configuration

  • Connect the Gravity: BMP581 Barometric Pressure Sensor to the ESP32-E as illustrated, with the key wiring correspondences as follows:
    • Sensor Pin "VCC" → ESP32-E 3.3V
    • Sensor Pin "GND" → ESP32-E GND
    • Sensor I2C Pin "SCL" → ESP32-E SCL (default GPIO22)
    • Sensor I2C Pin "SDA" → ESP32-E SDA (default GPIO21)
    • Sensor DIP Switch Configuration: Set the communication mode to I2C and the I2C address to 0x47

Note: The setting of the communication mode DIP switch persists after power-off, and the new mode takes effect upon device restart.

Step 2: Code Upload

Launch the Arduino IDE, copy the following code, and upload it to the ESP32-E:

#include "DFRobot_BMP58X.h"
#define BMP5_COMM_I2C
#define CALIBRATE_ABSOLUTE_DIFFERENCE

const uint8_t ADDR = 0x47;
DFRobot_BMP58X_I2C bmp58x(&Wire, ADDR);

void setup() {
  Serial.begin(115200);
  
  while(!bmp58x.begin()){
    Serial.println("Sensor initialization failed!");
    delay(1000);
  }
  Serial.println("Sensor initialization succeeded!");

// Calibrate absolute error (modify parameters according to actual altitude)
  #if defined(CALIBRATE_ABSOLUTE_DIFFERENCE)
/* This example uses an elevation of 540 meters in Wenjiang District, Chengdu. Replace it with the local elevation when in use.*/
    bmp58x.calibratedAbsoluteDifference(540.0);
  #endif

  // Set the measurement mode to normal mode
  bmp58x.setMeasureMode(bmp58x.eNormal);
}

void loop() {
  delay(1000);

  Serial.print("Temperature: ");
  Serial.print(bmp58x.readTempC());
  Serial.println(" °C");
  
  Serial.print("Atmospheric Pressure: ");
  Serial.print(bmp58x.readPressPa());
  Serial.println(" Pa");
  
  Serial.print("Altitude: ");
  Serial.print(bmp58x.readAltitudeM());
  Serial.println(" m");
  Serial.println("=================================");
}

Result

Example 2: Continuous Reading of Pressure, Temperature, and Altitude Data via UART

Objective

Establish communication between the ESP32-E and the Gravity: BMP581 Barometric Pressure Sensor through the UART interface to continuously acquire pressure, temperature, and altitude data.

Step 1: Wiring Configuration

  • Connect the Gravity: BMP581 Barometric Pressure Sensor to the ESP32-E as illustrated, with the key wiring correspondences as follows:
    • Sensor Pin "VCC" → ESP32-E 3.3V
    • Sensor Pin "GND" → ESP32-E GND
    • Sensor UART Pin "RX" → ESP32-E D3
    • Sensor UART Pin "TX" → ESP32-E D2
    • Sensor DIP Switch Configuration: Set the communication mode to UART and the address to 0x47

Note: The setting of the communication mode DIP switch persists after power-off, and the new mode takes effect upon device restart.

Step 2: Code Upload

Launch the Arduino IDE, copy the following code, and upload it to the ESP32-E:

#include "DFRobot_BMP58X.h"
#include "DFRobot_RTU.h"
#define BMP5_COMM_UART
#define CALIBRATE_ABSOLUTE_DIFFERENCE
const uint8_t ADDR = 0x47;

#if defined(BMP5_COMM_UART)
  DFRobot_BMP58X_UART bmp58x(&Serial1, 9600, ADDR, /*rx*/ D2, /*tx*/ D3);
#else
  #error "Only UART communication is supported in this configuration"
#endif

void setup() {
  Serial.begin(115200);
  while(!bmp58x.begin()){
    Serial.println("Sensor initialization failed!");
    delay(1000);
  }
// Calibrate absolute error (modify parameters according to actual altitude)
  #if defined(CALIBRATE_ABSOLUTE_DIFFERENCE)
/* This example uses an elevation of 540 meters in Wenjiang District, Chengdu. Replace it with the local elevation when in use.*/
    bmp58x.calibratedAbsoluteDifference(540.0);
  #endif

  bmp58x.setMeasureMode(bmp58x.eNormal);
}

void loop() {
  delay(1000);
  Serial.print("temp: ");
  Serial.print(bmp58x.readTempC());
  Serial.print(" (C)  press: ");
  Serial.print(bmp58x.readPressPa());
  Serial.print(" (Pa)  alt: ");
  Serial.print(bmp58x.readAltitudeM());
  Serial.println(" (M)");
}

Result

Example 3: FIFO Data Reading and Interrupt Triggering

Introduction to FIFO

FIFO (First In, First Out) is an integrated data buffering mechanism within the sensor. Its core feature is that data is temporarily stored here and retrieved in batches when needed, ensuring the temporal consistency of data.

In barometric pressure sensors, FIFO serves as a temporary data storage unit, responsible for data buffering and batch processing: Temperature and pressure data collected by the sensor at a set frequency are first written to the FIFO in an orderly manner instead of being transmitted to the external host in real time; when data acquisition is required, the host can read all cached data in the FIFO with a single operation, enabling batch retrieval.

Compared with systems without a buffering mechanism, FIFO offers distinct advantages:

  • Eliminates bus resource occupancy caused by high-frequency real-time communication, reducing system interaction overhead
  • Prevents transient data loss due to host processing delays, safeguarding data integrity
  • Supports on-demand batch reading, adapting to data analysis rhythms in various scenarios

In essence, FIFO acts as a data coordination unit between the sensor and the host, optimizing the efficiency and reliability of data interaction through orderly buffering and batch transmission.

Objective

Continuously read pressure and temperature data using the FIFO buffer.

Step 1: Wiring Configuration

  • Connect the Gravity: BMP581 Barometric Pressure Sensor to the ESP32-E as illustrated, with the key wiring correspondences as follows:
    • Sensor Pin "VCC" → ESP32-E 3.3V
    • Sensor Pin "GND" → ESP32-E GND
    • Sensor I2C Pin "SCL" → ESP32-E SCL (default GPIO22)
    • Sensor I2C Pin "SDA" → ESP32-E SDA (default GPIO21)
    • Sensor Pin "INT" → ESP32-E D6 (GPIO14)
    • Sensor DIP Switch Configuration: Set the communication mode to I2C and the I2C address to 0x47

Note: The setting of the communication mode DIP switch persists after power-off, and the new mode takes effect upon device restart.

Step 2: Code Upload

Launch the Arduino IDE, copy the following code, and upload it to the ESP32-E:

#include "DFRobot_BMP58X.h"
#include "DFRobot_RTU.h"

#define BMP5_COMM_I2C

/* Uncomment this line if eliminating absolute measurement error is not required */
#define CALIBRATE_ABSOLUTE_DIFFERENCE

/**
 * Configure interrupt mode: Uncomment the macro below to use latched interrupt;
 * otherwise, pulsed interrupt will be used
 */
// #define BMP5_INT_MODE_LATCHED

const uint8_t ADDR = 0x47;

DFRobot_BMP58X_I2C bmp58x(&Wire, ADDR);

volatile uint8_t flag = 0;
/* Interrupt Service Routine: Set flag when triggered */
void interrupt() {
  if (flag == 0) {
    flag = 1;
  }
}

void setup() {
  Serial.begin(115200);
  Serial.println("Initializing..");
  
  while (!bmp58x.begin()) {
    Serial.println("Sensor initialization failed!");
    delay(1000);
  }

  /**
   * Configure FIFO parameters:
   * - Data Type: Pressure + Temperature
   * - Downsampling: None
   * - Mode: Overwrite old data when full
   * - Threshold: 2 frames (triggers interrupt when reached)
   */
  bmp58x.configFIFO(
    bmp58x.eFIFOPressAndTempData,  // Store pressure and temperature data
    bmp58x.eNoDownSampling,        // No downsampling
    bmp58x.eFIFOOverwriteMode,     // Overwrite mode
    0x02                           // Threshold set to 2 frames
  );

  /**
   * Configure interrupt parameters:
   * - Trigger Mode: Pulsed/Latched (depends on macro definition)
   * - Polarity: Active high
   * - Output Type: Push-pull
   */
#if defined(BMP5_INT_MODE_LATCHED)
  bmp58x.configInterrupt(bmp58x.eIntModeLatched, bmp58x.eIntHighActive, bmp58x.eIntPushPull);
#else
  bmp58x.configInterrupt(bmp58x.eIntModePulsed, bmp58x.eIntHighActive, bmp58x.eIntPushPull);
#endif

  /* Set interrupt source: Trigger when FIFO reaches threshold */
  bmp58x.setIntSource(bmp58x.eIntFIFOThres);

  #if defined(CALIBRATE_ABSOLUTE_DIFFERENCE)
  /**
   * Calibrate absolute difference with 540 meters as the reference altitude
   * (Modify to local altitude in practical use)
   */
  bmp58x.calibratedAbsoluteDifference(540.0);
  #endif

  /* Set measurement mode: Normal mode (continuous measurement) */
  bmp58x.setMeasureMode(bmp58x.eNormal);

  /* Attach interrupt to ESP32's D6 pin (rising edge trigger) */
  attachInterrupt(digitalPinToInterrupt(D6), interrupt, RISING);
}

void loop() {
  /* Latched interrupt requires reading status register to clear flag */
#if defined(BMP5_INT_MODE_LATCHED)
  bmp58x.getIntStatus();
#endif

  /* When interrupt flag is detected, read FIFO data and print */
  if (flag == 1) {
    DFRobot_BMP58X::sFIFOData_t data = bmp58x.getFIFOData();
    Serial.print("FIFO len: ");
    Serial.println(data.len);
    
    /* Loop through and print all data in FIFO */
    for(int i = 0; i < data.len; ++i){
      Serial.print("temp: ");
      Serial.print(data.fifoTempC[i]);
      Serial.print(" (°C)  pressure: ");
      Serial.print(data.fifoPressPa[i]);
      Serial.println(" (Pa)");
    }
    
    flag = 0;  // Clear flag to wait for next interrupt
  }
}

Result

API Functions

/**
 * @fn begin
 * @brief Initializes the sensor hardware interface
 * @return true if initialization succeeds, false on failure
 */
bool begin(void);

/**
 * @fn setODR
 * @brief Configures sensor output data rate (ODR)
 * @param odr Output data rate selection (see: eOdr_t)
 * @n Available rates:
 * @n - eOdr240Hz:    Indicates an output rate of 240 Hz
 * @n - eOdr218_5Hz:  Indicates an output rate of 218.5 Hz
 * @n - eOdr199_1Hz:  Indicates an output rate of 199.1 Hz
 * @n - eOdr179_2Hz:  Indicates an output rate of 179.2 Hz
 * @n - eOdr160Hz:    Indicates an output rate of 160 Hz
 * @n - eOdr149_3Hz:  Indicates an output rate of 149.3 Hz
 * @n - eOdr140Hz:    Indicates an output rate of 140 Hz
 * @n - eOdr129_8Hz:  Indicates an output rate of 129.8 Hz
 * @n - eOdr120Hz:    Indicates an output rate of 120 Hz
 * @n - eOdr110_1Hz:  Indicates an output rate of 110.1 Hz
 * @n - eOdr100_2Hz:  Indicates an output rate of 100.2 Hz
 * @n - eOdr89_6Hz:   Indicates an output rate of 89.6 Hz
 * @n - eOdr80Hz:     Indicates an output rate of 80 Hz
 * @n - eOdr70Hz:     Indicates an output rate of 70 Hz
 * @n - eOdr60Hz:     Indicates an output rate of 60 Hz
 * @n - eOdr50Hz:     Indicates an output rate of 50 Hz
 * @n - eOdr45Hz:     Indicates an output rate of 45 Hz
 * @n - eOdr40Hz:     Indicates an output rate of 40 Hz
 * @n - eOdr35Hz:     Indicates an output rate of 35 Hz
 * @n - eOdr30Hz:     Indicates an output rate of 30 Hz
 * @n - eOdr25Hz:     Indicates an output rate of 25 Hz
 * @n - eOdr20Hz:     Indicates an output rate of 20 Hz
 * @n - eOdr15Hz:     Indicates an output rate of 15 Hz
 * @n - eOdr10Hz:     Indicates an output rate of 10 Hz
 * @n - eOdr5Hz:      Indicates an output rate of 5 Hz
 * @n - eOdr4Hz:      Indicates an output rate of 4 Hz
 * @n - eOdr3Hz:      Indicates an output rate of 3 Hz
 * @n - eOdr2Hz:      Indicates an output rate of 2 Hz
 * @n - eOdr1Hz:      Indicates an output rate of 1 Hz
 * @n - eOdr0_5Hz:    Indicates an output rate of 0.5 Hz
 * @n - eOdr0_250Hz:  Indicates an output rate of 0.250 Hz
 * @n - eOdr0_125Hz:  Indicates an output rate of 0.125 Hz
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t setODR(eODR_t odr);

/**
 * @fn setOSR
 * @brief Sets oversampling ratios for temperature and pressure
 * @param osrTemp Temperature oversampling (see: eOverSampling_t)
 * @param osrPress Pressure oversampling (see: eOverSampling_t)
 * @n Supported values:
 * @n - eOverSampling1:   1x oversampling
 * @n - eOverSampling2:   2x oversampling
 * @n - eOverSampling4:   4x oversampling
 * @n - eOverSampling8:   8x oversampling
 * @n - eOverSampling16:  16x oversampling
 * @n - eOverSampling32:  32x oversampling
 * @n - eOverSampling64:  64x oversampling
 * @n - eOverSampling128: 128x oversampling
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t setOSR(eOverSampling_t osrTemp, eOverSampling_t osrPress);

/**
 * @fn setMeasureMode
 * @brief Configures sensor power/measurement mode
 * @param mode Operation mode (see: eMeasureMode_t)
 * @n Available modes:
 * @n - eSleep:         Sleep mode
 * @n - eNormal:        Normal measurement mode
 * @n - eSingleShot:    Single-shot measurement
 * @n - eContinuous:    Continuous measurement
 * @n - eDeepSleep:     Deep Sleep mode
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t setMeasureMode(eMeasureMode_t mode);

/**
 * @fn reset
 * @brief Performs software reset of the sensor
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t reset(void);

/**
 * @fn readTempC
 * @brief Reads calibrated temperature data
 * @return float Temperature in degrees Celsius
 */
float readTempC(void);

/**
 * @fn readPressPa
 * @brief Reads calibrated pressure data
 * @return float Pressure in Pascals (Pa)
 */
float readPressPa(void);

/**
 * @fn readAltitudeM
 * @brief Calculates altitude based on pressure reading
 * @note Uses formula:
 * @n altitude = (1 - (P/101325)^0.190284) * 44307.7
 * @n where P = current pressure in Pa
 * @return float Altitude in meters
 */
float readAltitudeM(void);

/**
 * @fn configIIR
 * @brief Configures IIR filter coefficients
 * @param iirTemp  Temperature IIR filter (see: eIIRFilter_t)
 * @param iirPress Pressure IIR filter (see: eIIRFilter_t)
 * @n Available coefficients:
 * @n - eFilterBypass:   Bypass filter
 * @n - eFilter1:        1st order filter
 * @n - eFilter3:        3rd order filter
 * @n - eFilter7:        7th order filter
 * @n - eFilter15:       15th order filter
 * @n - eFilter31:       31st order filter
 * @n - eFilter63:       63rd order filter
 * @n - eFilter127:      127th order filter
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t configIIR(eIIRFilter_t iirTemp, eIIRFilter_t iirPress);

/**
 * @fn configFIFO
 * @brief Configures FIFO operation parameters
 * @param dataSel Data frame type (see: eFIFODataSel_t)
 * @n Available types:
 * @n - eFIFODisable:           FIFO disabled
 * @n - eFIFOTempData:          Temperature data only
 * @n - eFIFOPressData:         Pressure data only
 * @n - eFIFOPressAndTempData:  Pressure and temperature data
 *
 * @param downSampling Downsampling ratio (see: eFIFODownSampling_t)
 * @n Available ratios:
 * @n - eNoDownSampling:    No downsampling
 * @n - eDownSampling2:     2x downsampling
 * @n - eDownSampling4:     4x downsampling
 * @n - eDownSampling8:     8x downsampling
 * @n - eDownSampling16:    16x downsampling
 * @n - eDownSampling32:    32x downsampling
 * @n - eDownSampling64:    64x downsampling
 * @n - eDownSampling128:   128x downsampling
 *
 * @param mode FIFO operation mode (see: eFIFOWorkMode_t)
 * @n Available modes:
 * @n - eFIFOOverwriteMode:  Stream data continuously
 * @n - eFIFOFullStopMode:   Stop when FIFO full
 *
 * @param threshold FIFO trigger threshold (0=disable, 1-31=frames)]
 * @n - 0x0F: 15 frames. This is the maximum setting in PT-mode. The most
 * significant bit is ignored.
 * @n - 0x1F: 31 frames. This is the maximum setting in P- or T-mode.
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t configFIFO(eFIFODataSel_t dataSel, eFIFODownSampling_t downSampling, eFIFOWorkMode_t mode, uint8_t threshold);

/**
 * @fn getFIFOCount
 * @brief Gets current number of frames in FIFO
 * @return uint8_t Number of stored data frames (0-31)
 */
uint8_t getFIFOCount(void);

/**
 * @fn getFIFOData
 * @brief Reads all data from FIFO
 * @return sFIFOData_t Struct containing pressure and temperature data
 * @n - len: Number of stored data frames (0-31)
 * @n - pressure: Array of pressure values
 * @n - temperature: Array of temperature values
 */
sFIFOData_t getFIFOData(void);

/**
 * @fn configInterrupt
 * @brief Configures interrupt behavior
 * @param intMode Trigger mode (see: eIntMode_t)
 * @n Available modes:
 * @n - eIntModePulsed: Pulsed mode
 * @n - eIntModeLatched: Latched mode
 *
 * @param intPol Signal polarity (see: eIntPolarity_t)
 * @n Available polarities:
 * @n - eIntLowActive:  Active low
 * @n - eIntHighActive: Active high
 *
 * @param intOd Output driver type (see: eIntOutputMode_t)
 * @n Available types:
 * @n - eIntPushPull: Push-pull output
 * @n - eIntOpenDrain: Open-drain output
 *
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t configInterrupt(eIntMode_t mode, eIntPolarity_t pol, eIntOutputMode_t outputMode);

/**
 * @fn setIntSource
 * @brief Enables specific interrupt sources
 * @param source Bitmask of triggers (see: eIntSource_t)
 * @n Available sources:
 * @n - eIntDataReady:    Data ready interrupt
 * @n - eIntFIFOFull:    FIFO full interrupt
 * @n - eIntFIFOThres:   FIFO threshold interrupt
 * @n - eIntPressureOor: Pressure out-of-range interrupt
 * @details You can combine multiple interrupt sources using bitwise OR (|).
 *          Example: Enable both data ready and FIFO full interrupts:
 *          @code
 *          setIntSource(bmp58x.eIntDataReady | bmp58x.eIntFIFOFull);
 *          @endcode
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t setIntSource(uint8_t source);

/**
 * @fn getIntStatus
 * @brief Reads current interrupt status flags
 * @return uint16_t Bitmask of active interrupts
 * @n Possible flags:
 * @n - eIntStatusDataReady: Data ready (0x01)
 * @n - eIntStatusFIFOFull: FIFO full  (0x02)
 * @n - eIntStatusFIFOThres: FIFO threshold reached (0x04)
 * @n - eIntStatusPressureOor: Pressure out-of-range (0x08)
 * @n - eIntStatusResetComplete: Reset complete (0x10)
 */
uint16_t getIntStatus(void);

/**
 * @fn setOORPress
 * @brief Configures pressure out-of-range detection
 * @param oor Threshold pressure value (0x00000-0x1FFFF)
 * @param range Hysteresis range (0-255)
 * @n oor - range < Pressure < oor + range
 * @param cntLimit Trigger persistence count
 * @n Available persistence settings:
 * @n - eOORCountLimit1:  1 count
 * @n - eOORCountLimit3:  3 counts
 * @n - eOORCountLimit7:  7 counts
 * @n - eOORCountLimit15: 15 counts
 * @return uint8_t 0 on success, 1 on error
 */
uint8_t setOORPress(uint32_t oor, uint8_t range, eOORCountLimit_t cntLimit);

/**
 * @fn calibratedAbsoluteDifference
 * @brief use the given current altitude as a reference value, eliminate the absolute difference of subsequent
 * pressure and altitude data
 * @param altitude current altitude
 * @return boolean, indicates whether the reference value is set successfully
 * @retval True indicates the reference value is set successfully
 * @retval False indicates fail to set the reference value
 */
bool calibratedAbsoluteDifference(float altitude);

Register Definitions

Register Type Modbus Address Offset (Hex) Name Read/Write Permission Data Range Default Value Description
Input Register 0x0000 VID R 0x3343-0x3343 0x3343 Vendor ID (VID)
Input Register 0x0001 PID R 0x0000-0xFFFF 0xC299/0xC298 Product ID (PID) (bmp581/bmp585)
BMP581 PID: 0xC299
BMP585 PID: 0xC298
Input Register 0x0002 Hardware Version V1.0.0.0 R 0x0000-0xFFFF 0x1000 Hardware version number: 0x1000 corresponds to V1.0.0.0
Input Register 0x0003 Firmware Version V1.0.0.0 R 0x0000-0xFFFF 0x1000 Software version number: 0x1000 corresponds to V1.0.0.0
Input Register 0x0004 Module Device Address R 0x0046-0x0047 0x0047 Unique address of the device on the communication bus.
Switch the address (0x47, 0x46) via the DIP switch on the sensor.
Non-volatile (persists after power-off) and takes effect upon restart.
Input Register 0x0007 Chip ID R 0x0050-0x0050 0x0050 Unique identifier for the sensor chip model
Input Register 0x0008 Revision ID R 0x0032-0x0032 0x0032 Identifier for the design revision of the sensor chip
Input Register 0x0017 Chip Status R 0x0000-0x000F 0x0000 Status register containing the current operating state of the chip.
0b0000 0000 0000 0000
Bits 0-1 function as follows:
1. 0b00 (0x0): I2C mode only
2. 0b01 (0x1): SPI MODE1 and MODE2
3. 0b10 (0x2): SPI MODE0 and MODE3
4. 0b11 (0x3): Both SPI and I2C available (auto-configured, default I2C mode). During power-up, the CSB pin should be connected to VDDIO to pull it high. If the CSB pin is set to low level during power-up, the I2C interface will be disabled.
0b0000 0000 0000 0000
Bit 2 function as follows:
i3c_err_0: Set to 1 when an SDR parity error occurs
0b0000 0000 0000 0000
Bit 3 function as follows:
i3c_err_3: Set to 1 when an s0/s1 error occurs
Example:
0b0000 0000 0000 0001 (0x0001) indicates I2C mode only, no i3c_err_0 or i3c_err_3.
Input Register 0x001D FIFO Count R 0x0000-0x00FF 0x0000 Number of current data frames in the FIFO buffer
Input Register 0x0023 Temperature Data XLSB R 0x0000-0x00FF 0x007F Extra least significant byte of temperature data (TEMP_DATA_7_0)
Input Register 0x0024 Temperature Data LSB R 0x0000-0x00FF 0x007F Least significant byte of temperature data (TEMP_DATA_15_8)
Input Register 0x0025 Temperature Data MSB R 0x0000-0x00FF 0x007F Most significant byte of temperature data (TEMP_DATA_23_16)
0b0000 0000 0000 0000 0000 0000
DATA_MSB DATA_LSB DATA_XLSB
Temperature (°C) = (TEMP_DATA_MSB, TEMP_DATA_LSB, TEMP_DATA_XLSB) / 2¹⁶
Input Register 0x0026 Pressure Data XLSB R 0x0000-0x00FF 0x007F Extra least significant byte of pressure data (PRESS_DATA_7_0)
Input Register 0x0027 Pressure Data LSB R 0x0000-0x00FF 0x007F Least significant byte of pressure data (PRESS_DATA_15_8)
Input Register 0x0028 Pressure Data MSB R 0x0000-0x00FF 0x007F Most significant byte of pressure data (PRESS_DATA_23_16)
The final pressure data consists of:
0b0000 0000 0000 0000 0000 0000
DATA_MSB DATA_LSB DATA_XLSB
Pressure (Pa) = (PRESS_DATA_MSB, PRESS_DATA_LSB, PRESS_DATA_XLSB) / 2⁶
Input Register 0x002D Interrupt Status R 0x0000-0x00FF 0x0000 Register containing various interrupt status flags (bit set to 1 indicates interrupt trigger)
0b0000 0000 0000 0000
Bit 0: Data Ready Interrupt
0b0000 0000 0000 0000
Bit 1: FIFO Full
0b0000 0000 0000 0000
Bit 2: FIFO Threshold Triggered
0b0000 0000 0000 0000
Bit 3: Pressure Data Out of Set Threshold Range
0b0000 0000 0000 0000
Bit 4: Power-On Reset (POR) or Software Reset Completed
Input Register 0x002E Status R 0x0000-0x00FF 0x0002 Register containing general device status information (bit set to 1 indicates the corresponding status)
0b0000 0000 0000 0000
status_core_rdy (Bit 1): Digital core ready flag
0b0000 0000 0000 0000
status_nvm_rdy (Bit 2): Non-Volatile Memory (NVM) ready flag
0b0000 0000 0000 0000
status_nvm_err (Bit 3): NVM operation error (e.g., power failure, programming timeout)
0b0000 0000 0000 0000
status_nvm_cmd_err (Bit 4): NVM command execution failure (e.g., invalid parameters)
0b0000 0000 0000 0000
st_crack_pass (Bit 7): Hardware crack detection pass flag
Input Register 0x002F FIFO Data R 0x0000-0x00FF 0x007F Register for reading FIFO buffer data
PT-frameP-frameT-frameempty-frame
Input Register 0x003E Effective Oversampling Rate R 0x0000-0x00FF 0x0000 Register indicating the current effective oversampling rate setting
0b0000 0000 0000 0000
Bits 0-2: Temperature oversampling rate
0b0000 0000 0000 0000
Bits 3-5: Pressure oversampling rate
Refer to the Oversampling Rate Configuration Register for specific values.
Holding Register 0x0001 Module Baud Rate RW 0x0000-0x0008 0x0003 Register for setting the communication baud rate
0x0001: 2400
0x0003: 9600 (default)
0x0004: 14400
0x0005: 19200
0x0006: 38400
0x0007: 57600
0x0008: 115200
Other values: 115200
Non-volatile, takes effect upon restart.
Holding Register 0x0002 Reserved Bits RW 0x0000-0xFFFF 0x0001 Reserved
Holding Register 0x0019 Driver Configuration RW 0x0000-0x00FF 0x0030 Register for configuring output driver strength and characteristics
0b0000 0000 0000 0000
Bit 0 (I2C mode only): Controls the pull-up resistor of the CSB pin:
- 0b0 (0x0): Disable pull-up
- 0b1 (0x1): Enable pull-up
0b0000 0000 0000 0000
Bit 1: SPI mode selection:
- 0b0 (0x0): 4-wire SPI mode
- 0b1 (0x1): 3-wire SPI mode (reduces the number of communication pins)
0b0000 0000 0000 0000
Bits 4-7: Driver strength configuration for serial IO pins (SDX, SDO); the most significant bit (MSB) is only effective in I2C mode.
Holding Register 0x001A Interrupt Configuration RW 0x0000-0x00FF 0x0035 Register for configuring interrupt trigger conditions and behavior
0b0000 0000 0000 0000
Bit 0: Interrupt Mode:
- 0b0 (0x0): Pulsed mode (automatically deasserts after interrupt trigger)
- 0b1 (0x1): Latched mode (requires software to clear the interrupt flag)
0b0000 0000 0000 0000
Bit 1: Interrupt Polarity:
- 0b0 (0x0): Active low
- 0b1 (0x1): Active high
0b0000 0000 0000 0000
Bit 2: Interrupt Pin Type:
- 0b0 (0x0): Push-pull output (high driving capability)
- 0b1 (0x1): Open-drain output (requires external pull-up)
0b0000 0000 0000 0000
Bit 3: Interrupt Enable:
- 0b0 (0x0): Disable interrupt
- 0b1 (0x1): Enable interrupt
0b0000 0000 0000 0000
Bits 4-7: Driver strength configuration for the interrupt pin (INT); the most significant bit (MSB) is only effective in open-drain mode.
Holding Register 0x001B Interrupt Source RW 0x0000-0x00FF 0x0000 Register for configuring which events can trigger interrupts (- 0b0 (0x0): Disable interrupt; - 0b1 (0x1): Enable interrupt)
0b0000 0000 0000 0000
Bit 0: Data Ready Interrupt Enable:
After enabling, triggers an interrupt when the data register update is completed.
0b0000 0000 0000 0000
Bit 1: FIFO Full Interrupt Enable:
After enabling, triggers an interrupt when the FIFO buffer is full.
0b0000 0000 0000 0000
Bit 2: FIFO Threshold/Watermark Interrupt Enable:
After enabling, triggers an interrupt when the FIFO data volume reaches the threshold.
0b0000 0000 0000 0000
Bit 3: Pressure Data Out-of-Range Interrupt Enable:
After enabling, triggers an interrupt when the pressure data exceeds the set range.
Holding Register 0x001C FIFO Configuration RW 0x0000-0x00FF 0x0000 Register for configuring the FIFO buffer operation mode
0b0000 0000 0000 0000
Function of Bits 0-4: Set the FIFO trigger threshold (triggers the corresponding action when the data volume reaches this value).
Values and descriptions:
0b00000 (0x0): Disable FIFO threshold function (no trigger condition);
0b11111 (0x1F): Set the threshold to 31 frames (triggers the action when the data volume reaches 31 frames).
The maximum configurable number of frames varies by data frame type (PT-frame: up to 15 frames; P-frame/T-frame: up to 31 frames)
0b0000 0000 0000 0000
Function of Bit 5: Select the FIFO operating mode.
Values and descriptions:
0b0 (0x0): Stream-to-FIFO Mode — Continuously writes data to the FIFO (continues writing even if the FIFO is nearly full);
0b1 (0x1): STOP-on-FULL Mode — Stops writing new data after the FIFO is full (prevents overflow).
Holding Register 0x001E FIFO Data Frame Type Configuration RW 0x0000-0x00FF 0x0000 Configure the types of data frames stored in the FIFO
0b0000 0000 0000 0000
Bits 0-1: Select the FIFO frame data source:
0b00 (0x0): FIFO disabled (no data written to FIFO)
0b01 (0x1): Store only temperature data to FIFO
0b10 (0x2): Store only pressure data to FIFO
0b11 (0x3): Store both pressure + temperature data to FIFO
0b0000 0000 0000 0000
Bits 2-4: Set the FIFO downsampling rate (writes to the FIFO every n samples)
n = 2ˣ
X ranges from 0 (0b000) to 7 (0b111)
Holding Register 0x0031 Non-Volatile Memory Address RW 0x0000-0x00FF 0x0000 Register for setting the access address of non-volatile memory
Holding Register 0x0032 Non-Volatile Memory Data LSB RW 0x0000-0x00FF 0x0000 Least significant byte of non-volatile memory data
Holding Register 0x0033 Non-Volatile Memory Data MSB RW 0x0000-0x00FF 0x0000 Most significant byte of non-volatile memory data

Common Modbus-RTU Function Codes

Function Code (Hex) Name Function Description
0x03 Read Multiple Registers Read integers, characters, status words, and floating-point numbers (read N words) — Operates on Holding Registers with byte-level access.
0x04 Read Input Registers Read integers, status words, and floating-point numbers (read N words) — Operates on Input Registers with byte-level access.
0x06 Write Single Holding Register Write integers, characters, status words, and floating-point numbers (write one word) — Operates on Holding Registers with byte-level access.
0x10 Write Multiple Holding Registers Write to multiple consecutive Holding Registers — Load specific binary values into a series of contiguous Holding Registers.

The above commands enable reading and writing of Input Registers and Holding Registers.

Register Read/Write Examples

Hardware Preparation

Recommended Serial Debug Tools & Downloads

For serial communication debugging, professional tools are required. The following commonly used and feature-rich tools are recommended:

  • XCOM Serial Debug Assistant V2.0: An efficient and easy-to-use serial communication tool. [Download Link]
  • SSCOM3.2 Serial Assistant: Designed for embedded development, IoT communication, and daily serial debugging. [Download from Project Repository]

General Operation Steps

  • Hardware Connection: Connect the sensor to the host (computer) via the RainbowLink USB Protocol Converter. Switch the sensor's communication mode to UART and address to 0x47.
  • Parameter Configuration: Set the following parameters in the serial debug tool (must match the sensor's configuration):
    • Baud Rate: 9600 (default)
    • Data Bits: 8 bits
    • Stop Bits: 1 bit
    • Parity: None
  • Send Command: Enter the hexadecimal command in the "Transmit Area" of the debug tool, check "Hex Send", and click Send.

Example 1: Read Pressure Value (Input Register Read Operation)

Function: Read the current pressure value detected by the sensor via the Modbus RTU protocol.

Transmit Command & Parsing
Field Name Hex Value Description
Device Address 47 Default UART address of the sensor (0x47)
Function Code 04 Read Input Registers (fixed command)
Starting Register Address 00 26 Lowest significant register address for pressure data
Number of Registers 00 03 Read 3 consecutive registers
CRC Check 5F 66 Command checksum (ensures transmission integrity)

Complete Transmit Command: 47 04 00 26 00 03 5F 66

Response Data & Parsing

After receiving the command, the sensor returns pressure data. Example response:

Field Name Hex Value Description
Device Address 47 Matches the device address in the transmit command
Function Code 04 Confirms execution of "Read Input Registers" operation
Number of Bytes 06 Total number of returned data bytes (6 bytes)
Read Data 00 05 00 FD 00 5B Raw pressure data (requires conversion to standard pressure unit (Pa) using the formula below)
CRC Check 66 FB Checksum of the response data

Complete Response Data: 47 04 06 00 05 00 FD 00 5B 66 FB

Data Conversion Principle

The complete pressure data in Modbus registers consists of 3 Input Registers (address range: 0x0026-0x0028). Since data must be read starting from the lowest significant register, the starting address in the command is set to 0x0026, and the response data follows the same order (from least significant to most significant).

  • Response data breakdown:
    • "00 05": Least Significant Byte (LSB)
    • "00 FD": Middle Significant Byte
    • "00 5B": Most Significant Byte (MSB)
  • Reassemble the bytes in MSB-to-LSB order: 00 5B 00 FD 00 05
  • Convert hexadecimal to decimal: 6028549
  • Pressure calculation formula: Pressure (Pa) = Raw Data / 2⁶
  • Result: Pressure = 6028549 / 64 = 94196 (Pa)

Schematic Diagram:

Example 2: Modify Module Baud Rate (Holding Register Write Operation)

Function: Modify the sensor's UART baud rate via the Modbus RTU protocol (default: 9600, customizable).

Transmit Command & Parsing
Field Name Hex Value Description
Device Address 47 Default address of the sensor (0x47)
Function Code 06 Write Single Holding Register (fixed command)
Starting Register Address 00 01 Register address corresponding to baud rate configuration
Data to Write 00 08 Corresponding to 115200 bps (see Register Table for value-baud rate mapping)
CRC Check D7 6A Command checksum

Complete Transmit Command: 47 06 00 01 00 08 D7 6A

Complete Response Data: 47 06 00 01 00 08 D7 6A

Notes

  • If the response data matches the transmit command, the baud rate modification request has been accepted by the device.
  • The new baud rate takes effect only after powering off and restarting the sensor.
  • After restart, update the serial debug tool's baud rate to 115200; otherwise, communication will fail.

Schematic Diagram:

More Downloads