hts221: Auto-trigger one-shot conversion in power-down mode.#68
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the HTS221 driver to automatically trigger a fresh one-shot measurement when reading temperature/humidity while the sensor is in power-down (or configured for one-shot), and adds a combined read() API to avoid double conversions.
Changes:
- Add
_is_power_down(),_is_one_shot_mode(),trigger_one_shot(), and_ensure_data()helpers and call_ensure_data()fromtemperature()/humidity(). - Add
read()that returns(humidity, temperature)after a single trigger; makeget()delegate toread(). - Add CTRL_REG1/CTRL_REG2/STATUS_REG bit constants in
const.py.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/hts221/hts221/device.py | Adds one-shot auto-trigger logic, ensures fresh data in power-down/one-shot, and introduces a single-trigger read() API. |
| lib/hts221/hts221/const.py | Introduces bitmask constants used for mode/status handling in the driver. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Mar 13, 2026
0551cb7 to
54b9e0c
Compare
|
🎉 This PR is included in version 0.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
Closes #44 (for HTS221).
_is_power_down(),_is_one_shot_mode(),trigger_one_shot(), and_ensure_data()helperstemperature()andhumidity()now auto-trigger a one-shot conversion when the sensor is in power-down or one-shot modetrigger_one_shot()uses read-modify-write on CTRL_REG2 to preserve HEATER/BOOT bitsread()method that returns(humidity, temperature)with a single trigger (avoids double conversion)get()now delegates toread()for backward compatibilityconst.pypoweroff()thentemperature()verifies auto-trigger worksFollows the same
_ensure_data()pattern as WSEN-PADS and WSEN-HIDS.Test plan
Mock test results
Hardware test results
ruff checkpasses