Update SGP4x to return raw VOC and raw NOX values
Describe the problem you have/What new integration you would like
SGP4x reads a raw value from the device and uses it to update the VOC and/or NOX index which is an indicator of relative gas levels over time. This is the standard usecase for environments where elevated gas levels are temporary. If the elevated gas level continue for a long period, inside a 3D Printer chamber for example, the index will eventually drift toward 100. I would like to expose the raw values to use them as an indicator of actual, not relative, gas levels.
Please describe your use case for this integration and alternatives you've tried:
I have a SGP40 sensor inside my 3D printer chamber and another one outside the chamber. I want to monitor the effectiveness of my charcoal filter and also detect if any VOC is leaking to the room. The index alone is helpful but for very long prints will start to move toward 100.
Additional context
This is now best part of a year old but I'll mention that I'd find that useful is well.
Yes please. I have a similar usecase.
I've had the same use case, so I've decided to try and code this change as an external component for now for testing purposes.
Indeed, the stock VOC reading is not useful for use cases where you want to measure a constant load of VOC's and not whether the air quality is getting better or worse. Like in a 3d printer.
Ultimately I wanted to use this to control my Stealthmax unit and its new servo vent flap via home assistant and via automated espHome code. Not there yet, but this was needed to be able to get consistent VOC readings that don't converge down to 100.
More importantly I wanted to use a pair of those in the intake and exhaust of my air filter to be able to estimate its efficiency as the delta between the raw values should indicate how well it is absorbing VOC's.
I haven't raised a PR as this needs testing. Would appreciate feedback! Use as an external component for now until it gets tested and I can raise a PR against the base espHome sensor code.
You can use it like so:
- Include the below external component in your config file which overrides the ESPHome sgp4x sensor. sgp40 is my branch that contains the modified code, and the below URL is my git branch where you can audit the changes.
external_components:
- source:
type: git
url: https://github.com/igiannakas/esphome
ref: sgp40
components: [ sgp4x ]
- Output the sensor like so:
sensor:
- platform: sgp4x
i2c_id: bus_b
update_interval: 2s
voc:
name: "VOC"
voc_raw:
name: "VOC - Raw"
compensation:
temperature_source: intake_temp
humidity_source: intake_hum
Here's how it looks in HA:
Please note that a higher sensor value -> cleaner air, from what I understand. To use ideally you should identify a baseline value with an average measurement in clean air over say 12 hours, and then subtract that value from the VOC raw values.
For example like so:
voc_raw:
name: "Intake - VOC - Raw"
filters:
- lambda: return -(x - 31200);
If anyone tests this please do offer feedback!!