adafruit_ltr390

Adafruit CircuitPython library for the LTR390

  • Author(s): Bryan Siepert

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_ltr390.Gain

Options for gain

Gain

Raw Measurement Multiplier

Gain.GAIN_1X

1

Gain.GAIN_3X

3

Gain.GAIN_6X

6

Gain.GAIN_9X

9

Gain.GAIN_18X

18

class adafruit_ltr390.LTR390(i2c, address=83)

Class to use the LTR390 Ambient Light and UV sensor

Parameters
  • i2c (I2C) – The I2C bus the LTR390 is connected to.

  • address (int) – The I2C device address. Defaults to 0x53

Quickstart: Importing and using the LTR390

Here is an example of using the LTR390 class. First you will need to import the libraries to use the sensor

import board
import adafruit_ltr390

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
ltr = adafruit_ltr390.LTR390(i2c)

Now you have access to the lux and light attributes

lux = ltr.lux
light = ltr.light
data_ready

Ask the sensor if new data is available

enable_alerts(enable, source, persistance)

The configuration of alerts raised by the sensor

Parameters
  • enable – Whether the interrupt output is enabled

  • source – Whether to use the ALS or UVS data register to compare

  • persistance – The number of consecutive out-of-range readings before

property gain

The amount of gain the raw measurements are multiplied by

high_threshold

When the measured value is more than the low_threshold, the sensor will raise an alert

initialize()

Reset the sensor to it’s initial unconfigured state and configure it with sensible defaults so it can be used

property light

The currently measured ambient light level

low_threshold

When the measured value is less than the low_threshold, the sensor will raise an alert

property lux

Read light level and return calculated Lux value.

property measurement_delay

The delay between measurements. This can be used to set the measurement rate which affects the sensor power usage.

property resolution

Set the precision of the internal ADC used to read the light measurements

threshold_passed

The status of any configured alert. If True, a threshold has been passed.

Once read, this property will be False until it is updated in the next measurement cycle

property uvi

Read UV count and return calculated UV Index (UVI) value based upon the rated sensitivity of 1 UVI per 2300 counts at 18X gain factor and 20-bit resolution.

property uvs

The calculated UV value

property window_factor

Window transmission factor (Wfac) for UVI and Lux calculations. A factor of 1 (default) represents no window or clear glass; > 1 for a tinted window. Factor of > 1 requires an empirical calibration with a reference light source.

class adafruit_ltr390.MeasurementDelay

Options for measurement_delay

MeasurementDelay

Time Between Measurement Cycles (ms)

MeasurementDelay.DELAY_25MS

25

MeasurementDelay.DELAY_50MS

50

MeasurementDelay.DELAY_100MS

100

MeasurementDelay.DELAY_200MS

200

MeasurementDelay.DELAY_500MS

500

MeasurementDelay.DELAY_1000MS

1000

MeasurementDelay.DELAY_2000MS

2000

class adafruit_ltr390.Resolution

Options for resolution

Resolution

Internal ADC Resolution

Resolution.RESOLUTION_13BIT

13 bits

Resolution.RESOLUTION_16BIT

16 bits

Resolution.RESOLUTION_17BIT

17 bits

Resolution.RESOLUTION_18BIT

18 bits

Resolution.RESOLUTION_19BIT

19 bits

Resolution.RESOLUTION_20BIT

20 bits