Skip to content

feat: Add SCD4X#7198

Merged
thebentern merged 140 commits intomeshtastic:masterfrom
fablabbcn:feat/add-scd4x
Feb 9, 2026
Merged

feat: Add SCD4X#7198
thebentern merged 140 commits intomeshtastic:masterfrom
fablabbcn:feat/add-scd4x

Conversation

@oscgonfer
Copy link
Contributor

@oscgonfer oscgonfer commented Jul 2, 2025

This PR adds support for the SCD4X CO2 sensors by sensirion.
It builds upon on the great work by @Coloradohusky, @hafu and @fifieldt in #4601 and https://github.com/hafu/meshtastic-firmware/tree/add-scd30 (although it doesn't add SCD30 support).

This PR tries to sync that work with the current state master branch, and it's rebased on top of #7190, which is an attempt to decouple AirQualityTelemetry from PMSA0003I sensor (I have just ordered one sensor to test). I also started using the new Sensirion library for this sensor, which has a new release (and a very annoying change in the library name import).

This also goes along with meshtastic/protobufs#719 to support having real temperature and the sensor temperature separately. Testing it, you can see some differences between two sensors that are right next to each other (SHT31 and the one inside the SCD4X).

decoded {
  portnum: TELEMETRY_APP
  payload: "time: 1751450604 air_quality_metrics {   co2: 1602   co2_temperature: 28.4126797   co2_humidity: 55.2819099 }"
}
decoded {
  portnum: TELEMETRY_APP
  payload: "time: 1751450589 environment_metrics {   temperature: 31.69   relative_humidity: 50.19 }"
}

There are some comments that I point in the code directly below. I also tried to make it work with the screen, but I don't think my system allows for testing it ATM.

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Seeed ESP32-S3 Xiao board

@oscgonfer oscgonfer marked this pull request as ready for review July 2, 2025 10:08
@oscgonfer
Copy link
Contributor Author

An additional comment: these type of sensors generally require a "control" interface to enable or disable features. This is mapped here - and could be a good outcome of the hackathon.

@oscgonfer oscgonfer changed the title Add SCD4X feat: Add SCD4X Jul 2, 2025
@thebentern
Copy link
Contributor

@oscgonfer protobufs are merged and generated upstream now

@oscgonfer oscgonfer force-pushed the feat/add-scd4x branch 2 times, most recently from 247768e to 84865cd Compare July 2, 2025 12:46
@oscgonfer
Copy link
Contributor Author

oscgonfer commented Jul 2, 2025

rebased onto #7202 - just to keep in mind that the sensirion library needs to be 1.0.0 @thebentern

@fifieldt
Copy link
Member

fifieldt commented Jul 3, 2025

sensirion 1.1.0 was released - updated upstream.

@oscgonfer
Copy link
Contributor Author

sensirion 1.1.0 was released - updated upstream.

Merged

@hafu
Copy link
Contributor

hafu commented Jul 5, 2025

Thanks for your effort! I can confirm it works with:

@oscgonfer
Copy link
Contributor Author

Thanks for your effort! I can confirm it works with:

* Heltec v3

* RAK11310

* RAK4631 (needs [some fixes](https://github.com/meshtastic/firmware/pull/7190#pullrequestreview-2990183787) in

Thank you @hafu ! I fixed and rebased #7190

@vidplace7 vidplace7 added the enhancement New feature or request label Jul 18, 2025
@CLAassistant
Copy link

CLAassistant commented Jul 22, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ oscgonfer
❌ peterzqx
You have signed the CLA already but the status is still pending? Let us recheck it.

@oscgonfer
Copy link
Contributor Author

oscgonfer commented Feb 6, 2026

Hi @paulwalko @hafu

Do you want to give this a go? I believe it'd be final

@oscgonfer oscgonfer marked this pull request as draft February 7, 2026 17:43
@paulwalko
Copy link

Hi @paulwalko @hafu

Do you want to give this a go? I believe it'd be final

Looks good to me! Verified with a diy nrf52 node to take measurements (scd41 only) + rak 4631 to upload them.

@oscgonfer
Copy link
Contributor Author

Cool! I need to fix a minor detail on the Sen5x part, but it'd be done shortly! I'll mark it as ready when it's done!

@oscgonfer oscgonfer marked this pull request as ready for review February 8, 2026 09:45
@hafu
Copy link
Contributor

hafu commented Feb 8, 2026

Hi @paulwalko @hafu

Do you want to give this a go? I believe it'd be final

I'll try to test this next week with at least a Heltec v3

@oscgonfer
Copy link
Contributor Author

Resolved conflicts on merge. All good on my end, but let's see after tests.

@thebentern thebentern merged commit 579a0af into meshtastic:master Feb 9, 2026
77 checks passed
@oscgonfer oscgonfer deleted the feat/add-scd4x branch February 9, 2026 16:15
@Tomas-Kuchta-FPV
Copy link

Tomas-Kuchta-FPV commented Feb 13, 2026

Thanks for yor work. It seems to be working.
The high value is me breathing on it.

Screenshot_20260213-213914.png

@hafu
Copy link
Contributor

hafu commented Feb 14, 2026

Can also confirm it works using a Heltec v3.

I also have a MCP9808 temperature sensor connected to the I2C bus. At first it won't work and I got only SCD4X: Data is not ready messages. After connecting only the SCD4X sensor it worked immediately (after reset/reboot). Connected the MCP9809 again and no problems since. I assume it was the wiring on the bread board, which lead to communication issues on the I2C bus.

@oscgonfer
Copy link
Contributor Author

Thank you both @hafu and @Tomas-Kuchta-FPV for testing. Admin commands are now (WIP) implemented in meshtastic/python#903 in case you want to give it a whirl. The commands are used to modify calibration parameters and other config settings.

@Tomas-Kuchta-FPV
Copy link

Thank you both @hafu and @Tomas-Kuchta-FPV for testing. Admin commands are now (WIP) implemented in meshtastic/python#903 in case you want to give it a whirl. The commands are used to modify calibration parameters and other config settings.

I'll test it out.
Just one more thing is that the mobile apps also need to support the CO2 measurement and show it in measurements. I have tried to set up android studio but there seems to be a memory leak with linux, it gobles up ram and crashes. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.