-
Notifications
You must be signed in to change notification settings - Fork 1
tests: Add multidriver temperature comparison scenario for calibration. #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
46b6945
tests: Add multidriver temperature comparison scenario for calibration.
nedseb 7665d7e
tests: Fix multidriver board scenario to mount lib/ via mpremote.
nedseb 57f648f
tests: Fix multidriver temperature scenario after hardware validation.
nedseb 9f7d5ef
tests: Add 25C empirical offset to LIS2MDL in temperature comparison.
nedseb 7e716ec
tests: Use driver read_temperature_c() for LIS2MDL in comparison test.
nedseb 3822374
tests: Address Copilot review on PR #100.
nedseb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| type: board | ||
| name: "Temperature comparison (all sensors)" | ||
|
|
||
| i2c: | ||
| id: 1 | ||
|
|
||
| # List of drivers needed — triggers mounting lib/ via mpremote | ||
| drivers: | ||
| - hts221 | ||
| - wsen-hids | ||
| - wsen-pads | ||
| - lis2mdl | ||
|
|
||
| tests: | ||
| - name: "Read all temperature sensors" | ||
| action: hardware_script | ||
| script: | | ||
| import sys | ||
| sys.path.insert(0, '/remote/hts221') | ||
| sys.path.insert(0, '/remote/wsen-hids') | ||
| sys.path.insert(0, '/remote/wsen-pads') | ||
| sys.path.insert(0, '/remote/lis2mdl') | ||
|
|
||
| from machine import I2C | ||
| from time import sleep_ms | ||
|
|
||
| i2c = I2C(1) | ||
|
|
||
| temps = {} | ||
|
|
||
| # HTS221 | ||
| from hts221.device import HTS221 | ||
| hts = HTS221(i2c) | ||
| hts.poweroff() | ||
| sleep_ms(20) | ||
| hts.poweron() | ||
| sleep_ms(50) | ||
| temps['HTS221'] = hts.temperature() | ||
|
|
||
| # WSEN-HIDS | ||
| from wsen_hids.device import WSEN_HIDS | ||
| hids = WSEN_HIDS(i2c) | ||
| temps['WSEN-HIDS'] = hids.temperature() | ||
|
|
||
| # WSEN-PADS | ||
| from wsen_pads.device import WSEN_PADS | ||
| pads = WSEN_PADS(i2c) | ||
| temps['WSEN-PADS'] = pads.temperature() | ||
|
|
||
| # LIS2MDL (auxiliary, offset not guaranteed by datasheet) | ||
| from lis2mdl.device import LIS2MDL | ||
| mag = LIS2MDL(i2c) | ||
| temps['LIS2MDL'] = mag.read_temperature_c() | ||
|
|
||
|
nedseb marked this conversation as resolved.
|
||
| # Print comparison table | ||
| print('--- Temperature Comparison ---') | ||
| for name, t in temps.items(): | ||
| pad = ' ' * (12 - len(name)) | ||
| print(' ' + name + pad + ': ' + str(round(t, 2)) + ' C') | ||
|
|
||
| # Check thermometers in plausible range (HTS221, WSEN-HIDS, WSEN-PADS) | ||
| thermometers = [temps['HTS221'], temps['WSEN-HIDS'], temps['WSEN-PADS']] | ||
| all_ok = all(5.0 <= t <= 50.0 for t in thermometers) | ||
|
|
||
| # Check spread between thermometers | ||
| spread = max(thermometers) - min(thermometers) | ||
| print(' Spread: ' + str(round(spread, 2)) + ' C') | ||
|
|
||
| result = all_ok and spread < 8.0 | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Temperature spread with barometer" | ||
| action: hardware_script | ||
| script: | | ||
| import sys | ||
| sys.path.insert(0, '/remote/hts221') | ||
| sys.path.insert(0, '/remote/wsen-pads') | ||
|
|
||
| from machine import I2C | ||
| from time import sleep_ms | ||
|
|
||
| i2c = I2C(1) | ||
|
|
||
| from hts221.device import HTS221 | ||
| hts = HTS221(i2c) | ||
| hts.poweroff() | ||
| sleep_ms(20) | ||
| hts.poweron() | ||
| sleep_ms(50) | ||
| t_hts = hts.temperature() | ||
|
|
||
| from wsen_pads.device import WSEN_PADS | ||
| pads = WSEN_PADS(i2c) | ||
| t_pads = pads.temperature() | ||
|
|
||
| spread = abs(t_hts - t_pads) | ||
| print(' HTS221: ' + str(round(t_hts, 2)) + ' C | WSEN-PADS: ' + str(round(t_pads, 2)) + ' C | Spread: ' + str(round(spread, 2)) + ' C') | ||
| result = spread < 5.0 | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Temperature values feel correct" | ||
| action: manual | ||
| prompt: "Les températures lues sont-elles cohérentes entre elles et avec l'ambiance ?" | ||
| expect_true: true | ||
| mode: [hardware] | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.