Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

DPS310 Altitude Readings
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

DPS310 Altitude Readings

by darbymotorsports on Fri Aug 07, 2020 3:41 pm

I am trying to get altitude readings from this sensor. Is there a function within Adafruit_DPS310.h or do I have to mathematically calculate based on pressure and temperature?

The example includes functions to pull temperature and pressure. Is there a list of functions and descriptions somewhere that will work?

This is the code from example,

// 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(0x77)) { // Can pass in I2C address here, By default, the I2C address is 0x77.
//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();
}

darbymotorsports
 
Posts: 1
Joined: Mon Aug 03, 2020 11:02 pm

Re: DPS310 Altitude Readings

by rick_sroka on Wed Aug 26, 2020 8:07 am

I was going to post that the program example on https://adafruit-circuitpython-dsp310.r ... /en/latest only show temp and Barometric not Altitude

rick_sroka
 
Posts: 18
Joined: Thu Nov 12, 2015 3:54 pm

Re: DPS310 Altitude Readings

by adafruit_support_carter on Wed Aug 26, 2020 11:55 am

It looks like the libraries do not currently have an altitude function. So you'll have to do the math. Good info here:
https://learn.adafruit.com/clue-altimeter/overview
and the implementation in the BMP280 library may be helpful as a reference:
https://github.com/adafruit/Adafruit_BM ... 0.cpp#L373

adafruit_support_carter
 
Posts: 16820
Joined: Tue Nov 29, 2016 2:45 pm

Re: DPS310 Altitude Readings

by rick_sroka on Wed Aug 26, 2020 1:35 pm

ok can you change the info on the listings? i bought the unit for the altitude part.

rick_sroka
 
Posts: 18
Joined: Thu Nov 12, 2015 3:54 pm

Re: DPS310 Altitude Readings

by siddacious on Wed Aug 26, 2020 7:11 pm

Adapting the code below is all that would be required to get an altitude from a pressure reading. You'll have to define the pressure at sea level in hPa.

Code: Select all | TOGGLE FULL SIZE
  #define SEA_LEVEL_HPA <number here> 
  float pressure = readPressure(); // in Si units for Pascal
  pressure /= 100;

  altitude = 44330 * (1.0 - pow(pressure / SEA_LEVEL_HPA, 0.1903));

I've created an issue on the library to add a function to do this within the library itself, however there isn't anything keeping you from deriving altitude measurements without it.

Feel free to voice your support here:
https://github.com/adafruit/Adafruit_DPS310/issues/3

siddacious
 
Posts: 297
Joined: Fri Apr 21, 2017 3:09 pm

Re: DPS310 Altitude Readings

by rick_sroka on Wed Aug 26, 2020 8:26 pm

Hey thanks so much for the code. I am luck to add 1+1 to equals 2 some days

rick_sroka
 
Posts: 18
Joined: Thu Nov 12, 2015 3:54 pm

Re: DPS310 Altitude Readings

by rick_sroka on Sun Sep 06, 2020 12:30 pm

Looks like the bug is fixed . How do I reload the driver on the raspberry pi?

rick_sroka
 
Posts: 18
Joined: Thu Nov 12, 2015 3:54 pm

Re: DPS310 Altitude Readings

by siddacious on Tue Sep 08, 2020 2:11 pm

this should work:
Code: Select all | TOGGLE FULL SIZE
pip install [package_name] --upgrade


if you previously installed with a "sudo" before "pip", you may need to add it to the above

siddacious
 
Posts: 297
Joined: Fri Apr 21, 2017 3:09 pm

Please be positive and constructive with your questions and comments.