Part

Barometric pressure, DPS310

Pressure to a fraction of a pascal and temperature over I2C, with up to 128 times oversampling.

See every part
  • 4 pins
  • 3 settings
  • In 1 project
Drawn live by the editor's own code, at the size you see it.
Barometric pressure, DPS310 as drawn in the Mokxi simulator
At a glance

The Barometric pressure, DPS310 in brief

What it is, and every setting the properties panel gives it.

The Infineon DPS310 is a barometric pressure sensor that reads air pressure to a fraction of a pascal, plus temperature, over I2C at address 0x77 or 0x76. It is precise enough to tell a table from the floor by altitude, and it is the pressure sensor of drones and step counters. The board runs on 3 to 5 V on VIN, with GND for ground and SCL and SDA for I2C; the board carries the pull-ups. The model exposes three settings: the I2C address (0x76 or 0x77), pressure in hectopascals from 300 to 1200, and temperature, and the pressure and temperature sliders can be dragged while the circuit runs. Adafruit's library, shipped as Adafruit_DPS310.h, handles the raw 24-bit counts and the calibration coefficients. The model leaves out the FIFO, the interrupt pin, and the noise that oversampling removes.

Family
Sensors
Pins
4
address
119
temperature
22
pressure
1013.25
Pins

4 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
VIN
Supply, 3 to 5 V on the board.
GND
Ground.
SCL
I2C. The board carries the pull-ups.
SDA
I2C. The board carries the pull-ups.
How to use it

How to use the DPS310 barometer with an Arduino Uno

The example project is a height meter, the two halves of a drone's altimeter. A VL53L1X laser ranger points straight down and measures the height above the floor, and the DPS310 barometer works out how far the circuit has climbed from the change in air pressure. The DPS310 is wired VIN to the Uno's 5V pin, GND to GND, SCL to A5 and SDA to A4, the I2C pins.

The sketch starts the ranger, then calls baro.begin_I2C(0x76), configures pressure and temperature at 16 Hz with 16 samples, throws away one reading taken at the old settings, and waits for the first at the new ones before storing the starting pressure. In the loop it reads the ranger distance, reads the pressure, and multiplies the pressure drop by 8.3 to get meters climbed, about 8.3 m per hectopascal near sea level, printing both numbers every 400 ms.

With default settings, the serial monitor printed: "Height meter ready" and "floor 1200 mm climbed 0.0 m". The floor figure is the laser distance to the floor, 1200 mm. The climb is 0.0 m because the pressure has not changed since the sketch started.

After the pressure slider on the DPS310 was dragged down by 12 hPa, the serial monitor printed: "floor 1200 mm climbed 99.6 m". The laser distance stays the same because nothing moved toward the floor, while the pressure drop of 12 hPa reads as about 100 m of climb. You can try dragging the distance slider on the VL53L1X too, which changes only the floor number.

Part pin
Goes to
VIN
Arduino Uno R3 pin 5V
GND
Arduino Uno R3 pin GND
SCL
Arduino Uno R3 pin A5
SDA
Arduino Uno R3 pin A4
Height meterlive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
sketch.ino · Arduino Uno R3 · the first 45 lines
// Height meter: a VL53L1X laser ranger looks straight down for the height
// above the floor, and a DPS310 barometer works out how far it has climbed
// from the change in air pressure, the way a drone keeps its height.
//
//   VL53L1X, DPS310   SDA -> A4   SCL -> A5   VIN -> 5 V   GND -> GND
//
// The laser is exact to a few millimeters but only reaches 4 m. The
// barometer reaches any height, but air pressure only falls about 12 Pa a
// meter near the ground, so it needs the DPS310's precision. Together they
// cover both.
//
// Things to try. Drag the distance slider on the VL53L1X. Then drag the
// pressure slider on the DPS310 down by 12 hPa: that is about 100 m of climb.

#include <Wire.h>
#include <VL53L1X.h>
#include <Adafruit_DPS310.h>

VL53L1X ranger;
Adafruit_DPS310 baro;
float startPressure = 0;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  ranger.setTimeout(500);
  if (!ranger.init()) {
    Serial.println("No VL53L1X");
  }
  ranger.setDistanceMode(VL53L1X::Long);
  ranger.setMeasurementTimingBudget(50000);
  ranger.startContinuous(100);
  if (!baro.begin_I2C(0x76)) {
    Serial.println("No DPS310");
  }
  baro.configurePressure(DPS310_16HZ, DPS310_16SAMPLES);
  baro.configureTemperature(DPS310_16HZ, DPS310_16SAMPLES);
  // Throw away the reading taken at the old settings, then wait for the
  // first at the new ones.
  sensors_event_t temp, pressure;
  baro.getEvents(&temp, &pressure);
  while (!baro.temperatureAvailable() || !baro.pressureAvailable()) {
    delay(10);
  }
  baro.getEvents(&temp, &pressure);
Common errors

Common Barometric pressure, DPS310 errors and fixes

What goes wrong
The fix
Reading the sensor before COEF_RDY comes up.
Wait the first 40 ms after power on or a soft reset so the calibration coefficients are loaded.
Expecting a new reading every loop.
Remember that at 64 times oversampling each reading takes 104 ms.
Using the wrong I2C address in begin_I2C.
The DPS310 sits at 0x76 or 0x77; the sketch uses 0x76, and the address setting can be changed to match.
Reading a pressure value taken at the old configure settings.
Throw away the first reading after configuring, then wait for one at the new settings, as the sketch does.
Questions

Questions and answers

what is the dps310 i2c address

It is 0x77 or 0x76. The sketch calls begin_I2C(0x76).

how precise is the dps310

It reads air pressure to a fraction of a pascal, precise enough to tell a table from the floor by altitude.

what library reads the dps310 on an arduino

Adafruit's library, which Mokxi ships as Adafruit_DPS310.h. You call begin_I2C, configure pressure and temperature, then getEvents for pascals and degrees.

what does the dps310 model leave out

The FIFO, the interrupt pin, and the noise that oversampling removes.

How it is modeled

What is true about the Barometric pressure, DPS310, here

In its help article’s own words: what the simulation gets right, and where it stops.

Not modeled

The FIFO and the interrupt pin, and the noise oversampling removes.

From DPS310 barometric pressure sensor, in full.

Projects

See the Barometric pressure, DPS310 in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

The boards it is shown on

This board has a built-in project with the Barometric pressure, DPS310 in it.

Wire up the Barometric pressure, DPS310

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.