Barometric pressure sensors are key components in wearable devices such as fitness trackers and other applications, accurately measuring altitude. The BMP585 barometric pressure sensor is the latest generation sensor from Bosch Sensors. It boasts superior accuracy and ultra-low power consumption, making it suitable for various environments including fitness trackers and indoor positioning, providing exceptional accuracy for altitude tracking applications. The BMP585 barometric pressure sensor has a small footprint, offering excellent design flexibility. It is a single-package solution that customers can easily integrate into a variety of devices, such as smartwatches, wearable devices, ear-worn devices, home appliances, smart home devices, and industrial products.
In this article, we will use the STM32 NUCLEO development board to connect the YBX-BMP585 barometric pressure sensor module via SPI to read the current barometric pressure and temperature values.
Required components
- ● NUCLEO-G070RB Development Board
- ● YBX-BMP585 Atmospheric Pressure Sensor Module
- ● Connect jumpers
- ● Micro USB cable
YBX-BMP585 Atmospheric Pressure Sensor Module
This module utilizes Bosch Sensors’ latest generation BMP585 barometric pressure sensor. This sensor boasts a wide measurement range of 300 hPa to 1250 hPa and an absolute accuracy of ±30 Pa. The BMP585 is optimized for high-performance applications, such as adaptive measurements of ±6 Pa. This corresponds to a height difference of ±50 cm and a temperature coefficient of offset (TCO) of 0.5 Pa/K. The BMP585 sensor offers extremely high accuracy, capable of measuring height changes of only a few centimeters. It can also detect movements during fitness training, even detecting the level of an individual’s pull-ups or push-ups. Furthermore, due to its extreme ruggedness, users need not worry about environmental conditions. The BMP585 features a gel-filled cavity, which, through a suitable integration concept, maximizes protection against the ingress of water and other liquids such as chemicals.

The YBX-BMP585 module has an onboard voltage LDO that supports 3.3V-5V power input. The module supports SPI and I2C interface connections via an 8-pin 2.54mm pitch header. The default I2C address is 0x47, which can be changed to 0x46 by pulling the SDO (ADR pin) high.

Hardware connection method
The NUCLEO-G070RB development board can connect to the YBX-BMP585 atmospheric pressure sensor module via both SPI and I2C. This article mainly introduces the SPI connection method. The SPI connection method is as follows:

The BMP585 module connects to the SPI1 interface of the NUCLEO-G070RB, with corresponding pins PA5 (SCK), PA6 (MISO), and PA7 (MOSI). The chip select pin CS is connected to PB0. The VCC of the BMP585 module is connected to the +5V pin, and the GND pin is connected to any GND pin of the NUCLEO-G070RB.
Connect the components as shown in the diagram. The actual connection is as follows:

Code
The code used in this article is based on the BMP5-Sensor-API driver provided by Bosch, which can be downloaded from GitHub .
Use the STM32CubeMX tool to configure the specific pin and interface parameters according to the hardware connection, and then port the code. The following functions need to be rewritten:
static int8_t get_sensor_data(const struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_dev *dev);
BMP5_INTF_RET_TYPE bmp5_spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr);
BMP5_INTF_RET_TYPE bmp5_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr);
BMP5_INTF_RET_TYPE bmp5_spi_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr);
BMP5_INTF_RET_TYPE bmp5_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr);
void bmp5_delay_us(uint32_t period_us, void *intf_ptr);
int8_t bmp5_interface_init(struct bmp5_dev *bmp5_dev, uint8_t intf);
Read the current atmospheric pressure value in the main function:
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_SPI1_Init();
/* USER CODE BEGIN 2 */
printf("\nBMP585 SPI Test\n");
printf("Bolgen Studio\n");
/* Interface reference is given as a parameter
* For I2C: BMP5_I2C_INTF
* For SPI: BMP5_SPI_INTF
/
rslt = bmp5_interface_init(&dev, BMP5_SPI_INTF);
bmp5_error_codes_print_result("bmp5_interface_init", rslt);
if (rslt == BMP5_OK)
{
rslt = bmp5_init(&dev);
bmp5_error_codes_print_result("bmp5_init", rslt);
if (rslt == BMP5_OK)
{
rslt = set_config(&osr_odr_press_cfg, &dev);
bmp5_error_codes_print_result("set_config", rslt);
}
if (rslt == BMP5_OK)
{
rslt = get_sensor_data(&osr_odr_press_cfg, &dev);
bmp5_error_codes_print_result("get_sensor_data", rslt);
}
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_Delay(50);
}
Compile and upload to the STM32 NUCLEO development board.
Test Results
Use a serial port tool to open the corresponding virtual serial port and receive the following data:









