firmware
firmware copied to clipboard
Add CO2 sensing with SCD4X
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
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?
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?
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
Thanks for the heads up! Will take a look in the next few days.
@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?
@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
Was checking it out just now! Will keep testing 😄
OK, over to you -- I'll hold off making any more commits
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
A fix went in at https://github.com/meshtastic/firmware/pull/5584 that seems relevant.
any update on this sensor recently?
Thanks for the review @hafu ! Help taking the concept forward would be most welcome
I finally acquired an SCD40. Need to solder the pins on, but after that should be able to help test this.
I am having a saga acquiring a soldering iron :(
Hi! I had started doing the same rework to set it all up for our Smartcitizen hackathon next week, but probably best to start working on this on this same branch. Which commit would you recommend starting with? (There have been quite some merges.. )
Reading the comments above I'd suggest approaching the temperature and humidity of these sensors (CO2 or other multi-sensor modules) as "temperature of the co2 sensor", and add it as co2_sensor_temperature (or something like that?) in the protobuf. It would be good to keep these values separate from environment telemetry, because its otherwise difficult to get a good temperature reading (which is not affected by the co2 sensor operation itself).
Note: I have some of these sensors I can use to test as well (except PMSA003I). If you are at discord, feel free to ping at oscgonfer
As mentioned before, I didn't got this branch in a working state and started over. There are also many changes in the firmware ongoing and the PMSA003I got also some changes, which must be applied here.
I suggest to start a new branch with the SCD4x sensor and keep it simple. Get it working to read out the values and send them via telemetry. In my opinion the support for displays can be added in another PR, but it is a nice to have.
Reading the comments above I'd suggest approaching the temperature and humidity of these sensors (CO2 or other multi-sensor modules) as "temperature of the co2 sensor", and add it as
co2_sensor_temperature(or something like that?) in the protobuf. It would be good to keep these values separate from environment telemetry, because its otherwise difficult to get a good temperature reading (which is not affected by the co2 sensor operation itself).
I did another approach, at least for the SCD30: The SCD30 comes with an extra temperature/humidity sensor (RH/T something) integrated for calibration. I have to read the datasheet for the SCD4x if it is alike. Therefore I suggest to use the values from the integrated temperature/humidity sensor as environment metrics and calibration, if no other sensor is available.
I also wanted to start on a new branch this week, since I have now a SCD4x.
Hi @hafu,
We are doing a hackathon next week to integrate a whole bunch of air quality sensors into meshtastic (we are coming from a project called smartcitizen with a lot of sensors supported including these). For the hackathon, we have a selection of sensors that overlap with: scd30, scd40, sfa30, sen5x and sen6x series which we are mapping here: https://github.com/fablabbcn/smartcitizen-meshtastic/issues/4, and most of them are multisensor nodes that have to be agreed on how the firmware treats the readings.
I think it'd be great if we manage to all sync on this effort, and have a joint approach for integrating these... We can probably discuss the reasoning on discord or a joint call together? I think we can find an agreement on the approach, and potentially even work on a new branch together (maybe on the hackathon repo?
What do you think?
Hi @hafu,
We are doing a hackathon next week to integrate a whole bunch of air quality sensors into meshtastic (we are coming from a project called smartcitizen with a lot of sensors supported including these). For the hackathon, we have a selection of sensors that overlap with: scd30, scd40, sfa30, sen5x and sen6x series which we are mapping here: fablabbcn#4, and most of them are multisensor nodes that have to be agreed on how the firmware treats the readings.
I think it'd be great if we manage to all sync on this effort, and have a joint approach for integrating these... We can probably discuss the reasoning on discord or a joint call together? I think we can find an agreement on the approach, and potentially even work on a new branch together (maybe on the hackathon repo?
What do you think?
Sounds great! This would also be my first major contribution to the project. I did some tinkering with modules, sensors and build my customized meshtastic firmware. Getting CO2 sensors running with meshtastic is on my to do list since the beginning of the year.
I give discord another try, if this is the preferred way. Tomorrow I have some time to discuss. A call is also possible tomorrow.
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
A comment to an old comment: I had some issues with the SCD30 too. I figured out, that the SCD30 only works reliable with 5V. Maybe the 3.3V power rail is a bit to low and prevents the sensor from working properly.
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
A comment to an old comment: I had some issues with the SCD30 too. I figured out, that the SCD30 only works reliable with 5V. Maybe the 3.3V power rail is a bit to low and prevents the sensor from working properly.
I think this should be no issue... we have used SCD30 for very looong data collections (+2 years). (some SCD30 docs here https://docs.smartcitizen.me/knowledge/air/co2/Sensirion_SCD30/)
Hi @hafu, We are doing a hackathon next week to integrate a whole bunch of air quality sensors into meshtastic (we are coming from a project called smartcitizen with a lot of sensors supported including these). For the hackathon, we have a selection of sensors that overlap with: scd30, scd40, sfa30, sen5x and sen6x series which we are mapping here: fablabbcn#4, and most of them are multisensor nodes that have to be agreed on how the firmware treats the readings. I think it'd be great if we manage to all sync on this effort, and have a joint approach for integrating these... We can probably discuss the reasoning on discord or a joint call together? I think we can find an agreement on the approach, and potentially even work on a new branch together (maybe on the hackathon repo? What do you think?
Sounds great! This would also be my first major contribution to the project. I did some tinkering with modules, sensors and build my customized meshtastic firmware. Getting CO2 sensors running with meshtastic is on my to do list since the beginning of the year.
I give discord another try, if this is the preferred way. Tomorrow I have some time to discuss. A call is also possible tomorrow.
I think one very good way to start would be to have a clean branch, updated with master, that has the decouple of AirQualityTelemetry and the PMA003I. I can give it a go, but I have no PMA sensor with me (although I have all the other sensirion ones available).
I now have a functional SCD4X and am starting to test and edit this patch a bit.
I can confirm the I2C detection code works at least :)
Trying to clean this up a little for you so you can have a more pleasant hackathon.
I give discord another try, if this is the preferred way. Tomorrow I have some time to discuss. A call is also possible tomorrow.
@oscgonfer Sorry, I got sick, but I got some energy today and tried out your PR and gave some feedback.