Repository navigation
DEV-1102: sign-extend the BMP581 temperature - #310
Merged
Merged
Conversation
The BMP581's compensated temperature is a signed 24-bit value over 65536, but both driver paths receive it as UINT24 and used it unsigned, so a reading below 0 degC came out as ~255 degC. Danny's fridge test exported 254.33-256.00 degC for every sub-zero sample. CalibDetailsBmp581.signExtend24 now reads the field as two's complement, in calibratePressureSensorData (the ShimmerObject / Consensys path) and in SensorBMP581's own decode. Pressure stays unsigned; UNCAL keeps the raw register value, as for BMP390. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes DEV-1102: BMP581 temperatures below 0 °C decode as about 255 °C.
Symptom
In a fridge test on two Shimmer3Rs (CE2F and D8A6, both fitted with a BMP581), the Consensys SD exports show 254.33–256.00 °C for every sample below freezing. That's 8.1% of CE2F's samples and 1.8% of D8A6's. Read as signed, the traces are continuous and bottom out at −1.67 °C and −0.37 °C.
Cause
The BMP581's compensated temperature is a signed 24-bit value in units of 1/65536 °C; pressure is unsigned, in units of 1/64 Pa (Bosch
bmp5.c). Both driver paths receive the temperature asUINT24and used it unsigned:ShimmerObject, the path Consensys uses: it reads signal0x1Aon Shimmer3R as"u24", thenCalibDetailsBmp581.calibratePressureSensorDatacomputesUT / 65536.0.SensorBMP581:channelBmp581TempisUINT24, andprocessDatacomputesraw / 65536.0.Fix
CalibDetailsBmp581.signExtend24()reads the field as two's complement. It's idempotent, so an already-signed value passes through unchanged.Testing
API_00013_Bmp581TemperatureSignTest(5 tests) covers:0xFE5556→ −1.667 °C (previously 254.33 °C);0x800000→ −128 °C and0x7FFFFF→ about 128 °C;cd ShimmerDriver && ./gradlew test: 108 tests, 0 failures.ShimmerDriverPC:./gradlew buildpasses. It was run through a junction namedShimmer-Java-Android-API, because the module'ssettings.gradleresolves siblings by that folder name.API_00005_Suite_ShimmerDriver../gradlew testruns it regardless, and DEV-1095: anchor each SD file on its first packet's own counter time #309 edits the same suite lines.Effect on output
Re-exporting affected recordings from their SD files gives correct negative temperatures. Exports made before the fix keep the wrong values.
Related
compensateBmp581appliess24, with an existing sub-zero test). It only needs its comment corrected: DEV-1102: correct the claim that the Java driver agrees on BMP581 sign shimmer-web-sdk#162.🤖 Generated with Claude Code