Home » DPS310 barometric pressure sensor and ESP32 board example

DPS310 barometric pressure sensor and ESP32 board example

by shedboy71

In this example we take a look at the DPS310 barometric pressure sensor from Infineon to an ESP32

First lets look at some information about the sensor from the manufacturer

The pressure sensor element is based on a capacitive sensing principle which guarantees high precision during temperature changes. The small package makes the DPS310 ideal for mobile applications and wearable devices.The internal signal processor converts the output from the pressure and temperature sensor elements to 24 bit results.

Each unit is individually calibrated, the calibration coefficients calculated during this process are stored in the calibration registers. The coefficients are used in the application to convert the measurement results to high accuracy pressure and temperature values.

The result FIFO can store up to 32 measurement results, allowing for a reduced host processor polling rate. Sensor measurements and calibration coefficients are available through the serial I2C or SPI interface.

The measurement status is indicated by status bits or interrupts on the SDO pin.

Here is the sensor I purchased from the good folks at Adafruit (via Pimoroni in the UK)


  • Supply voltage range 1.7V to 3.6V
  • Operation range 300hPa – 1200hPa
  • Sensor’s precision 0.002hPa
  • Relative accuracy ±0.06hPa
  • Pressure temperature sensitivity of 0.5Pa/K
  • Temperature accuracy  ±0.5C°


This is the sensor that I bought

Parts Required

Here are the parts I used

The sensor you can pick up in the $6 price range – you can connect to the sensor using a standard header the classic dupont style jumper wire.

Name Link
ESP32 WeMos Mini D1 LOLIN32 ESP32
DPS310 DPS310 Precision Barometric Pressure / Altitud
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire




The layout below shows an Adafruit Huzzah ESP32, I tried a couple of other ESP32 boards like the Lolin32 as well and they worked just fine

If you have an ESP32 board with a STEMMA QT cables, you can use these:

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

I actually just extended and use this but in the layout I have shown that you can solder a header and just this as well – so you have a choice

Code Example

This example uses a couple of libraries, both of which can be installed using the library manager. if you search for the DPS310 one first and you are using a newer version of the Arduino IDE it will install the other one as well – which is useful.

You need the Adafruit library for the https://github.com/adafruit/Adafruit_DPS310

You also need an I2C support library from the same folks for the library above to work and that is available from – https://github.com/adafruit/Adafruit_BusIO

This is the simple test example, when you install the library there is also another sensor test example which is similar

[codesyntax lang=”cpp”]

// This example shows how to read temperature/pressure

#include <Adafruit_DPS310.h>

Adafruit_DPS310 dps;

// Can also use SPI!
#define DPS310_CS 10

void setup() {
  while (!Serial) delay(10);

  if (! dps.begin_I2C()) {             // Can pass in I2C address here
  //if (! dps.begin_SPI(DPS310_CS)) {  // If you want to use SPI
    Serial.println("Failed to find DPS");
    while (1) yield();
  Serial.println("DPS OK!");

  dps.configurePressure(DPS310_64HZ, DPS310_64SAMPLES);
  dps.configureTemperature(DPS310_64HZ, DPS310_64SAMPLES);

void loop() {
  sensors_event_t temp_event, pressure_event;
  while (!dps.temperatureAvailable() || !dps.pressureAvailable()) {
    return; // wait until there's something to read

  dps.getEvents(&temp_event, &pressure_event);
  Serial.print(F("Temperature = "));
  Serial.println(" *C");

  Serial.print(F("Pressure = "));
  Serial.println(" hPa"); 




Here is what I saw in Serial monitor

Temperature = 18.90 *C
Pressure = 988.10 hPa

Temperature = 19.25 *C
Pressure = 988.14 hPa

Temperature = 19.78 *C
Pressure = 988.16 hPa

Temperature = 20.27 *C
Pressure = 988.16 hPa






You may also like

Leave a Comment

%d bloggers like this:

Adblock Detected

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