Skip to content

wsen-hids: Fix missing AUTO_INCREMENT bit in multi-byte register reads.#110

Merged
nedseb merged 1 commit intomainfrom
fix/wsen-hids-auto-increment
Mar 14, 2026
Merged

wsen-hids: Fix missing AUTO_INCREMENT bit in multi-byte register reads.#110
nedseb merged 1 commit intomainfrom
fix/wsen-hids-auto-increment

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 14, 2026

Closes #109

Summary

  • Fix _read_regs() to set AUTO_INCREMENT (bit 7) when reading more than 1 byte, as required by the WSEN-HIDS (HTS221-based) I2C protocol
  • Remove redundant | AUTO_INCREMENT in _read_raw_humidity_temperature() (now handled centrally)
  • Update mock register addresses to use auto-increment keys (0xB6, 0xBA, 0xBC, 0xBE)

Bug

Without the auto-increment bit, multi-byte reads return the same byte repeated. This corrupted all 16-bit calibration values (T0_OUT, T1_OUT, H0_T0_OUT, H1_T0_OUT), causing temperature to read ~6°C too low and humidity to be inaccurate.

Hardware validation

Before fix:

HTS221:    T=26.39 C
WSEN-HIDS: T=20.31 C  ← ~6°C too low
WSEN-PADS: T=25.86 C

After fix:

HTS221:    T=31.22 C
WSEN-HIDS: T=31.33 C  ← now matches HTS221
WSEN-PADS: T=29.88 C

Test plan

  • ruff check passes
  • pytest tests/ -k mock — 44/44 passed (no regressions)
  • Hardware: temperature and humidity now match HTS221 within ~0.1°C

@nedseb nedseb requested a review from Copilot March 14, 2026 07:26
@nedseb nedseb self-assigned this Mar 14, 2026
@nedseb nedseb added the bug Something isn't working label Mar 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect multi-byte I2C register reads in the wsen-hids driver by ensuring the sensor’s required AUTO_INCREMENT bit is applied whenever reading more than one byte, which restores correct calibration parsing and accurate temperature/humidity measurements.

Changes:

  • Update WSEN_HIDS._read_regs() to OR in AUTO_INCREMENT for multi-byte reads.
  • Remove redundant AUTO_INCREMENT OR-ing at the call site in _read_raw_humidity_temperature().
  • Update the WSEN-HIDS mock scenario register map to use auto-incremented register keys for multi-byte calibration reads.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/wsen-hids/wsen_hids/device.py Centralizes AUTO_INCREMENT behavior in _read_regs() and simplifies raw read call sites.
tests/scenarios/wsen_hids.yaml Adjusts mock register keys to validate the new multi-byte auto-increment behavior in mock tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nedseb nedseb merged commit 6209722 into main Mar 14, 2026
7 checks passed
@nedseb nedseb deleted the fix/wsen-hids-auto-increment branch March 14, 2026 07:32
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wsen-hids: Fix missing AUTO_INCREMENT bit in multi-byte register reads.

2 participants