feat: Implement CCS811 sensor#3363
Conversation
There was a problem hiding this comment.
Sorry @rahul31124, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0db329f8a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Build StatusBuild successful. APKs to test: https://github.com/fossasia/pslab-app/actions/runs/28230225704/artifacts/7902420535. Screenshots |
There was a problem hiding this comment.
Pull request overview
This PR adds support for the CCS811 gas sensor to PSLab App, and extends the Gas Sensor instrument with sensor selection (MQ-135 vs CCS811) plus export/playback support via the existing logged-data flow.
Changes:
- Added CCS811 sensor instrument screen/provider and an I2C driver implementation.
- Extended Gas Sensor instrument with configuration (active sensor + update period + optional location) and data export/playback plumbing.
- Hooked Gas Sensor playback into the Logged Data screen and added new localization strings.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/view/sensors_screen.dart | Routes the detected CCS811 sensor to the new CCS811 screen. |
| lib/view/logged_data_screen.dart | Adds Gas Sensor to the list of playable instruments and routes playback to GasSensorScreen. |
| lib/view/gas_sensor_screen.dart | Adds config navigation, recording/export, and playback UI controls for the Gas Sensor instrument. |
| lib/view/gas_sensor_config_screen.dart | New UI for gas sensor settings (update period, active sensor, location inclusion). |
| lib/view/ccs811_screen.dart | New CCS811 instrument UI (raw values + charts + controls). |
| lib/providers/gas_sensor_state_provider.dart | Adds CCS811-backed readings, recording/export data shaping, and playback control to gas sensor provider. |
| lib/providers/gas_sensor_config_provider.dart | New persisted config provider for gas sensor settings. |
| lib/providers/ccs811_provider.dart | New provider managing CCS811 data collection and chart series. |
| lib/models/gas_sensor_config.dart | New config model with JSON serialization helpers. |
| lib/l10n/app_en.arb | Adds strings for CCS811 + gas sensor config/export UX. |
| lib/communication/sensors/ccs811.dart | New CCS811 I2C driver for initialization and raw data reads. |
Yugesh-Kumar-S
left a comment
There was a problem hiding this comment.
Hi @rahul31124 , nice work. I would suggest you to make use of the gauge_widget.dart and instruments_stats.dart for the gas sensor UI. The UI components of gas sensor looks different from other instruments.
|
Hello @Yugesh-Kumar-S , actually, we've decided to modernize the UI, which is why it looks different now. Gradually, we'll update the other instruments with the same design as well. We may also need to create more reusable components to support this |
|
@rahul31124 I just tested your implementation and I noticed that there are multiple graphs in the "Gas Sensor" screen if the user changes to the configuration screen and switches back again. Bildschirmaufzeichnung.vom.2026-06-25.22-11-50.mp4 |
|
Hello @marcnause, I've been thinking about the Gas Sensor instrument, and I wonder if it would be better to support only the MQ-135 . The MQ-135 is a broad gas sensor that responds to many different gases, so labeling the output as CO₂ would not be correct. Our algorithm can estimate CO₂, but if other gases are present, the reading will also change, so it isn't really a direct CO₂ measurement. If someone specifically wants to estimate CO₂ using the MQ-135, that's fine, but since this is a general Gas Sensor instrument, maybe it would be more accurate to display something like Gas Level or Gas Concentration instead of CO₂. I also think we should not add the CCS811 option into this instrument. The CCS811 is a different type of sensor with its own onboard algorithms that reports eCO₂ and TVOC, so mixing it with the MQ-135 in the same instrument could be confusing so let it remains in sensor instrument only What do you think? |
|
After thinking about it a bit, your arguments convinced me. I looked at a few data sheets for the MQ-135 and they used "concentration", but I think "level" would also be fine. It is also a shorter word which may make it easier to fit the UI. |
|
Hello @marcnause, Following your advice, I have removed the gas sensor code changes from this PR. I'll create a separate PR for the gas sensor improvements. This PR now only adds the CCS811 sensor to the sensor screen. Please review it when you have a chance. Thanks! |







-1_instruments_screen.png?raw=true)
-2_nav_drawer.png?raw=true)
-3_accelerometer.png?raw=true)
-4_power_source.png?raw=true)
-5_multimeter.png?raw=true)
-6_wave_generator.png?raw=true)
-7_oscilloscope.png?raw=true)
Fixes #2990
Changes
Screenshots / Recordings
Record_2026-06-24-14-31-35_dbe5c1a2b66d718c881a98a90d7b17a3.mp4
Checklist:
constants.dartor localization files instead of hard-coded values.dart formator the IDE formatter.flutter analyzeand tests run influtter test.