Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CO2 sensing with SCD4X #4601

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Coloradohusky
Copy link
Contributor

This PR adds support for CO2 sensing with the SCD40/SCD41 sensors. These sensors also support temperature and relative humidity.

Currently, it is using startLowPowerPeriodicMeasurement, which has an update interval of ~30 seconds. However, the datasheet mentions a measure_single_shot for lower power use, but says it is limited to SCD41 sensors only. Nonetheless, I tried it on my SCD40 sensor and it appeared to work fine. measure_single_shot also includes a delay of 5 seconds for each use.

Average Supply Current:

  • High Performance Mode: 11 mA
  • Low Power Mode: 2.8 mA
  • Idle Single Shot Mode: 1.1 mA for 1 min and 0.36 mA for 5 min interval
  • Power-Cycled Single Shot Mode: 0.18 mA for 10 min, 0.09 mA for 20 min, 0.03 mA for 1 hour interval

Other than that, the only differences between SCD40 and SCD41 are a wider CO2 interval and higher accuracy.

See SCD4x Low Power Operation and the Datasheet for more information.

Thanks

@fifieldt
Copy link
Contributor

Since this one has temperature and humidity in addition to co2, it looks like it spans our EnvironmentMetrics and AirQualityMetrics. Do you have a sense for how easy it would be to put the co2 in AirQualityMetrics and keep the temp/humidity in EnvironmentMetrics?

@Coloradohusky
Copy link
Contributor Author

Coloradohusky commented Sep 26, 2024

I'll work on moving it over to AirQualityMetrics instead of EnvironmentMetrics - although I noticed that IAQ is also in EnvironmentMetrics, should that be moved as well?

@Coloradohusky
Copy link
Contributor Author

Hm yeah, I'm looking closer at AirQualityModule and it's going to be more involved than I'd hoped - AirQualityModule explicitly wants a Adafruit_PM2.5 sensor (aqi = Adafruit_PM25AQI()) so I'm not entirely sure how to handle that with the addition of the CO2 metric

@fifieldt
Copy link
Contributor

Thanks for the heads up! Will take a look in the next few days.

Previously the module was designed around a single sensor.
This patch brings it into line with the same design as
EnvironmentTelemetry.
@fifieldt
Copy link
Contributor

@Coloradohusky - I hacked together some things over at
https://github.com/fifieldt/meshtastic-firmware/tree/scd4x

It compiles ... but I haven't got it further than that :)

Do you think you'd be able to hack from there and test with your sensor?

@fifieldt fifieldt marked this pull request as draft October 19, 2024 01:06
@fifieldt
Copy link
Contributor

@Coloradohusky , have hacked this a bit more. In theory you might also get a screen on your UI with CO2 readings too. Can you test & improve? =D

@Coloradohusky
Copy link
Contributor Author

Was checking it out just now! Will keep testing 😄

@fifieldt fifieldt marked this pull request as ready for review October 19, 2024 02:03
@fifieldt
Copy link
Contributor

OK, over to you -- I'll hold off making any more commits

@fifieldt fifieldt requested a review from caveman99 October 24, 2024 04:15
@Coloradohusky
Copy link
Contributor Author

Coloradohusky commented Oct 28, 2024

Haven't had much luck yet - it properly detects the sensor, but doesn't grab any measurements. Not sure what's preventing the measurements but will keep testing

@fifieldt fifieldt added the pinned Exclude from stale processing label Oct 31, 2024
@fifieldt fifieldt mentioned this pull request Nov 7, 2024
@fifieldt
Copy link
Contributor

A fix went in at #5584 that seems relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned Exclude from stale processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants