Skip to content

feat: Implement CCS811 sensor#3363

Merged
marcnause merged 11 commits into
fossasia:mainfrom
rahul31124:gas_sensor
Jun 27, 2026
Merged

feat: Implement CCS811 sensor#3363
marcnause merged 11 commits into
fossasia:mainfrom
rahul31124:gas_sensor

Conversation

@rahul31124

@rahul31124 rahul31124 commented Jun 24, 2026

Copy link
Copy Markdown
Member

Fixes #2990

Changes

  • Added support for the CCS811 gas sensor.
  • Implemented and verified CCS811 communication on real sensor.

Screenshots / Recordings

Record_2026-06-24-14-31-35_dbe5c1a2b66d718c881a98a90d7b17a3.mp4

Checklist:

  • No hard coding: I have used values from constants.dart or localization files instead of hard-coded values.
  • No end of file edits: No modifications done at end of resource files.
  • Code reformatting: I have formatted the code using dart format or the IDE formatter.
  • Code analysis: My code passes checks run in flutter analyze and tests run in flutter test.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry @rahul31124, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@rahul31124 rahul31124 requested a review from marcnause June 24, 2026 10:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread lib/view/gas_sensor_config_screen.dart Outdated
Comment thread lib/providers/gas_sensor_state_provider.dart Outdated
Comment thread lib/providers/gas_sensor_state_provider.dart Outdated
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Build Status

Build successful. APKs to test: https://github.com/fossasia/pslab-app/actions/runs/28230225704/artifacts/7902420535.

Screenshots

Android Screenshots
iPhone Screenshots
iPad Screenshots

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment thread lib/providers/gas_sensor_config_provider.dart Outdated
Comment thread lib/view/gas_sensor_screen.dart Outdated
Comment thread lib/view/gas_sensor_screen.dart Outdated

@Yugesh-Kumar-S Yugesh-Kumar-S left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@rahul31124

Copy link
Copy Markdown
Member Author

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

@marcnause

Copy link
Copy Markdown
Contributor

@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

@rahul31124

Copy link
Copy Markdown
Member Author

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?

@marcnause

Copy link
Copy Markdown
Contributor

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.

@rahul31124

Copy link
Copy Markdown
Member Author

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!

@marcnause marcnause merged commit 8eeb04c into fossasia:main Jun 27, 2026
16 checks passed
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.

Add support for sensor CCS811

4 participants