Infineon / arduino-xensiv-dps3xx

Infineon's XENSIV™ Digital Pressure Sensor Arduino Library for all DPS3xx barometric pressure sensors
https://www.infineon.com/cms/en/product/sensor/pressure-sensors/pressure-sensors-for-iot/
Other
1 stars 2 forks source link

Use with Particle Photon shows results are off by a small amount #2

Closed buelowp closed 2 days ago

buelowp commented 3 years ago

Have you looked for an answer?

We appreciate you checking the documentation, release notes, or the Developer community before asking. Please tell us where you looked, so we can fill the gap and help the next person too.

I've googled, and looked through your tickets (open,closed). I've seen similar, but most of those seem to be programming issues.

Question/Issue:

I have ported your library to the Particle photon, and it works very well. Thank you. However, I have two DPS310 sensors from Adafruit, and I'm seeing similar results for both. The current measured conditions at the location of the sensor are ~80F (local thermometer), 29.88 InHG (taken from weather.com and weatherunderground.com), altitude ~670 feet above sea level. The values from both sensors are within a safe margin of error of each other, and reflect the print below.

0000093175 [app] INFO: Temperature: 83.078969 F, Pressure 29.19 InHG, Altitude 206.276611

Context I'm using a Particle Photon, release 3.1.0. I'm using your library mostly unmodified (I added prints to init to show the id values), though cloned to my github so I can update the properties file to create a private library. Someone else has uploaded your library unmodified, but didn't publish so I needed to change some names so I could use it. The unit is running in my office, uncovered and away from other equipment. There is no AC at this time, and no moving airflow to speak of.

I've verified my calculations are accurate for inHG online.

I'm running roughly your example, modified to calculate inHg, convert C to F, and calculate altitude.

    //set measurement precision and rate to standard values;
    configTemp(DPS__MEASUREMENT_RATE_4, DPS__OVERSAMPLING_RATE_8);
    configPressure(DPS__MEASUREMENT_RATE_4, DPS__OVERSAMPLING_RATE_8);
#include "DPS.h"

#define INHG    0.00029529983071445

Dps310 dpsobj = Dps310();
SerialLogHandler logHandler;

// setup() runs once, when the device is first turned on.
void setup() 
{
    uint8_t ret = dpsobj.begin(Wire);
    if (ret != 0)
        Log.error("Got return code %d from begin", ret);
    else
        Log.info("Product ID: %d", dpsobj.getProductId());
}

// loop() runs over and over again, as quickly as it can execute.
void loop() 
{
    float temperature;
    float pressure;
    uint8_t oversampling = 7;
    int16_t ret;

    //lets the Dps310 perform a Single temperature measurement with the last (or standard) configuration
    //The result will be written to the paramerter temperature
    //ret = Dps310PressureSensor.measureTempOnce(temperature);
    //the commented line below does exactly the same as the one above, but you can also config the precision
    //oversampling can be a value from 0 to 7
    //the Dps 310 will perform 2^oversampling internal temperature measurements and combine them to one result with higher precision
    //measurements with higher precision take more time, consult datasheet for more information
    ret = dpsobj.measureTempOnce(temperature, oversampling);

    if (ret != 0)
    {
        Log.error("Error getting temperature: %d", ret);
    }

    //Pressure measurement behaves like temperature measurement
    //ret = Dps310PressureSensor.measurePressureOnce(pressure);
    ret = dpsobj.measurePressureOnce(pressure, oversampling);
    float mercury = pressure * INHG;
    if (ret != 0)
    {
        Log.error("Error getting pressure: %d", ret);
    }

    float altitude = 44330 * (1.0 - pow((pressure / 100) / 1013, 0.1903));

    Log.info("Temperature: %f F, Pressure %0.2f InHG, Altitude %f", (temperature * 1.8 + 32), mercury, altitude);
    //Wait some time
    delay(1000);    
}

The sensor identification outputs are

0000002275 [app] INFO: virtual uint8_t Dps310::init(): Product ID: 0
0000002276 [app] INFO: virtual uint8_t Dps310::init(): Revision ID: 1
0000002276 [app] INFO: virtual uint8_t Dps310::init(): sensor id: 1

Where did you expect to find the answer? I'm hoping someone can explain why the results are consistent, but not accurate. I can't find another calibration option at this time and am hoping to use this as a weather station input.

THANKS!
github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 6 weeks with no activity. Please comment to this issue if it's still relevant.

buelowp commented 2 months ago

Anything ever come of this?

ederjc commented 2 months ago

Hi @buelowp, my apologies for this late reply! I am not sure if I got your question correctly: Are you concerned about the difference in temperature values compared to the local thermometer?

buelowp commented 2 months ago

It has been a while, but I bumped this after I got a message that it was going to close just in case someone else might see it. The concern at the time was that the pressure measurements were so inconsistent with measurements from a similar device nearby and those from trusted sources. I've since moved on, so if you don't care, I don't either. I am using a different library and different sensor which seem to be working for me more consistently now.

ederjc commented 2 months ago

I think now I understand what you were trying to do.

I am not an expert for weather measurements, but I tried to reproduce your observations and had a similar experience: my sensor values are not equal to air pressure measurements of nearby weather stations. I was measuring 954.0 hPa while weather.com is reporting 1018.6 hPa. So I hooked up another sensor from a different vendor and got similar results. It reports 953.9 hPa.

I researched a bit on the topic and appearently local weather stations do a sea-level adjustment on their pressure measurements to ensure comparability between locations at different heights.

Doing this sea-level-adjustment for my measurements using the barometric formula and my height of ~551m leads to ~1013.2 hPa which is very close to the reported 1018.6 hPa. There are many assumptions (including the exact height) in the barometric formula, I assume that's where the remaining error of 5.4 hPa comes from.

Completely understand that this might not be relevant for you anymore, still wanted to look into it.

Best regards Julian

github-actions[bot] commented 1 month ago

This issue is stale because it has been open more than 6 weeks with no activity. Please comment on this issue if it's still relevant or it will be closed automatically after 1 week.

github-actions[bot] commented 3 weeks ago

This issue was closed because it has been stalled for 1 week with no activity.