AirGradient Forum

New Go IAQS LED feature - excellent!

I agree that below 800 is best but we don’t have a whole lot of colors available. If 800-1000 is already yellow, what are we doing with larger values? (If the led is RGB, we just have red and magenta left. I spent some time thinking about this since also the IAQS uses 800 as cutoff)
The German Umweltbundesamt and other EU organizations find < 1000 ok. Ausschuss für Innenraumrichtwerte | Umweltbundesamt

Maybe the led can do more colors, that would make things easier.
,

Thanks for sharing this study!

This study associated 1000 ppm CO2 with a reduced sleep efficiency by 1.3% compared to 750ppm. This finding was statistically significant, but it does not sound like a big effect to me, although different people may be more or less sensitive to it.

Hi @Randomperson, I hope you are doing well. Regarding your question about the LEDs. Our engineer confirmed that the RGB LEDs are addressable and they are capable of producing multiple colors.

Very nice, so we can actually use a continuous scale (in HSL color space) to display the air quality. (E.g. co2 ppm: 400=blue, 800=green 1000=yellow etc,)

Give me some time to think about it, come up with a formula and experiment.

1 Like

@Randomperson thanks! Looking forward to hearing your thoughts.

Ok here it comes. CO2 only for now, If you like my approach I’ll do the same thing for PM.

I started with defining led colors for CO2 values. I also tried to use values matching up with the GO IAQS values:
400 is perfect, blue
800 is fine, green
1000 is questionable, yellow
1400 is bad, red.
2000 is really bad, magenta

To build a color function I used the HSL color space where H is the hue, this makes math with colors a lot easier.

If you put the color values and the ppm in a 2d chart it looks like this:

With a bit of help from matplotlib curve fitting I arrived at this function:

Which gives me this color gradient for the LED, what do you think?

Code for this would look like this (I use python, but transferring it to a different language like c should be easy)


import colorsys
# python library for conversion of color models

def CO2toLED(ppm: float, brightness: float) -> None:
    '''
    function to calculate and set LED colors from CO2 ppm value
    input: CO2 value in ppm, LED brightness scale 0-1, saturation set to 1 for best color
    '''
    
    # limit values to 400-2000, below 400 always blue, above 20ö0 always magenta
    if ppm < 400:
        ppm = 400
    if ppm > 2000:
        ppm = 2000
    
    h = -2.5e-08 * pow(ppm, 3) + 0.0001871 * pow(ppm, 2) - 0.513 * ppm + 417.7

    # normalize H from angle in degrees to scale of 0..1 including shift for negative values from curve fitting
    h_norm = ((h + 360) % 360) / 360
    
    # convert HSV to RGB
    rgb = colorsys.hsv_to_rgb(h_norm,1,brightness)
    
    # LED code here
    print(f"LED set to R:{rgb[0]}, G:{rgb[1]}, B:{rgb[2]}")

1 Like

Hi @Randomperson! Thanks for the detailed proposal. That’s impressive. (Although I’m not a fan of maths in general, I can understand what it would look like with the HSV chart)

This approach is interesting, as it also gives the granularity that @Bart_Netherlands suggested.

I tried using Codex to help implement your proposed color to run on my Go (without applying the CO2 rule, just to see how it looks visually):

What do you guys think? It’s still difficult to tell whether we will implement this (as I haven’t discussed it with the team yet). But it would be nice to hear what our users think.