Home Code Arduino Uno and DPS310 barometric pressure sensor

Arduino Uno and DPS310 barometric pressure sensor

by shedboy71

In this example we connect a DPS310 barometric pressure sensors from Infineon to an Arduino Uno

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

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

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

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

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

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

Features

  • 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.

I used a Qwiic cable – since a few sensors seem to use these but this is optional

Name Link
Arduino Uno UNO R3 CH340G/ATmega328P, compatible for Arduino UNO
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
sensor shield Expansion IO Board Sensor Shield

 

Schematic/Connection

I used the Adafruit sensor and in this case used the Stemma connection

For the STEMMA QT cables, it uses the Qwiic convention:

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

So color coded for ease of use

arduino and DPS310

arduino and DPS310

Code Example

This example uses a couple of libraries, both of which can be installed using the library manager

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

[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() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  Serial.println("DPS310");
  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.print(temp_event.temperature);
  Serial.println(" *C");

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

  Serial.println();
}

[/codesyntax]

Output

Here is what I saw in Serial monitor

DPS310
DPS OK!
Temperature = 18.77 *C
Pressure = 992.08 hPa

Temperature = 18.79 *C
Pressure = 992.08 hPa

Temperature = 18.80 *C
Pressure = 992.08 hPa

Links

Datasheet

Share

You may also like

Leave a Comment