@@ -100,8 +100,80 @@ tests:
100100 expect_true : true
101101 mode : [hardware]
102102
103+ - name : " Calibrate all sensors to WSEN-HIDS reference"
104+ action : hardware_script
105+ script : |
106+ import sys
107+ sys.path.insert(0, '/remote/hts221')
108+ sys.path.insert(0, '/remote/wsen-hids')
109+ sys.path.insert(0, '/remote/wsen-pads')
110+ sys.path.insert(0, '/remote/lis2mdl')
111+
112+ from machine import I2C
113+ from time import sleep_ms
114+
115+ i2c = I2C(1)
116+
117+ # Use WSEN-HIDS as the reference thermometer
118+ from wsen_hids.device import WSEN_HIDS
119+ ref = WSEN_HIDS(i2c)
120+ ref_t = ref.temperature()
121+
122+ # Read raw values from each sensor before calibration
123+ from hts221.device import HTS221
124+ hts = HTS221(i2c)
125+ hts.poweroff()
126+ sleep_ms(20)
127+ hts.poweron()
128+ sleep_ms(50)
129+ hts_t = hts.temperature()
130+
131+ from wsen_pads.device import WSEN_PADS
132+ pads = WSEN_PADS(i2c)
133+ pads_t = pads.temperature()
134+
135+ from lis2mdl.device import LIS2MDL
136+ mag = LIS2MDL(i2c)
137+ mag_t = mag.read_temperature_c()
138+
139+ print('--- Before calibration ---')
140+ print(' WSEN-HIDS (ref): ' + str(round(ref_t, 2)) + ' C')
141+ print(' HTS221: ' + str(round(hts_t, 2)) + ' C')
142+ print(' WSEN-PADS: ' + str(round(pads_t, 2)) + ' C')
143+ print(' LIS2MDL: ' + str(round(mag_t, 2)) + ' C')
144+
145+ spread_before = max(hts_t, pads_t, mag_t, ref_t) - min(hts_t, pads_t, mag_t, ref_t)
146+ print(' Spread: ' + str(round(spread_before, 2)) + ' C')
147+
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+
154+ # Re-read after calibration
155+ sleep_ms(50)
156+ ref_t2 = ref.temperature()
157+ hts_t2 = hts.temperature()
158+ pads_t2 = pads.temperature()
159+ mag_t2 = mag.read_temperature_c()
160+
161+ print('--- After calibration ---')
162+ print(' WSEN-HIDS (ref): ' + str(round(ref_t2, 2)) + ' C')
163+ print(' HTS221: ' + str(round(hts_t2, 2)) + ' C')
164+ print(' WSEN-PADS: ' + str(round(pads_t2, 2)) + ' C')
165+ print(' LIS2MDL: ' + str(round(mag_t2, 2)) + ' C')
166+
167+ spread_after = max(hts_t2, pads_t2, mag_t2, ref_t2) - min(hts_t2, pads_t2, mag_t2, ref_t2)
168+ print(' Spread: ' + str(round(spread_after, 2)) + ' C')
169+
170+ # After calibration, spread should be < 2°C
171+ result = spread_after < 2.0
172+ expect_true : true
173+ mode : [hardware]
174+
103175 - name : " Temperature values feel correct"
104176 action : manual
105- prompt : " Les températures lues sont-elles cohérentes entre elles et avec l'ambiance ?"
177+ prompt : " Les températures calibrées sont-elles cohérentes entre elles et avec l'ambiance ?"
106178 expect_true : true
107179 mode : [hardware]
0 commit comments