Skip to content

fix: add soft reset and NVM copy wait on sensor init#12

Merged
guillaumedelre merged 1 commit into
developfrom
fix/sensor-init-reset
May 14, 2026
Merged

fix: add soft reset and NVM copy wait on sensor init#12
guillaumedelre merged 1 commit into
developfrom
fix/sensor-init-reset

Conversation

@guillaumedelre
Copy link
Copy Markdown
Owner

Summary

  • Add soft reset (0xB6 → 0xE0) at the start of each measurement to ensure the sensor starts from a known state
  • Add _wait_nvm_copy(): polls status register 0xF3 bit 0 until NVM copy completes (up to 5 attempts × 2ms), raises OSError on timeout
  • Add test_nvm_copy_timeout_raises_oserror test

Per Bosch BME280 SensorAPI recommended initialization sequence.

Test plan

  • 20 tests pass: docker compose run --rm test
  • On Pi: sensor reads correctly after power cycle

Per Bosch BME280 SensorAPI spec (section 4.2), perform a soft reset
(0xB6 → 0xE0) before each measurement to ensure a known state, then
poll the status register (0xF3 bit 0) until the NVM copy completes.
Raises OSError if NVM copy does not finish within 5 attempts.
Add test covering the NVM timeout path.

Co-authored-by: agilicode <agilicode@gmail.com>
@guillaumedelre guillaumedelre merged commit 1da97a5 into develop May 14, 2026
3 checks passed
@guillaumedelre guillaumedelre deleted the fix/sensor-init-reset branch May 14, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant