modules: sensor: add warmup delays to prevent CCS811 early read failures#17
Merged
Merged
Conversation
58003b1 to
562ead8
Compare
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>
562ead8 to
2621f04
Compare
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Kconfig.sensorto enable sensor warmup (SENSOR_MODULE_WARMUP_ENABLE) and specify warmup durations for CCS811, BME280, and HM3301 sensors (SENSOR_MODULE_CCS811_WARMUP_MS, etc.).sensor_state_objectinsensor_module.cto track initialization time and per-sensor warmup completion status when warmup is enabled. [1] [2]Sensor reading and state machine updates:
Fixes: #16