Skip to content

Commit 73af7bd

Browse files
committed
tests: Address Copilot review on PR #116.
1 parent 1731cc9 commit 73af7bd

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

tests/scenarios/board_temperature_comparison.yaml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ tests:
100100
expect_true: true
101101
mode: [hardware]
102102

103-
- name: "Calibrate all sensors to WSEN-HIDS reference"
103+
- name: "Offset-align all sensors to WSEN-HIDS reference"
104104
action: hardware_script
105105
script: |
106106
import sys
@@ -114,29 +114,34 @@ tests:
114114
115115
i2c = I2C(1)
116116
117-
# Use WSEN-HIDS as the reference thermometer
117+
# Initialize all sensors
118118
from wsen_hids.device import WSEN_HIDS
119119
ref = WSEN_HIDS(i2c)
120-
ref_t = ref.temperature()
121120
122-
# Read raw values from each sensor before calibration
123121
from hts221.device import HTS221
124122
hts = HTS221(i2c)
125123
hts.poweroff()
126124
sleep_ms(20)
127125
hts.poweron()
128126
sleep_ms(50)
129-
hts_t = hts.temperature()
130127
131128
from wsen_pads.device import WSEN_PADS
132129
pads = WSEN_PADS(i2c)
133-
pads_t = pads.temperature()
134130
135131
from lis2mdl.device import LIS2MDL
136132
mag = LIS2MDL(i2c)
133+
134+
# Read reference just before each sensor to minimize drift
135+
ref_t = ref.temperature()
136+
hts_t = hts.temperature()
137+
138+
ref_t2 = ref.temperature()
139+
pads_t = pads.temperature()
140+
141+
ref_t3 = ref.temperature()
137142
mag_t = mag.read_temperature_c()
138143
139-
print('--- Before calibration ---')
144+
print('--- Before offset alignment ---')
140145
print(' WSEN-HIDS (ref): ' + str(round(ref_t, 2)) + ' C')
141146
print(' HTS221: ' + str(round(hts_t, 2)) + ' C')
142147
print(' WSEN-PADS: ' + str(round(pads_t, 2)) + ' C')
@@ -145,35 +150,34 @@ tests:
145150
spread_before = max(hts_t, pads_t, mag_t, ref_t) - min(hts_t, pads_t, mag_t, ref_t)
146151
print(' Spread: ' + str(round(spread_before, 2)) + ' C')
147152
148-
# Calibrate each sensor using two-point method
149-
# Use a synthetic second point: measured+10 -> ref+10
150-
hts.calibrate_temperature(ref_t, hts_t, ref_t + 10.0, hts_t + 10.0)
151-
pads.calibrate_temperature(ref_t, pads_t, ref_t + 10.0, pads_t + 10.0)
152-
mag.calibrate_temperature(ref_t, mag_t, ref_t + 10.0, mag_t + 10.0)
153+
# Apply offset to align each sensor to the reference reading
154+
hts.set_temp_offset(ref_t - hts_t)
155+
pads.set_temp_offset(ref_t2 - pads_t)
156+
mag.set_temp_offset(ref_t3 - mag_t)
153157
154-
# Re-read after calibration
158+
# Re-read after offset alignment
155159
sleep_ms(50)
156-
ref_t2 = ref.temperature()
160+
ref_t4 = ref.temperature()
157161
hts_t2 = hts.temperature()
158162
pads_t2 = pads.temperature()
159163
mag_t2 = mag.read_temperature_c()
160164
161-
print('--- After calibration ---')
162-
print(' WSEN-HIDS (ref): ' + str(round(ref_t2, 2)) + ' C')
165+
print('--- After offset alignment ---')
166+
print(' WSEN-HIDS (ref): ' + str(round(ref_t4, 2)) + ' C')
163167
print(' HTS221: ' + str(round(hts_t2, 2)) + ' C')
164168
print(' WSEN-PADS: ' + str(round(pads_t2, 2)) + ' C')
165169
print(' LIS2MDL: ' + str(round(mag_t2, 2)) + ' C')
166170
167-
spread_after = max(hts_t2, pads_t2, mag_t2, ref_t2) - min(hts_t2, pads_t2, mag_t2, ref_t2)
171+
spread_after = max(hts_t2, pads_t2, mag_t2, ref_t4) - min(hts_t2, pads_t2, mag_t2, ref_t4)
168172
print(' Spread: ' + str(round(spread_after, 2)) + ' C')
169173
170-
# After calibration, spread should be < 2°C
174+
# After alignment, spread should be < 2°C
171175
result = spread_after < 2.0
172176
expect_true: true
173177
mode: [hardware]
174178

175179
- name: "Temperature values feel correct"
176180
action: manual
177-
prompt: "Les températures calibrées sont-elles cohérentes entre elles et avec l'ambiance ?"
181+
prompt: "Les températures lues sont-elles cohérentes entre elles et avec l'ambiance ?"
178182
expect_true: true
179183
mode: [hardware]

0 commit comments

Comments
 (0)