Home CodeCircuitpython Raspberry Pi Pico and BMP388 barometric pressure sensor circuitpython example

Raspberry Pi Pico and BMP388 barometric pressure sensor circuitpython example

by rp2040guy71

In this article we connect a BMP388 barometric pressure sensor to a Raspberry Pi Pico running Circuitpython

Sensor Information

The BMP388 is a very small, precise, low power, low noise absolute barometric pressure sensor. It enables accurate altitude tracking and is perfectly suited for drone applications.

By making accurate steering significantly easier, the BMP388 enhances the drone flying experience.

It is compatible for use with other Bosch sensors such as the BMI088 for better performance, robustness and stability. The BMP388 sensor excites with an outstanding design flexibility.

The barometric pressure is usually used to measure barometric pressure and temperature. But besides that, we can also use the sensor to measure the altitude and the relative floor height due to the fact that there is a certain relationship between altitude and barometric pressure.

BMP388 is based on Bosch’s mature Piezo resistive pressure sensor technology featuring high accuracy as well low power consumption and high EMC robustness.

The sensor features an accuracy of about ±8Pa, which is equivalent to about ±0.5m difference in altitude, and an absolute accuracy temperature of ±0.5℃ for a temperature range between 0℃ and 65℃.


  • Low power consumption
  • Low noise
  • High resolution
  • Small dimensions
  • Best-in-class offset temperature coefficient(-20℃-65℃@700-1100hPa)


  • Operating Voltage: 3.3V-5.5V
  • Operating Current: 0.5mA
  • Operating Range: 300-1250 hPa
  • Relative Accuracy: ±8 Pa (equivalent to ±0.50m @700-900hPa, 25℃-40℃)
  • Absolute Accuracy: ±50 Pa(0℃-65℃@300-1100hPa)
  • Temperature Coefficient Offset: ±0.75 Pa/K(-20℃-65℃@700-1100hPa)
  • Absolute Accuracy Temperature: ±0.5℃(@0℃-65℃)
  • Operating Temperature: -40℃~80℃ (more accurate in 0℃-65℃)

Parts Required


Name Link
Pico Raspberry Pi Pico Development Board
BMP388 BMP388 Atmospheric Pressure Sensor
Connecting cables Aliexpress link

Amazon.com link

Ebay link



Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

rp2040 and bmp388

rp2040 and bmp388

Code Example

I used Thonny for development

The following is based on a library , I copied the adafruit_bmp3xx.mpy library for this device to the lib folder on my Raspberry Pi Pico – https://circuitpython.org/libraries

This is the basic example which comes with the library

import time
import board
import adafruit_bmp3xx
import busio
i2c = busio.I2C(scl=board.GP1, sda=board.GP0) # uses board.SCL and board.SDA
# To initialise using the default address:
bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c)
bmp.pressure_oversampling = 8
bmp.temperature_oversampling = 2
while True:
        "Pressure: {:6.4f}  Temperature: {:5.2f}".format(bmp.pressure, bmp.temperature)


Here is what I saw in Thonny REPL window

Pressure: 995.6948 Temperature: 22.52
Pressure: 995.7038 Temperature: 22.47
Pressure: 995.7166 Temperature: 22.40
Pressure: 995.8149 Temperature: 22.70
Pressure: 995.8398 Temperature: 24.51
Pressure: 995.7399 Temperature: 25.07



You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More