LTR390
Works with
Any CircuitPython board with I2C
What it does
The LTR390 measures both UV index and ambient light from a single chip over I2C. It can operate in UV mode or ambient light mode — not both simultaneously — so you switch between them in code. Common uses include sun exposure monitoring, UV dose logging, and light-aware outdoor projects.
Installing the library
Download adafruit_ltr390.mpy from the Adafruit CircuitPython Bundle and copy it to the lib/ folder on your board.
Quick start
import board
import busio
import adafruit_ltr390
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_ltr390.LTR390(i2c)
# Read UV index (default mode is UV)
print(f"UV raw: {sensor.uvs}")
print(f"UV index: {sensor.uvi}")
# Switch to ambient light mode
sensor.mode = adafruit_ltr390.MODE_ALS
print(f"Ambient light: {sensor.light} lux")
Key things you can do
| What you want | How to do it |
|---|---|
| Read raw UV counts | sensor.uvs |
| Read calibrated UV index | sensor.uvi |
| Read ambient light | sensor.light (lux) |
| Switch to UV mode | sensor.mode = adafruit_ltr390.MODE_UVS |
| Switch to ambient light mode | sensor.mode = adafruit_ltr390.MODE_ALS |
| Check current mode | sensor.mode |
| Adjust gain | sensor.gain — options: GAIN_1X, GAIN_3X, GAIN_6X, GAIN_9X, GAIN_18X |
| Adjust resolution | sensor.resolution — higher resolution increases read time |
Reading the official docs
Full API reference: https://docs.circuitpython.org/projects/ltr390/en/latest/
Key things to look up:
- The chip cannot read UV and ambient light at the same time — switching modes requires a short settling time before a valid reading is available
uviis a derived value calculated fromuvs, gain, and resolution — use it for human-readable UV index- Higher gain improves sensitivity in low-light or low-UV conditions but can saturate in direct sunlight
Projects using this library
- Adafruit LTR390 guide — wiring, setup, and example code for both modes