adafruit / Adafruit_CircuitPython_LTR390

CircuitPython library for the LTR390 ambient light and UV sensor
MIT License
7 stars 2 forks source link

Add UVI, Lux, and Window Transmission Factor #3

Closed CedarGroveStudios closed 3 years ago

CedarGroveStudios commented 3 years ago

Updated the LTR390 sensor library to include UVI and Lux parameters. The revision also includes a window_factor parameter to accommodate window transmission light loss (defaults to 1.0 = clear or no glass). UVI and Lux values are properly scaled for all gain and resolution settings.

The UVI and Lux calculations were taken directly from the data sheet assuming the sensor is factory calibrated. The UVI and Lux measurements were not verified with a calibrated source.

Use example:

import busio
import board
import adafruit_ltr390

i2c = busio.I2C(board.SCL, board.SDA)
ltr = adafruit_ltr390.LTR390(i2c)

print("UVI: ", ltr.uvi, "Lux: ", ltr.lux)

To set the window transmission factor to other than the default 1.0:

ltr.window_factor = 1.1