Adafruit LTR390 UV Sensor Library
Public Member Functions | List of all members
Adafruit_LTR390 Class Reference

Class that stores state and functions for interacting with LTR390 UV Sensor. More...

#include <Adafruit_LTR390.h>

Public Member Functions

 Adafruit_LTR390 ()
 Instantiates a new LTR390 class.
 
bool begin (TwoWire *theWire=&Wire)
 Setups the hardware for talking to the LTR390. More...
 
bool reset (void)
 Perform a soft reset with 10ms delay. More...
 
void enable (bool en)
 Enable or disable the light sensor. More...
 
bool enabled (void)
 Read the enabled-bit from the sensor. More...
 
void setMode (ltr390_mode_t mode)
 Set the sensor mode to EITHER ambient (LTR390_MODE_ALS) or UV (LTR390_MODE_UVS) More...
 
ltr390_mode_t getMode (void)
 get the sensor's mode More...
 
void setGain (ltr390_gain_t gain)
 Set the sensor gain. More...
 
ltr390_gain_t getGain (void)
 Get the sensor's gain. More...
 
void setResolution (ltr390_resolution_t res)
 Set the sensor resolution. Higher resolutions take longer to read! More...
 
ltr390_resolution_t getResolution (void)
 Get the sensor's resolution. More...
 
void setThresholds (uint32_t lower, uint32_t higher)
 Set the interrupt output threshold range for lower and upper. When the sensor is below the lower, or above upper, interrupt will fire. More...
 
void configInterrupt (bool enable, ltr390_mode_t source, uint8_t persistance=0)
 Configure the interrupt based on the thresholds in setThresholds() When the sensor is below the lower, or above upper thresh, interrupt will fire. More...
 
bool newDataAvailable (void)
 Checks if new data is available in data register. More...
 
uint32_t readUVS (void)
 Read 3-bytes out of UV data register, does not check if data is new! More...
 
uint32_t readALS (void)
 Read 3-bytes out of ambient data register, does not check if data is new! More...
 

Detailed Description

Class that stores state and functions for interacting with LTR390 UV Sensor.

Member Function Documentation

◆ begin()

bool Adafruit_LTR390::begin ( TwoWire *  theWire = &Wire)

Setups the hardware for talking to the LTR390.

Parameters
theWireAn optional pointer to an I2C interface
Returns
True if initialization was successful, otherwise false.

◆ reset()

bool Adafruit_LTR390::reset ( void  )

Perform a soft reset with 10ms delay.

Returns
True on success (reset bit was cleared post-write)

◆ enable()

void Adafruit_LTR390::enable ( bool  en)

Enable or disable the light sensor.

Parameters
enTrue to enable, False to disable

◆ enabled()

bool Adafruit_LTR390::enabled ( void  )

Read the enabled-bit from the sensor.

Returns
True if enabled

◆ setMode()

void Adafruit_LTR390::setMode ( ltr390_mode_t  mode)

Set the sensor mode to EITHER ambient (LTR390_MODE_ALS) or UV (LTR390_MODE_UVS)

Parameters
modeThe desired mode - LTR390_MODE_UVS or LTR390_MODE_ALS

◆ getMode()

ltr390_mode_t Adafruit_LTR390::getMode ( void  )

get the sensor's mode

Returns
The current mode - LTR390_MODE_UVS or LTR390_MODE_ALS

◆ setGain()

void Adafruit_LTR390::setGain ( ltr390_gain_t  gain)

Set the sensor gain.

Parameters
gainThe desired gain: LTR390_GAIN_1, LTR390_GAIN_3, LTR390_GAIN_6 LTR390_GAIN_9 or LTR390_GAIN_18

◆ getGain()

ltr390_gain_t Adafruit_LTR390::getGain ( void  )

Get the sensor's gain.

Returns
gain The current gain: LTR390_GAIN_1, LTR390_GAIN_3, LTR390_GAIN_6 LTR390_GAIN_9 or LTR390_GAIN_18

◆ setResolution()

void Adafruit_LTR390::setResolution ( ltr390_resolution_t  res)

Set the sensor resolution. Higher resolutions take longer to read!

Parameters
resThe desired resolution: LTR390_RESOLUTION_13BIT, LTR390_RESOLUTION_16BIT, LTR390_RESOLUTION_17BIT, LTR390_RESOLUTION_18BIT, LTR390_RESOLUTION_19BIT or LTR390_RESOLUTION_20BIT

◆ getResolution()

ltr390_resolution_t Adafruit_LTR390::getResolution ( void  )

Get the sensor's resolution.

Returns
The current resolution: LTR390_RESOLUTION_13BIT, LTR390_RESOLUTION_16BIT, LTR390_RESOLUTION_17BIT, LTR390_RESOLUTION_18BIT, LTR390_RESOLUTION_19BIT or LTR390_RESOLUTION_20BIT

◆ setThresholds()

void Adafruit_LTR390::setThresholds ( uint32_t  lower,
uint32_t  higher 
)

Set the interrupt output threshold range for lower and upper. When the sensor is below the lower, or above upper, interrupt will fire.

Parameters
lowerThe lower value to compare against the data register.
higherThe higher value to compare against the data register.

◆ configInterrupt()

void Adafruit_LTR390::configInterrupt ( bool  enable,
ltr390_mode_t  source,
uint8_t  persistance = 0 
)

Configure the interrupt based on the thresholds in setThresholds() When the sensor is below the lower, or above upper thresh, interrupt will fire.

Parameters
enableWhether the interrupt output is enabled
sourceWhether to use the ALS or UVS data register to compare
persistanceThe number of consecutive out-of-range readings before we fire the IRQ. Default is 0 (each reading will fire)

◆ newDataAvailable()

bool Adafruit_LTR390::newDataAvailable ( void  )

Checks if new data is available in data register.

Returns
True on new data available

◆ readUVS()

uint32_t Adafruit_LTR390::readUVS ( void  )

Read 3-bytes out of UV data register, does not check if data is new!

Returns
Up to 20 bits, right shifted into a 32 bit int

◆ readALS()

uint32_t Adafruit_LTR390::readALS ( void  )

Read 3-bytes out of ambient data register, does not check if data is new!

Returns
Up to 20 bits, right shifted into a 32 bit int

The documentation for this class was generated from the following files: