Skip to content

Commit f605cee

Browse files
committed
tests: Add ISM330DL temperature to multidriver comparison scenario.
1 parent cd0a4ce commit f605cee

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

tests/scenarios/board_temperature_comparison.yaml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ drivers:
1010
- wsen-hids
1111
- wsen-pads
1212
- lis2mdl
13+
- ism330dl
1314

1415
tests:
1516
- name: "Read all temperature sensors"
@@ -20,6 +21,7 @@ tests:
2021
sys.path.insert(0, '/remote/wsen-hids')
2122
sys.path.insert(0, '/remote/wsen-pads')
2223
sys.path.insert(0, '/remote/lis2mdl')
24+
sys.path.insert(0, '/remote/ism330dl')
2325
2426
from machine import I2C
2527
from time import sleep_ms
@@ -52,6 +54,11 @@ tests:
5254
mag = LIS2MDL(i2c)
5355
temps['LIS2MDL'] = mag.read_temperature_c()
5456
57+
# ISM330DL (auxiliary, offset not guaranteed by datasheet)
58+
from ism330dl.device import ISM330DL
59+
imu = ISM330DL(i2c)
60+
temps['ISM330DL'] = imu.temperature_c()
61+
5562
# Print comparison table
5663
print('--- Temperature Comparison ---')
5764
for name, t in temps.items():
@@ -108,6 +115,7 @@ tests:
108115
sys.path.insert(0, '/remote/wsen-hids')
109116
sys.path.insert(0, '/remote/wsen-pads')
110117
sys.path.insert(0, '/remote/lis2mdl')
118+
sys.path.insert(0, '/remote/ism330dl')
111119
112120
from machine import I2C
113121
from time import sleep_ms
@@ -131,6 +139,9 @@ tests:
131139
from lis2mdl.device import LIS2MDL
132140
mag = LIS2MDL(i2c)
133141
142+
from ism330dl.device import ISM330DL
143+
imu = ISM330DL(i2c)
144+
134145
# Read reference just before each sensor to minimize drift
135146
ref_t = ref.temperature()
136147
hts_t = hts.temperature()
@@ -141,34 +152,41 @@ tests:
141152
ref_t3 = ref.temperature()
142153
mag_t = mag.read_temperature_c()
143154
155+
ref_t4 = ref.temperature()
156+
imu_t = imu.temperature_c()
157+
144158
print('--- Before offset alignment ---')
145159
print(' WSEN-HIDS (ref): ' + str(round(ref_t, 2)) + ' C')
146160
print(' HTS221: ' + str(round(hts_t, 2)) + ' C')
147161
print(' WSEN-PADS: ' + str(round(pads_t, 2)) + ' C')
148162
print(' LIS2MDL: ' + str(round(mag_t, 2)) + ' C')
163+
print(' ISM330DL: ' + str(round(imu_t, 2)) + ' C')
149164
150-
spread_before = max(hts_t, pads_t, mag_t, ref_t) - min(hts_t, pads_t, mag_t, ref_t)
165+
spread_before = max(hts_t, pads_t, mag_t, imu_t, ref_t) - min(hts_t, pads_t, mag_t, imu_t, ref_t)
151166
print(' Spread: ' + str(round(spread_before, 2)) + ' C')
152167
153168
# Apply offset to align each sensor to the reference reading
154169
hts.set_temp_offset(ref_t - hts_t)
155170
pads.set_temp_offset(ref_t2 - pads_t)
156171
mag.set_temp_offset(ref_t3 - mag_t)
172+
imu.set_temp_offset(ref_t4 - imu_t)
157173
158174
# Re-read after offset alignment
159175
sleep_ms(50)
160-
ref_t4 = ref.temperature()
176+
ref_t5 = ref.temperature()
161177
hts_t2 = hts.temperature()
162178
pads_t2 = pads.temperature()
163179
mag_t2 = mag.read_temperature_c()
180+
imu_t2 = imu.temperature_c()
164181
165182
print('--- After offset alignment ---')
166-
print(' WSEN-HIDS (ref): ' + str(round(ref_t4, 2)) + ' C')
183+
print(' WSEN-HIDS (ref): ' + str(round(ref_t5, 2)) + ' C')
167184
print(' HTS221: ' + str(round(hts_t2, 2)) + ' C')
168185
print(' WSEN-PADS: ' + str(round(pads_t2, 2)) + ' C')
169186
print(' LIS2MDL: ' + str(round(mag_t2, 2)) + ' C')
187+
print(' ISM330DL: ' + str(round(imu_t2, 2)) + ' C')
170188
171-
spread_after = max(hts_t2, pads_t2, mag_t2, ref_t4) - min(hts_t2, pads_t2, mag_t2, ref_t4)
189+
spread_after = max(hts_t2, pads_t2, mag_t2, imu_t2, ref_t5) - min(hts_t2, pads_t2, mag_t2, imu_t2, ref_t5)
172190
print(' Spread: ' + str(round(spread_after, 2)) + ' C')
173191
174192
# After alignment, spread should be < 2°C

0 commit comments

Comments
 (0)