BMP384 and Raspberry Pi Pico Arduino example

In this article we connect the ever popular BMP384 Sensor to a raspberry Pi Pico and we will then display readings via the serial monitor window. We are using t he Arduino IDE.

Lets look at the sensor first

Features

The BMP384 provides excellent accuracy across a wide measurement range (300hPa to 1250hPa and -40 to +85°C).

The sensor also features a configurable oversampling setting, a FIFO buffer for storing up to 73 measurements, as well as a low pass filter so users can customize the performance based on the application’s requirements.

The sensor communicates over I2C by default.

The BMP384 has three operating modes: Sleep Mode, Normal Mode and Forced Mode. While in Sleep Mode the sensor is idle and consumes ~2µA. While in Normal Mode, the sensor automatically cycles between measurement and standby periods and consumes ~700µA at peak current draw during measurements.

Forced Mode allows direct control of measurements to wake the sensor from Sleep Mode, take a single-shot measurement, and return the device to Sleep Mode.

Parameter Technical data
Operation range
Pressure: 300… 1250 hPa
Supply voltage VDDIO
Supply voltage VDD
1.2 V … 3.6 V
1.65 V … 3.6 V
Interface
I²C (up to 3.4 MHz) and SPI (3 and 4 wire, up to 10 MHz)
Average typical current consumption (1 Hz data rate)
3.4 µA @ 1 Hzpressure and temperature,
2.0 µA in sleep mode
Absolute accuracy
P=300 …1100 hPa (T=0 … 65 °C)
± 50 Pa
Relative accuracy pressure (typ.)
P=900…1100 hPa (T=25 … 40°C)
± 9 Pa, equiv. to ± 0.75 m
Noise in pressure (lowest bandwidth, highest resolution)
0.03 Pa
Temperature coefficient offset (25°…40°C @ 900 hPa)
±1 Pa/K
Long-term stability (12 months)
±0.70 hPa
Maximum sampling rate
200 Hz

Parts Required

Name Link
Raspberry Pi Pico
BMP384
Connecting cables

 

Schematic/Connection

Here is a layout in fritzing to show this

Code Example

I used the sparkfun BMP384 library and  this is the default example which worked

#include <Wire.h>
#include "SparkFunBMP384.h"

// Create a new sensor object
BMP384 pressureSensor;

// I2C address selection
uint8_t i2cAddress = BMP384_I2C_ADDRESS_DEFAULT; // 0x77
//uint8_t i2cAddress = BMP384_I2C_ADDRESS_SECONDARY; // 0x76

void setup()
{
    // Start serial
    Serial.begin(115200);
    Serial.println("BMP384 Example1 begin!");

    // Initialize the I2C library
    Wire.begin();

    // Check if sensor is connected and initialize
    // Address is optional (defaults to 0x77)
    while(pressureSensor.beginI2C(i2cAddress) != BMP3_OK)
    {
        // Not connected, inform user
        Serial.println("Error: BMP384 not connected, check wiring and I2C address!");

        // Wait a bit to see if connection is established
        delay(1000);
    }

    Serial.println("BMP384 connected!");
}

void loop()
{
    // Get measurements from the sensor
    bmp3_data data;
    int8_t err = pressureSensor.getSensorData(&data);

    // Check whether data was acquired successfully
    if(err == BMP3_OK)
    {
        // Acquisistion succeeded, print temperature and pressure
        Serial.print("Temperature (C): ");
        Serial.print(data.temperature);
        Serial.print("\t\t");
        Serial.print("Pressure (Pa): ");
        Serial.println(data.pressure);
    }
    else
    {
        // Acquisition failed, most likely a communication error (code -2)
        Serial.print("Error getting data from sensor! Error code: ");
        Serial.println(err);
    }

    // Only print every second
    delay(1000);
}

 

Output

Temperature (C): 18.95 Pressure (Pa): 98937.87
Temperature (C): 18.96 Pressure (Pa): 98915.58
Temperature (C): 18.95 Pressure (Pa): 98953.07
Temperature (C): 18.95 Pressure (Pa): 98913.54
Temperature (C): 18.95 Pressure (Pa): 98929.76

Links

https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp384-ds003.pdf

https://github.com/sparkfun/SparkFun_BMP384_Arduino_Library

Related posts

STTS22H temperature sensor and Raspberry Pi Pico Arduino example

KX132 accelerometer and Raspberry Pi Pico Arduino example

RGB LED examples on the Arduino Nano RP2040 Connect

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