Skip to content

modules: sensor: add warmup delays to prevent CCS811 early read failures#17

Merged
nmpluta merged 1 commit into
mainfrom
16-initially-fetching-data-from-ccs811-fails
Sep 6, 2025
Merged

modules: sensor: add warmup delays to prevent CCS811 early read failures#17
nmpluta merged 1 commit into
mainfrom
16-initially-fetching-data-from-ccs811-fails

Conversation

@nmpluta
Copy link
Copy Markdown
Owner

@nmpluta nmpluta commented Sep 6, 2025

This pull request adds support for configurable sensor warmup periods in the sensor module, allowing certain sensors to stabilize before their readings are used. The changes include new Kconfig options for enabling warmup and setting warmup durations per sensor, as well as logic in the sensor state machine to track and enforce warmup completion before reading or publishing sensor data.

Sensor warmup configuration and logic:

  • Added new Kconfig options in Kconfig.sensor to enable sensor warmup (SENSOR_MODULE_WARMUP_ENABLE) and specify warmup durations for CCS811, BME280, and HM3301 sensors (SENSOR_MODULE_CCS811_WARMUP_MS, etc.).
  • Extended the sensor_state_object in sensor_module.c to track initialization time and per-sensor warmup completion status when warmup is enabled. [1] [2]
  • On initialization, now records the startup time and resets warmup completion flags for all sensors.

Sensor reading and state machine updates:

  • Modified the reading logic to skip sensors that have not completed their warmup period, and to only count sensors as enabled if their warmup is done. [1] [2]
  • Added helper functions to check warmup status and compute elapsed warmup time for each sensor, marking sensors as ready when their configured warmup period has passed. [1] [2]

Fixes: #16

@nmpluta nmpluta requested a review from Copilot September 6, 2025 18:15
@nmpluta nmpluta linked an issue Sep 6, 2025 that may be closed by this pull request

This comment was marked as outdated.

@nmpluta nmpluta force-pushed the 16-initially-fetching-data-from-ccs811-fails branch 2 times, most recently from 58003b1 to 562ead8 Compare September 6, 2025 18:32
CCS811 sensor needs 5-second stabilization after init before valid readings.
Added configurable per-sensor warmup periods with tracking to skip reads
during warmup.

- CCS811: 5000ms warmup, BME280/HM3301: 100ms
- Individual sensor warmup completion tracking
- Partial data handling during warmup

The change fixes the regression introduced in PR #15 where removing the
global warmup delay caused CCS811 to fail with -EAGAIN during the first
few read attempts after system initialization.

Refs: #16

Signed-off-by: Natalia Pluta <pluta.natalia.m@gmail.com>
@nmpluta nmpluta force-pushed the 16-initially-fetching-data-from-ccs811-fails branch from 562ead8 to 2621f04 Compare September 6, 2025 18:38
@nmpluta nmpluta requested a review from Copilot September 6, 2025 18:38
@nmpluta nmpluta merged commit cc1ac5c into main Sep 6, 2025
10 checks passed
@nmpluta nmpluta deleted the 16-initially-fetching-data-from-ccs811-fails branch September 6, 2025 18:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds configurable sensor warmup periods to prevent early read failures, particularly for CCS811 sensors that require stabilization time after initialization. The implementation includes new Kconfig options for warmup configuration and state machine logic to track and enforce warmup completion before reading sensor data.

  • Adds Kconfig options for enabling sensor warmup and configuring warmup durations per sensor type
  • Extends sensor state machine to track initialization time and warmup completion status
  • Modifies sensor reading logic to skip sensors that haven't completed warmup and handle partial reads gracefully

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
app/src/modules/sensor/sensor_module.c Main implementation with warmup tracking, state machine updates, and sensor reading logic
app/src/modules/sensor/Kconfig.sensor New configuration options for warmup enabling and per-sensor warmup durations
app/src/modules/controller/controller_module.c Macro rename for consistency (no functional change)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread app/src/modules/sensor/sensor_module.c
Comment thread app/src/modules/sensor/sensor_module.c
Comment thread app/src/modules/sensor/sensor_module.c
Comment thread app/src/modules/sensor/sensor_module.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initially fetching data from ccs811 fails

2 participants