Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 73 additions & 1 deletion tests/scenarios/board_temperature_comparison.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,80 @@ tests:
expect_true: true
mode: [hardware]

- name: "Calibrate all sensors to WSEN-HIDS reference"
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)

# Use WSEN-HIDS as the reference thermometer
from wsen_hids.device import WSEN_HIDS
ref = WSEN_HIDS(i2c)
ref_t = ref.temperature()

# Read raw values from each sensor before calibration
from hts221.device import HTS221
hts = HTS221(i2c)
hts.poweroff()
sleep_ms(20)
hts.poweron()
sleep_ms(50)
hts_t = hts.temperature()

from wsen_pads.device import WSEN_PADS
pads = WSEN_PADS(i2c)
pads_t = pads.temperature()
Comment thread
nedseb marked this conversation as resolved.
Outdated

from lis2mdl.device import LIS2MDL
mag = LIS2MDL(i2c)
mag_t = mag.read_temperature_c()

print('--- Before calibration ---')
print(' WSEN-HIDS (ref): ' + str(round(ref_t, 2)) + ' C')
print(' HTS221: ' + str(round(hts_t, 2)) + ' C')
print(' WSEN-PADS: ' + str(round(pads_t, 2)) + ' C')
print(' LIS2MDL: ' + str(round(mag_t, 2)) + ' C')

spread_before = max(hts_t, pads_t, mag_t, ref_t) - min(hts_t, pads_t, mag_t, ref_t)
print(' Spread: ' + str(round(spread_before, 2)) + ' C')

# Calibrate each sensor using two-point method
# Use a synthetic second point: measured+10 -> ref+10
hts.calibrate_temperature(ref_t, hts_t, ref_t + 10.0, hts_t + 10.0)
pads.calibrate_temperature(ref_t, pads_t, ref_t + 10.0, pads_t + 10.0)
mag.calibrate_temperature(ref_t, mag_t, ref_t + 10.0, mag_t + 10.0)
Comment thread
nedseb marked this conversation as resolved.
Outdated

# Re-read after calibration
sleep_ms(50)
ref_t2 = ref.temperature()
hts_t2 = hts.temperature()
pads_t2 = pads.temperature()
mag_t2 = mag.read_temperature_c()

print('--- After calibration ---')
print(' WSEN-HIDS (ref): ' + str(round(ref_t2, 2)) + ' C')
print(' HTS221: ' + str(round(hts_t2, 2)) + ' C')
print(' WSEN-PADS: ' + str(round(pads_t2, 2)) + ' C')
print(' LIS2MDL: ' + str(round(mag_t2, 2)) + ' C')

spread_after = max(hts_t2, pads_t2, mag_t2, ref_t2) - min(hts_t2, pads_t2, mag_t2, ref_t2)
print(' Spread: ' + str(round(spread_after, 2)) + ' C')

# After calibration, spread should be < 2°C
result = spread_after < 2.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 ?"
prompt: "Les températures calibrées sont-elles cohérentes entre elles et avec l'ambiance ?"
Comment thread
nedseb marked this conversation as resolved.
Outdated
expect_true: true
mode: [hardware]
Loading