Added simple barometric formula to MS5611 driver

This commit is contained in:
dario 2024-08-06 11:44:34 +02:00
parent fa30a28b45
commit afe9b83b01
3 changed files with 32 additions and 8 deletions

View File

@ -169,6 +169,10 @@ namespace sta
* @return float The altitude estimate in meters.
*/
float getAltitudeEstimate();
static float getSeaLevel(float pressRef, float altRef);
static float getAltitudeEstimate(float pressure, float sealevel);
private:
/**
* @brief Reset the sensor.

View File

@ -121,6 +121,16 @@ namespace sta
return altitude;
}
float MS56xx::getSeaLevel(float pressRef, float altRef)
{
return pressRef / (std::pow((1 - altRef / 44330), 5.255));
}
float MS56xx::getAltitudeEstimate(float pressure, float sealevel)
{
return 44330 * (1 - std::pow(pressure / sealevel, 1 / 5.255));
}
void MS56xx::readPROM() {
uint8_t buffer[2];

View File

@ -103,6 +103,16 @@ namespace sta
return altitude;
}
float MS56xx::getSeaLevel(float pressRef, float altRef)
{
return pressRef / (std::pow((1 - altRef / 44330), 5.255));
}
float MS56xx::getAltitudeEstimate(float pressure, float sealevel)
{
return 44330 * (1 - std::pow(pressure / sealevel, 1 / 5.255));
}
void MS56xx::readPROM() {
}