SGP30 air quality sensor ESPHOME code optimization and numerical meaning

Spread the love

sgp30

My SGP30 air quality sensor initially fluctuated in readings,
but then it remained consistently at 400 ppm and 0 ppb for several hours without changing, which is clearly abnormal.
I’m using the official default code template
and have checked several times to confirm that the SGP30 sensor, ESPHOME communication, and wiring are all working correctly, but the data is still incorrect.
AI analysis suggests that I’m missing some code.

Add code

`store_baseline: true` # Automatically saves the baseline and restores it on the next startup.
`update_interval: 1s` # Updates every second.
Previously, no time interval was set; the default seemed to be 60 seconds, which was too long. Now it’s changed to 1 second. The value will change
as soon as the data changes. Secondly, it automatically saves the previous baseline, eliminating the need to recalibrate the baseline data every 12 hours after a power outage. This ensures the accuracy of the baseline and allows for quick data updates (because it’s normal for the data not to change during baseline testing).
The code below can be reused.

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true
  id: bus_a

# Example configuration entry
sensor:
  - platform: sgp30
    eco2:
      name: "eCO2"
    tvoc:
      name: "TVOC"
    store_baseline: true
    update_interval: 1s

Numerical Explanation

The 420 ppm  and  21 ppb you mentioned   are two parameters measured by the SGP30 sensor:

  • eCO₂(equivalent CO₂)= 420 ppm
  • TVOC(Total Volatile Organic Compounds)= 21 ppb

Below, I will explain their meanings and normal ranges in detail


eCO₂ (equivalent carbon dioxide concentration)

  • Unit: ppm (parts per million)
  • It does not directly measure CO₂, but rather calculates the “equivalent” carbon dioxide concentration based on the reaction of TVOC (volatile organic compounds).
  • Common Ranges: | Environment | Typical eCO₂ Value |
    | —- | —- |
    | Fresh Outdoor Air | 400 ppm (Baseline) |
    | Normal Indoor Air | 600 ~ 800 ppm |
    | Poorly Ventilated/Multi-person Environment | 1000 ~ 2000 ppm |
    | Very Stuffy/Poor Air Quality | > 2000 ppm |

Your current  420 ppm  indicates that the air is very fresh, almost at outdoor air levels.


TVOC (Total Volatile Organic Compounds)

  • Unit: ppb (parts per billion)
  • This indicates the total concentration of various organic gases in the air, for example:
    • Formaldehyde (HCHO)
    • benzene
    • alcohol vapor
    • Cooking smell
    • Fragrances, cleaning agent scents, etc.

Typical range:

Air quality levelTVOC(ppb)illustrate
excellent0 ~ 65The air is very clean.
good65 ~ 220Normal home environment
generally220 ~ 660It has a slight odor
Difference> 660Heavy air pollution or poor ventilation

Your current level of  21 ppb  is very low, indicating that the air is extremely clean.


Summarize

This means your sensor is working properly and the current air quality is excellent.

Leave a Reply

Your email address will not be published. Required fields are marked *