tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
607 stars 192 forks source link

sgp30: add the now-obsolete SGP30 air quality sensor #619

Closed aykevl closed 10 months ago

aykevl commented 10 months ago

Tested with a rp2040.

TODO: add the ability to set the absolute humidity for more accurate sensor details. The formula for that is rather complex, so I've left this as a future addition.


I've combined this sensor with the SCD40 CO₂ sensor to create a simple air quality monitor at home.

conejoninja commented 10 months ago

Thanks, I was using a SGP30 for a project of mine that got delayed, never got the SGP30 working properly as the values weren't what I expected and it stopped working at random times (probably a power issue I fixed later, but never got the time to check it).

Why use two different CO_2 sensors?

aykevl commented 10 months ago

Thanks, I was using a SGP30 for a project of mine that got delayed, never got the SGP30 working properly as the values weren't what I expected and it stopped working at random times (probably a power issue I fixed later, but never got the time to check it).

It stopped working for me too, for some reason. I haven't figured out the details yet, except it manages to bring down the attached Raspberry Pi too (so probably a power issue of some sort, maybe even a short?). Note that the first ~15 seconds you will get stub results, not the actual measurements. Perhaps that was the issue?

Why use two different CO_2 sensors?

The SGP30 is not a CO₂ sensor. It is a VOC sensor - even though marketing seems to suggest otherwise (and companies are probably only too happy to let this confusion remain). Instead of CO₂, it measures various other gases and makes a CO₂ estimate based on that, that is in practice highly inaccurate.

Historically, real CO₂ sensors have been somewhat expensive but nowadays a SGP40 can be bought at around €15 so it's not that expensive anymore. And it can be quite accurate after it's been calibrated to outside air.

deadprogram commented 10 months ago

Thanks for the addition @aykevl and to @conejoninja for review. Now merging.

deadprogram commented 10 months ago

Thanks for the addition @aykevl and to @conejoninja for review. Now merging.