[hmc5883l] Fix wrong gain for 88uT range#14281
Conversation
The 88uT range gain was 0.073 mG/bit instead of 0.73 mG/bit, causing readings to be 10x too low. The datasheet specifies 1370 LSb/Gauss for this range, giving 1000/1370 = 0.73 mG/bit. Fixes esphome#14276 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file: external_components:
- source: github://pr#14281
components: [hmc5883l]
refresh: 1h(Added by the PR bot) |
There was a problem hiding this comment.
Pull request overview
Fixes incorrect field strength scaling for the HMC5883L 88µT range so reported magnetic field values are no longer 10× too low.
Changes:
- Corrected the gain constant for
HMC5883L_RANGE_88_UTfrom0.073fto0.73f(mG/bit), aligning with the datasheet’s 1370 LSB/Gauss value.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #14281 +/- ##
==========================================
+ Coverage 74.25% 74.28% +0.02%
==========================================
Files 55 55
Lines 11595 11595
Branches 1583 1583
==========================================
+ Hits 8610 8613 +3
+ Misses 2580 2578 -2
+ Partials 405 404 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Memory Impact AnalysisComponents:
This analysis runs automatically when components change. Memory usage is measured from a representative test configuration. |
|
Thanks |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
What does this implement/fix?
Fix incorrect gain value for the 88µT range. The code had
0.073mG/bit instead of0.73mG/bit, causing readings to be 10x too low.The datasheet (page 14) specifies a gain of 1370 LSb/Gauss for this range:
1000 / 1370 = 0.73 mG/bit. All other ranges were correct.Types of changes
Related issue or feature (if applicable):
Pull request in esphome-docs with documentation (if applicable):
N/A
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).