adafruit / Adafruit_SI1145_Library

Arduino library for the SI1145 sensors in the Adafruit shop
Other
21 stars 36 forks source link

UV part to part calibration #5

Closed bonjour81 closed 7 years ago

bonjour81 commented 7 years ago

The UV calibration seems a bit curious.

According to datasheet, the calibration is done using UCOEF[0:3]. Datasheet says "default value" are 0x7B, 0x6B, 0x01, and 0x00.

In the library, we can see in begin function: write8(SI1145_REG_UCOEFF0, 0x29); write8(SI1145_REG_UCOEFF1, 0x89); write8(SI1145_REG_UCOEFF2, 0x02); write8(SI1145_REG_UCOEFF3, 0x00);

Value seems not matching the datasheet default. Is there any reason for that ?

In addition, the SI1145 provide some part to part calibration factors that could be recovered at address 0x22 to 0x2D after writing 0x12 in 0x18 (see datasheet §2.4).

It seems this job was prepared, because we can find in library the following definition:

define SI1145_GET_CAL 0x12

But this define is not used anymore in the code.

Datasheet extract for reference : _To enable UV reading, set the EN_UV bit in CHLIST, and configure UCOEF [0:3] to the default values of 0x7B,0x6B, 0x01, and 0x00. [...]

The accuracy of UV readings can be improved by using calibration parameters that are programmed into the Si1132/Si114x at Silicon Labs' production facilities to adjust for normal part-to-part variation. The calibration parameters are recovered from the Si113x/Si114x by writing Command Register @ address 0x18 with the value 0x12. When the calibration parameters are recovered they show up at I2C registers 0x22 to 0x2D. These are the same registers used to report the VIS, IR, PS1, PS2, PS3, and AUX measurements_

ladyada commented 7 years ago

hmm its been a long time since we wrote this code but from what we recall, there was an app note with instructions on what to write based and we followed it. we can't seem to find that app note now but promise - we didnt make up the numbers!

bonjour81 commented 7 years ago

Hi! Well I'm sure it comes from somewhere :-). I was just wondering why it's different from datasheet.

Although, I think the very best would be to read and use coefficient factory programmed in each Si1145. It seems not very difficult but modifying a library is still slightly above my noobs skills. What do you think about it?

bonjour81 commented 7 years ago

From my measurements last days, my measurements seems around 1 or 2 UV index too high. I expect this may be the root cause.

ladyada commented 7 years ago

well - here's my counter proposal - the callibration of this sensor is kinda all fake anyways because its not a true UV sensor (something that is not very well explained, much to our frustration) and this chip is pretty much discontinued for that purpose because everyone got annoyed with silabs for the poor UV performance.

so what we recommend is trying something like the VEML https://www.adafruit.com/product/2899 its a real UV sensor :)

bonjour81 commented 7 years ago

Main reason to use Si1145 was this sentense : Then you can call readUV which will give you a 16-bit value relating to how much UV was detected. Again, this is not an UV index value, its unitless. You may need to calibrate the value against a known value depending on your usage!

from here: https://learn.adafruit.com/adafruit-veml6070-uv-light-sensor-breakout/wiring-and-test

at least on the paper, SI1145 was expected to give a good enought UV index. I don't know what to do with VEML6070 output :-)

ladyada commented 7 years ago

veml gives UVi. a 16 bit value is higher precision but its not accurate!

bonjour81 commented 7 years ago

well for sure library for VEML does not give the index (the 0 to ~11 numbers), not sure how to convert.

ladyada commented 7 years ago

that is the index

bonjour81 commented 7 years ago

I think you lost me. If I look to the VEML example output (from adafruit website): https://cdn-learn.adafruit.com/assets/assets/000/032/478/medium800/force___flex_light.png?1463428897

I see values upto 90. this is for sure not a UV index as described in the table here: https://en.wikipedia.org/wiki/Ultraviolet_index with values from 0 to 11+

ladyada commented 7 years ago

yah no idea what the correlation is. the datasheet has all the information. if you have any other questions, please post in the forums since this isn't where we do tech support!

bonjour81 commented 7 years ago

sure, we get a bit away initial topic :-)

ladyada commented 7 years ago

thankx :)

nfj25 commented 3 years ago

Just for the record, version 1.1 of the datasheet says: default values of 0x29, 0x89, 0x02, and 0x00 version 1.4 says: default values of 0x7B, 0x6B, 0x01, and 0x00