Home » Connect a BMP384 pressure sensor to an ESP32 module example

Connect a BMP384 pressure sensor to an ESP32 module example

by shedboy71

In this article we look at a temperature and pressure sensor, the BMP384 pressure sensor from Bosch Sensortec, and connect it to an ESP32 board

Sensor Information

The BMP384 can be used for high-resolution measurements (up to 21-bit) and uses a gel-filled cavity to provide extra resistance to liquids (water and other chemicals). This makes it a great option for monitoring pressure near water or in humid environments, though the sensor is not water-proof without an adequate integration concept.

The BMP384 provides excellent accuracy across a wide measurement range (300hPa to 1250hPa and -40 to +85°C) on an incredibly small footprint that uses the Qwiic Micro size (0.75in. x 0.30in. / 19.05mm x 7.62mm) so you can install it in projects with exceptionally tight spaces.

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

The Qwiic Pressure Sensor communicates over I2C by default, utilizing the handy Qwiic system so no soldering is required to connect it to the rest of your system.

The BMP384 has three operating modes: Sleep Mode, Normal Mode and Forced Mode. 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.

This is what the breakout looks like that I purchased, it is from SparkFun


Take note of the supply voltage

  • Supply Voltage Range: 1.65V – 3.6V
  • Current Draw:
    • 700µA – Peak while measuring pressure
    • 3.4 µA @ 1Hz – Pressure and temperature monitoring with Ultra Low Power oversampling settings
    • ~2µA – Sleep Mode
  • Data Transfer Speeds:
    • I2C – 3.4MHz
    • SPI – 10MHz
  • I2C Address: 0x77 (Default), 0x76 (Alternate which can be set under the board by bridging 2 pads using solder)
  • Internal Temperature Sensor

Parts Required

You can connect to the sensor using DuPont-style jumper wire.

The sensor will cost in the range of $20, I did get it along with various others at a decent sale price

You can connect up pretty much any ESP32 board – I used a Lolin 32 from Wemos – first board I had at hand


Name Link
Connecting cables



I used 3.3v from the ESP32

I also used a Qwiic cable, but if you do not have one, there is an unpopulated set of pins you can solder a header to. This is how you would wire this up


Code Example

I installed the Sparkfun library using the Arduino ide

Click the Manage Libraries … menu item, search for BMP384, and select the Sparkfun BMP384 library like this

This is one of the examples that gets installed with the library, with a  few comments and unused lines removed.

#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.println("BMP384 Example1 begin!");

    // Initialize the I2C library

    // 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

    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("Pressure (Pa): ");
        // Acquisition failed, most likely a communication error (code -2)
        Serial.print("Error getting data from sensor! Error code: ");

    // Only print every second



When run you will see something like this in the serial monitor window

Temperature (C): 20.67 Pressure (Pa): 100386.79
Temperature (C): 20.67 Pressure (Pa): 100403.07
Temperature (C): 20.66 Pressure (Pa): 100388.79
Temperature (C): 20.66 Pressure (Pa): 100406.11



You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.