Skip to content

Commit

Permalink
ms5611: ignore reading 0
Browse files Browse the repository at this point in the history
This prevents publishing a negative pressure which leads to a NAN
altitude estimate further down the line.
  • Loading branch information
julianoes authored and dagar committed Oct 4, 2022
1 parent d22d33e commit e3d730e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/drivers/barometer/ms5611/ms5611.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ MS5611::collect()
return ret;
}

// According to the sensor docs:
// If the conversion is not executed before the ADC read command, or the
// ADC read command is repeated, it will give 0 as the output result.
//
// We have seen 0 during the init phase on I2C, therefore, we add this
// protection in.
if (raw == 0) {
perf_count(_comms_errors);
perf_end(_sample_perf);
return ret;
}

/* handle a measurement */
if (_measure_phase == 0) {

Expand Down

0 comments on commit e3d730e

Please sign in to comment.