File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -236,12 +236,23 @@ def read_temperature_raw(self) -> int:
236236 return v - 0x10000 if (v & 0x8000 ) else v
237237
238238 def read_temperature_c (self ) -> float :
239- """Temperature in °C (8 LSB/°C + offset)."""
239+ """Temperature in °C (8 LSB/°C + empirical offset).
240+
241+ The LIS2MDL temperature sensor has no guaranteed absolute zero
242+ point (see datasheet Table 4). The offset defaults to 25 °C
243+ based on empirical observation (confirmed by Zephyr RTOS
244+ PR #35912). Use ``set_temp_offset()`` to calibrate against a
245+ reference thermometer.
246+ """
240247 return self ._temp_offset + self .read_temperature_raw () / LIS2MDL_TEMP_SENSITIVITY
241248
242- def set_temp_offset (self , offset ):
243- """Set the temperature offset in °C for calibration."""
244- self ._temp_offset = offset
249+ def set_temp_offset (self , offset_c ):
250+ """Set the temperature offset in °C for calibration.
251+
252+ Args:
253+ offset_c: offset value in degrees Celsius (default is 25).
254+ """
255+ self ._temp_offset = float (offset_c )
245256
246257 # --- IDENTITY & HARDWARE OFFSETS ---
247258
Original file line number Diff line number Diff line change 6767 - name : " Read temperature returns float"
6868 action : call
6969 method : read_temperature_c
70- expect_not_none : true
70+ expect : 25.0
7171 mode : [mock]
7272
7373 - name : " Magnitude in plausible range"
You can’t perform that action at this time.
0 commit comments