Skip to content

Commit 8bde63a

Browse files
committed
tests: Add multidriver temperature comparison scenario for calibration.
1 parent 6c84c83 commit 8bde63a

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
type: board
2+
name: "Temperature comparison (all sensors)"
3+
4+
i2c:
5+
id: 1
6+
7+
tests:
8+
- name: "Read all temperature sensors"
9+
action: hardware_script
10+
script: |
11+
import sys
12+
sys.path.insert(0, '/flash/lib/hts221')
13+
sys.path.insert(0, '/flash/lib/wsen-hids')
14+
sys.path.insert(0, '/flash/lib/wsen-pads')
15+
sys.path.insert(0, '/flash/lib/lis2mdl')
16+
sys.path.insert(0, '/flash/lib/bq27441')
17+
18+
from machine import I2C
19+
from time import sleep_ms
20+
21+
i2c = I2C(1)
22+
23+
temps = {}
24+
25+
# HTS221
26+
from hts221.device import HTS221
27+
hts = HTS221(i2c)
28+
hts.poweroff()
29+
sleep_ms(20)
30+
hts.poweron()
31+
sleep_ms(50)
32+
temps['HTS221'] = hts.temperature()
33+
34+
# WSEN-HIDS
35+
from wsen_hids.device import WSEN_HIDS
36+
hids = WSEN_HIDS(i2c)
37+
temps['WSEN-HIDS'] = hids.temperature()
38+
39+
# WSEN-PADS
40+
from wsen_pads.device import WSEN_PADS
41+
pads = WSEN_PADS(i2c)
42+
temps['WSEN-PADS'] = pads.temperature()
43+
44+
# LIS2MDL
45+
from lis2mdl.device import LIS2MDL
46+
mag = LIS2MDL(i2c)
47+
temps['LIS2MDL'] = mag.read_temperature_c()
48+
49+
# BQ27441
50+
from bq27441.device import BQ27441, TempMeasureType
51+
bq = BQ27441(i2c)
52+
raw = bq.temperature(TempMeasureType(1))
53+
temps['BQ27441'] = raw / 10.0 - 273.15
54+
55+
# Print comparison table
56+
print('--- Temperature Comparison ---')
57+
for name, t in temps.items():
58+
print(f' {name:12s}: {t:6.2f} C')
59+
60+
# Check all in plausible range
61+
all_ok = all(5.0 <= t <= 50.0 for t in temps.values())
62+
63+
# Check spread between dedicated thermometers
64+
dedicated = [temps['HTS221'], temps['WSEN-HIDS']]
65+
spread = max(dedicated) - min(dedicated)
66+
print(f' Spread (HTS221 vs WSEN-HIDS): {spread:.2f} C')
67+
68+
result = all_ok and spread < 3.0
69+
expect_true: true
70+
mode: [hardware]
71+
72+
- name: "Temperature spread with barometer"
73+
action: hardware_script
74+
script: |
75+
import sys
76+
sys.path.insert(0, '/flash/lib/hts221')
77+
sys.path.insert(0, '/flash/lib/wsen-pads')
78+
79+
from machine import I2C
80+
from time import sleep_ms
81+
82+
i2c = I2C(1)
83+
84+
from hts221.device import HTS221
85+
hts = HTS221(i2c)
86+
hts.poweroff()
87+
sleep_ms(20)
88+
hts.poweron()
89+
sleep_ms(50)
90+
t_hts = hts.temperature()
91+
92+
from wsen_pads.device import WSEN_PADS
93+
pads = WSEN_PADS(i2c)
94+
t_pads = pads.temperature()
95+
96+
spread = abs(t_hts - t_pads)
97+
print(f' HTS221: {t_hts:.2f} C | WSEN-PADS: {t_pads:.2f} C | Spread: {spread:.2f} C')
98+
result = spread < 5.0
99+
expect_true: true
100+
mode: [hardware]
101+
102+
- name: "Temperature values feel correct"
103+
action: manual
104+
prompt: "Les temperatures lues sont-elles coherentes entre elles et avec l'ambiance ?"
105+
expect_true: true
106+
mode: [hardware]

0 commit comments

Comments
 (0)