LTR-390 UV and light sensor

The Lite-On LTR-390UV reads the UV index or the visible light over I2C at 0x53, one at a time, 13 to 20 bits at a gain of 1 to 18.

Aliases: LTR390, Adafruit LTR390, UV index sensor, ultraviolet sensor. It is the sensor of a sunburn warning: the UV index is the number the weather forecast gives, 0 at night to 11 and more at noon in summer.

Pins

Pin What it does
VIN, GND Supply, 3 to 5 V on the board.
SCL, SDA I2C. The board carries the pull-ups.
INT The threshold interrupt, left high-Z by the model.

Properties

uvi is the UV index and lux the visible light; the two sliders change them.

Reading it on an Arduino

With Adafruit's library, which Mokxi ships as Adafruit_LTR390.h:

#include <Adafruit_LTR390.h>
Adafruit_LTR390 ltr;

void setup() {
  Serial.begin(9600);
  ltr.begin();
  ltr.setMode(LTR390_MODE_UVS);
  ltr.setGain(LTR390_GAIN_18);
  ltr.setResolution(LTR390_RESOLUTION_20BIT);
}

void loop() {
  if (ltr.newDataAvailable()) Serial.println(ltr.getUVI());
  delay(100);
}

How it talks

MAIN_CTRL (0x00) enables it and picks UV or light mode; MEAS_RATE (0x04) sets the resolution (20 bits take 400 ms, 13 bits 12.5 ms) and how often it measures; GAIN (0x05) the gain. PART_ID (0x06) reads 0xB2. MAIN_STATUS (0x07) flags new data and clears when read; the counts are at 0x0D (light) and 0x10 (UV), 20 bits low byte first. UVI = UVS / (2300 x gain / 18 x time / 400 ms).

What it does not model

The interrupt, the window factor of a cover over the sensor, and the spectral response.

Common mistakes

Reading the UV counts in light mode: only the mode chosen is measured. A small UV figure at gain 1 and 13 bits: the counts are few; raise the gain and the resolution.