Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UV Index shows zero! #2

Closed
gotfredsen opened this issue Sep 11, 2021 · 9 comments
Closed

UV Index shows zero! #2

gotfredsen opened this issue Sep 11, 2021 · 9 comments

Comments

@gotfredsen
Copy link

I have tried out this library even though readUVS() gives data, the UV Index is zero:

Modded example:

...
void loop() {
  if (ltr390.newDataAvailable()) {
    if (ltr390.getMode() == LTR390_MODE_ALS) {
      Serial.print("Ambient Light Lux: ");
      Serial.println(ltr390.getLux());
      ltr390.setGain(LTR390_GAIN_18);                  //Recommended for UVI - x18
      ltr390.setResolution(LTR390_RESOLUTION_20BIT);   //Recommended for UVI - 20-bit
      ltr390.setMode(LTR390_MODE_UVS);
    } else if (ltr390.getMode() == LTR390_MODE_UVS) {
      Serial.print("UV Index: ");
      Serial.println(ltr390.getUVI());
      Serial.print("UV Data: ");                       // added for debug
      Serial.println(ltr390.readUVS());                // added for debug
      ltr390.setGain(LTR390_GAIN_3);                   //Recommended for Lux - x3
      ltr390.setResolution(LTR390_RESOLUTION_18BIT);   //Recommended for Lux - 18-bit
      ltr390.setMode(LTR390_MODE_ALS);
    }
  }
}
...

Result:

UV Index: 0
UV Data: 181
Ambient Light Lux: 11540
UV Index: 0
UV Data: 184
Ambient Light Lux: 11539
UV Index: 0
UV Data: 184
Ambient Light Lux: 11521
UV Index: 0
UV Data: 177
Ambient Light Lux: 11507
UV Index: 0
UV Data: 182
Ambient Light Lux: 11507
UV Index: 0
UV Data: 180
Ambient Light Lux: 11522
UV Index: 0
UV Data: 180
Ambient Light Lux: 11499
@gotfredsen
Copy link
Author

Actually if I lower the resolution to 16 bits, I get a UV Index. I also noticed that if I change the ALS from 18bit to 16bit, the lux readout is 4x higher (from ~15k to ~60k). While I assume the raw ALS would change, I expect to see similar lux levels, just with lower precision.

I tried Adafruit's library, but bar an error in their code, it also doesn't calculate lux and UV Index, for same reason I wonder.

I could also have a different version of the LTR390 chip, since the data sheet changed the UV Sensitivity count from 2300 to 1400, so maybe mine is an old (2300) version...

@levkovigor
Copy link
Owner

@gotfredsen
What UV source did you use?
According to datasheet UVI accuracy +- 1.5 at Gain 18x and 20bit Resolution at range UVI < 3. So if the UV source is weak, the reading may be near zero.
Any LTR390 has UV Sensitivity 1400 according to the latest datasheet. 2300 - is incorrect value, it was measured incorrectly.

@levkovigor
Copy link
Owner

@gotfredsen
About ALS calculation for different resolutions - I ll recheck it on next week

@levkovigor
Copy link
Owner

@gotfredsen BTW I've found mistakes in setResolution and getResolution methods. I've corrected them and made new release 1.0.3
Maybe this was the problem. Can you check UVI and ALS calculations now?

@gotfredsen
Copy link
Author

@levkovigor the ALS/Lux calculations seems perfect now, thank you. See below.

However the UV Index calculation might be off. Using a gain of x3, the UV index seems dangerous high ;-). If I keep to x18 (and 20bit), I still get zero. And I accept my UV source might not be the best. I will find a more reliable source and test again.

Ambient Light Lux: 2071
UV Index: 4294967295
UV data: 2589
Ambient Light Lux: 2072
UV Index: 4294967295
UV data: 2591
Ambient Light Lux: 2071
UV Index: 4294967295
UV data: 2589
Ambient Light Lux: 2084
UV Index: 4294967295
UV data: 2606
Ambient Light Lux: 2075
UV Index: 4294967295
UV data: 2594
Ambient Light Lux: 2069
UV Index: 4294967295
UV data: 2587

@levkovigor
Copy link
Owner

@gotfredsen
I'm going to do research on the gain and resolution tomorrow. There is no such information in the datasheet. Perhaps there is not proportional dependence.

@gotfredsen
Copy link
Author

gotfredsen commented Sep 12, 2021

@levkovigor
I changed the library to return float on the UV Index instead, and I get some readings out of that. While I know the UV Index is reported in whole numbers, I have seen libraries reporting UV Index in real numbers, which I find useful.

I have compared the LTR390 with two other UV Sensors: VEML6075 and SI1133, both end-of-life.

UPDATE:
I did get UV Index with a better light source: I got 3.54 outdoor (33k lux), and (because of float) 0.01 indoor in a "darker" area (96 lux). Under my desk lamp (6434 lux) I get 0.08 in UV Index.

@levkovigor
Copy link
Owner

@gotfredsen Changed return values of Lux and UV Index to float - 1.0.5

UPDATE:
I did get UV Index with a better light source: I got 3.54 outdoor (33k lux), and (because of float) 0.01 indoor in a "darker" area (96 lux). Under my desk lamp (6434 lux) I get 0.08 in UV Index.

Lux and UV Index are different indicators and depend on the light source and environment

@levkovigor
Copy link
Owner

@gotfredsen

New release - 1.0.6
Error fixed in function getResoluton()
Added data in csv files for Lux and UVI calculations at different gain and resolution values
Added some data in csv files with comparisons of sensors: LTR390, VEML6070, VEML7700, SI1145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants