Home Circuitpython Adafruit Feather M0 and LTR390 UV Light Sensor circuitpython example

Adafruit Feather M0 and LTR390 UV Light Sensor circuitpython example

by shedboy71

In this article we connect a LTR390 UV Light Sensor to an Adafruit Feather M0 running Circuitpython

Sensor Information

This sensor converts light intensity to a digital output signal capable of direct I2C interface.

It provides a linear ALS response over a wide dynamic range, and is well suited to applications under high ambient brightness.

The sensor has a programmable interrupt with hysteresis to response to events and that removes the need to poll the sensor for a reading which improves system efficiency.

This CMOS design and factory-set one time trimming capability ensure minimal sensor-to-sensor variations forease of manufacturability to the end customers.

Features

I2C interface capable of Standard mode @100kHz or Fast mode @400kHz communication; 1.8V logic compatible
Ambient Light / Ultraviolet light(UVS)Technology in one ultra-small 2x2mm ChipLED package
Very low power consumption with sleep mode capability
Operating voltage ranges: 1.7V to 3.6V
Operating temperature ranges: -40 to +85 ºC
Built-in temperature compensation circuit
Programmable interrupt function for ALS , UVS with upper and lower thresholds
RoHS andHalogen free compliant

UVS/ALS Features

  • 13 to 20 bits effective resolution
  • Wide dynamic range of 1:18,000,000 with linear response
  • Close to human eye spectral response
  • Automatic rejection for 50Hz/60Hz lighting flicker

This is the sensor that I bought

Parts Required

The sensor you can pick up in the $6 price range – you can connect to the sensor using a standard header the classic dupont style jumper wire.

I used a Qwiic cable – since a few sensors seem to use these but this is optional

Name Link
Adafruit Feather M0 Express Amazon link

Ebay link

LTR390 Adafruit LTR390 UV Light Sensor – Stemma QT/Qwiic
Connecting cables Aliexpress product link

Ebay link

 

Schematic/Connection

I used the Adafruit LTR390 sensor and in this case used the Stemma connection

For the STEMMA QT cables, it uses the Qwiic convention:

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

feather and LTR390

feather and LTR390

Code Example

I used Mu for development

The following is based on a library , I copied the adafruit_LTR390.mpy library for this device to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries

This is the basic example which comes with the library

[codesyntax lang=”python”]

import time
import board
import adafruit_ltr390

i2c = board.I2C()
ltr = adafruit_ltr390.LTR390(i2c)

while True:
    print("UV:", ltr.uvs, "\t\tAmbient Light:", ltr.light)
    print("UVI:", ltr.uvi, "\t\tLux:", ltr.lux)
    time.sleep(1.0)

[/codesyntax]

Output

Here is what I saw in Mu REPL window

UV: 1 Ambient Light: 71
UVI: 0.0417391 Lux: 56.8
UV: 0 Ambient Light: 70
UVI: 0.0 Lux: 53.6
UV: 0 Ambient Light: 54
UVI: 0.0 Lux: 0.8
UV: 0 Ambient Light: 1
UVI: 0.0 Lux: 0.8
UV: 0 Ambient Light: 65
UVI: 0.0 Lux: 53.6

Links

Datasheet

 

 

You may also like

Leave a Comment