Skip to content

tests: Add calibration test to temperature comparison.#116

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

tests: Add calibration test to temperature comparison.#116
nedseb merged 2 commits intomainfrom
fix/temp-comparison-calibration

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 14, 2026

Summary

  • Add a new hardware test that calibrates all temperature sensors (HTS221, WSEN-PADS, LIS2MDL) against WSEN-HIDS as reference
  • Uses two-point calibration with a synthetic second point (measured + 10 → ref + 10)
  • Prints before/after comparison table and spread
  • Verifies that post-calibration spread is < 2°C (vs < 8°C before calibration)
  • Update manual check prompt to reference calibrated values

Closes #117

Test plan

Hardware test (STeaMi board)

python3 -m pytest tests/ --port /dev/ttyACM0 -k "Temperature and comparison" -s -v
  • All mock tests pass (54/54, this scenario is hardware-only)
  • Hardware validation on STeaMi board

Test results

$ python3 -m pytest tests/ --port /dev/ttyACM0 -k "Temperature and comparison" -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 168 items / 164 deselected / 4 selected                                                                                  

tests/test_scenarios.py::test_scenario[Temperature comparison (all sensors)/Read all temperature sensors/hardware] --- Temperature Comparison ---
  LIS2MDL     : 25.12 C
  WSEN-HIDS   : 28.43 C
  WSEN-PADS   : 26.86 C
  HTS221      : 28.54 C
  Spread: 1.68 C
PASSED
tests/test_scenarios.py::test_scenario[Temperature comparison (all sensors)/Temperature spread with barometer/hardware] HTS221: 28.54 C  |  WSEN-PADS: 26.86 C  |  Spread: 1.68 C
PASSED
tests/test_scenarios.py::test_scenario[Temperature comparison (all sensors)/Calibrate all sensors to WSEN-HIDS reference/hardware] --- Before calibration ---
  WSEN-HIDS (ref): 28.24 C
  HTS221:          28.39 C
  WSEN-PADS:       26.85 C
  LIS2MDL:         25.12 C
  Spread: 3.26 C
--- After calibration ---
  WSEN-HIDS (ref): 28.43 C
  HTS221:          28.28 C
  WSEN-PADS:       28.24 C
  LIS2MDL:         28.24 C
  Spread: 0.19 C
PASSED
tests/test_scenarios.py::test_scenario[Temperature comparison (all sensors)/Temperature values feel correct/hardware]   [MANUAL] Les températures calibrées sont-elles cohérentes entre elles et avec l'ambiance ? [Entree=oui / Echap=non] 
PASSED

=========================================== 4 passed, 164 deselected in 86.26s (0:01:26) ===========================================

@nedseb nedseb requested a review from Copilot March 14, 2026 12:30
@nedseb nedseb self-assigned this Mar 14, 2026
@nedseb nedseb added enhancement New feature or request test labels 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 new hardware-only calibration validation step to the existing board-level temperature comparison scenario, using WSEN-HIDS as the reference to calibrate the other onboard temperature sensors.

Changes:

  • Adds a hardware_script step to calibrate HTS221, WSEN-PADS, and LIS2MDL against WSEN-HIDS and assert a tighter post-calibration spread.
  • Prints before/after temperature readings and spread for easier manual inspection.
  • Updates the manual verification prompt to reference calibrated temperatures.

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

Comment thread tests/scenarios/board_temperature_comparison.yaml Outdated
Comment thread tests/scenarios/board_temperature_comparison.yaml Outdated
Comment thread tests/scenarios/board_temperature_comparison.yaml Outdated
@nedseb
Copy link
Copy Markdown
Contributor Author

nedseb commented Mar 14, 2026

Addressed Copilot review:

  • Drift temporel : la référence WSEN-HIDS est relue juste avant chaque capteur pour minimiser la dérive
  • Gain = 1.0 : remplacé calibrate_temperature() par set_temp_offset() puisqu'on ne valide que l'offset (pas de second point de température disponible). Renommé le test en "Offset-align" pour refléter ce qui est réellement testé
  • Prompt trompeur : reformulé sans supposer que l'étape de calibration a été exécutée

@nedseb nedseb merged commit 73af7bd into main Mar 14, 2026
3 checks passed
@nedseb nedseb deleted the fix/temp-comparison-calibration branch March 14, 2026 12:43
@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 test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: Add calibration validation to temperature comparison.

2 participants