Skip to content

wsen-pads: Add two-point temperature calibration.#112

Merged
nedseb merged 2 commits intomainfrom
fix/wsen-pads-temp-calibration
Mar 14, 2026
Merged

wsen-pads: Add two-point temperature calibration.#112
nedseb merged 2 commits intomainfrom
fix/wsen-pads-temp-calibration

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 14, 2026

Summary

  • Add set_temp_offset() and calibrate_temperature() methods to WSEN-PADS driver
  • Apply calibration (gain + offset) in temperature() and read() methods
  • Add mock test scenarios for offset and two-point calibration
  • Improve existing mock tests with precise expected values

Closes #106

Test plan

Mock tests (CI)

python3 -m pytest tests/ -k "wsen-pads and mock" -v

Hardware tests (STeaMi board)

python3 -m pytest tests/ --port /dev/ttyACM0 -k "wsen-pads and hardware" -s -v
  • ruff check passes
  • All mock tests pass (8 tests including 3 new calibration tests)
  • Hardware validation on STeaMi board

Test results

$python3 -m pytest tests/ --port /dev/ttyACM0 -k "wsen-pads and hardware" -s -v

======================================================= test session starts ========================================================
platform linux -- Python 3.13.7, pytest-8.3.5, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/nedjar/sandbox/micropython-steami-lib
configfile: pytest.ini
plugins: typeguard-4.4.2
collected 162 items / 155 deselected / 7 selected                                                                                  

tests/test_scenarios.py::test_scenario[board_i2c_scan/WSEN-PADS device ID (0x5D)/hardware] 0xB3
PASSED
tests/test_scenarios.py::test_scenario[wsen-pads/Verify device ID register/hardware] 0xB3
PASSED
tests/test_scenarios.py::test_scenario[wsen-pads/Read device ID via method/hardware] 0xB3
PASSED
tests/test_scenarios.py::test_scenario[wsen-pads/Read status register/hardware] 0
PASSED
tests/test_scenarios.py::test_scenario[wsen-pads/Pressure in plausible range/hardware] 982.31
PASSED
tests/test_scenarios.py::test_scenario[wsen-pads/Temperature in plausible range/hardware] 25.11
PASSED
tests/test_scenarios.py::test_scenario[wsen-pads/Pressure and temperature feel correct/hardware]   Pressure: 982.27 hPa
  Temperature: 25.13 °C
  [MANUAL] Ces valeurs sont-elles cohérentes (pression ~1013 hPa, température ambiante) ? [Entree=oui / Echap=non] 
PASSED

================================================ 7 passed, 155 deselected in 41.61s ================================================

@nedseb nedseb requested a review from Copilot March 14, 2026 11:01
@nedseb nedseb self-assigned this Mar 14, 2026
@nedseb nedseb added the enhancement New feature or request label Mar 14, 2026
@nedseb nedseb changed the title wsen-pads: Add two-point temperature calibration wsen-pads: Add two-point temperature calibration. 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

Adds a harmonized two-point temperature calibration API to the WSEN-PADS driver and updates mock scenarios to validate calibrated temperature outputs, aligning with the calibration approach used in other drivers.

Changes:

  • Introduces _temp_gain/_temp_offset state plus set_temp_offset() and calibrate_temperature() in WSEN_PADS.
  • Applies gain/offset calibration in both temperature() and the temperature value returned by read().
  • Tightens mock expectations and adds new mock calibration scenarios.

Reviewed changes

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

File Description
lib/wsen-pads/wsen_pads/device.py Adds calibration state + APIs; applies calibration in temperature() and read().
tests/scenarios/wsen_pads.yaml Updates mock expectations and adds scenarios for offset and two-point calibration.

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

Comment thread tests/scenarios/wsen_pads.yaml Outdated
Comment thread lib/wsen-pads/wsen_pads/device.py
@nedseb
Copy link
Copy Markdown
Contributor Author

nedseb commented Mar 14, 2026

Addressed Copilot review:

  • Replaced expect: 25.0 with expect_range: [24.9, 25.1] to avoid float equality brittleness
  • Added mock test for read() to verify temperature calibration is applied in both temperature() and read()

@nedseb nedseb merged commit 4b996cd into main Mar 14, 2026
6 checks passed
@nedseb nedseb deleted the fix/wsen-pads-temp-calibration branch March 14, 2026 12:08
@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

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wsen-pads: Add two-point temperature calibration methods.

2 participants