Gravity: LTR390 UV Light Sensor Ultraviolet/Visible Light Wiki - DFRobot

1. Introduction

This Gravity: LTR390-UV sensor from DFRobot provides both ambient light and UV sensing with UV spectral response from 280nm to 430nm and raw data output. It features high sensitivity, quick response, and strong anti-interference ability.
With built-in ADC and MCU, this UV module can convert light data to a digital signal capable of being directly output via I2C or UART interface. It can be used for light experiments, outdoor UV detection, and other scenarios requiring UV or ambient light monitoring.

2. Features

3. Application

4. Board Overview

Label Full Name Description
D/T SDA/TXD I2C Data Line/UART Transmit Data
C/R SCL/RXD I2C Clock Line/UART Receive Data
- Power -
+ Power + (DC 3.3V-5V)

Note: Select I2C or UART mode by DIP switch.

5. Specification

6. Dimension

7. Tutorial for Arduino UNO

7.1 Hardware Requirements

7.2 Software Requirements

7.3 Connection Diagram

I2C Connection Diagram

Pin Connections:

UV Sensor: + (to) Arduino UNO: 5V

UV Sensor: - (to) Arduino UNO: GND

UV Sensor: D (to) Arduino UNO: SDA

UV Sensor: C (to) Arduino UNO: SCL

UART Connection Diagram

Pin Connections:

UV Sensor: + (to) Arduino UNO: 5V

UV Sensor: - (to) Arduino UNO: GND

UV Sensor: T (to) Arduino UNO: 4

UV Sensor: R (to) Arduino UNO: 5

7.4 Sample Code

I2C Mode

Ambient Light

#include "DFRobot_LTR390UV.h"
DFRobot_LTR390UV ltr390(/*addr = */LTR390UV_DEVICE_ADDR, /*pWire = */&Wire);

void setup()
{
  Serial.begin(115200);
  while(ltr390.begin() != 0){
    Serial.println(" Sensor initialize failed!!");
    delay(1000);
  }
  Serial.println(" Sensor  initialize success!!");
  ltr390.setALSOrUVSMeasRate(ltr390.e18bit,ltr390.e100ms);//18-bit data, sampling time of 100ms 
  ltr390.setALSOrUVSGain(ltr390.eGain3);//Gain of 3
  ltr390.setMode(ltr390.eALSMode);//Set ambient light mode 
}
void loop()
{
  float als = 0;
  als = ltr390.readALSTransformData();//Get data converted from ambient light intensity, which can only be used in ambient light mode
  Serial.print("ALS:");
  Serial.print(als);
  Serial.println("Lux");
  delay(1000);
}

Result

Serial print ambient light data (in an office with strong light).

Note: Ambient Light Reference Range

Place/Environment Illuminance
Sunny day 30000-300000 lux
Indoors on sunny day 100-1000 lux
Cloudy day 3000-10000 lux
Outdoors on cloudy day 50-500 lux
Indoors on cloudy day 5-50 lux
Indoors at dusk 10 lux
At sunrise and sunset 300 lux
At night 0.001-0.02 lux
Moonlit evening 0.02-0.3 lux
Lightless office 30-50 lux
Exposure to flashlight light 8000-15000 lux

UV Light

#include "DFRobot_LTR390UV.h"
DFRobot_LTR390UV ltr390(/*addr = */LTR390UV_DEVICE_ADDR, /*pWire = */&Wire);

void setup()
{
  Serial.begin(115200);
  while(ltr390.begin() != 0){
    Serial.println(" Sensor initialize failed!!");
    delay(1000);
  }
  Serial.println(" Sensor  initialize success!!");
  ltr390.setALSOrUVSMeasRate(ltr390.e18bit,ltr390.e100ms);//18-bit data, sampling time of 100ms 
  ltr390.setALSOrUVSGain(ltr390.eGain3);//Gain of 3
  ltr390.setMode(ltr390.eUVSMode);//Set UV mode 
}
void loop()
{
  uint32_t data = 0;
  data = ltr390.readOriginalData();//Get UV raw data
  Serial.print("data:");
  Serial.println(data);
  delay(1000);
}

Result

Serial print UV raw data (in the environment without direct sunlight on sunny day).

UART Mode

Ambient Light

#include "DFRobot_LTR390UV.h"
#include <SoftwareSerial.h>
#define UARTMODE //UART mode

SoftwareSerial mySerial(/*rx =*/4, /*tx =*/5);
DFRobot_LTR390UV ltr390(/*addr =*/LTR390UV_DEVICE_ADDR, /*s =*/&mySerial);

void setup()
{
  #define UARTMODE
  mySerial.begin(9600);
  Serial.begin(115200);
  while(ltr390.begin() != 0){
    Serial.println(" Sensor initialize failed!!");
    delay(1000);
  }
  Serial.println(" Sensor  initialize success!!");
  ltr390.setALSOrUVSMeasRate(ltr390.e18bit,ltr390.e100ms);//18-bit data, sampling time of 100ms 
  ltr390.setALSOrUVSGain(ltr390.eGain3);//Gain of 3
  ltr390.setMode(ltr390.eALSMode);//Set ambient light mode 
}

void loop()
{
  float als = 0;
  als = ltr390.readALSTransformData();//Get the data converted from ambient light intensity, which can only be used in ambient light mode
  Serial.print("ALS:");
  Serial.print(als);
  Serial.println("Lux");
  delay(100);
}

Result

Serial print ambient light data (in an office with strong light).

UV Light

#include "DFRobot_LTR390UV.h"
#include <SoftwareSerial.h>
#define UARTMODE //UART mode

SoftwareSerial mySerial(/*rx =*/4, /*tx =*/5);
DFRobot_LTR390UV ltr390(/*addr =*/LTR390UV_DEVICE_ADDR, /*s =*/&mySerial);

void setup()
{
  #define UARTMODE
  mySerial.begin(9600);
  Serial.begin(115200);
  while(ltr390.begin() != 0){
    Serial.println(" Sensor initialize failed!!");
    delay(1000);
  }
  Serial.println(" Sensor  initialize success!!");
  ltr390.setALSOrUVSMeasRate(ltr390.e18bit,ltr390.e100ms);//18-bit data, sampling time of 100ms 
  ltr390.setALSOrUVSGain(ltr390.eGain3);//Gain of 3
  ltr390.setMode(ltr390.eUVSMode);//Set UV mode 
}

void loop()
{
  uint32_t data = 0;
  data = ltr390.readOriginalData();//Get UV raw data
  Serial.print("data:");
  Serial.println(data);
  delay(100);
}

Result

Serial print UV raw data (in the environment without direct sunlight on sunny day).

8. API

 /**
   * @fn begin
   * @brief Init SEN0540 device
   * @return Return value init status
   * @retval 0  Succeed
   * @retval -1 Failed
   */
  int8_t begin(void);

  /**
   * @fn setMode
   * @brief Set data collecting mode for module
   * @param mode select data collecting mode 
   * @return NONE
   */
  void setMode(eModel_t mode);

  /**
   * @fn setALSOrUVSMeasRate
   * @brief Set data bit and sampling time of module, the sampling time must be greater than the time the bit needs
   * @n --------------------------------------------------------------------------------------------------------
   * @n |    bit7    |    bit6    |    bit5    |    bit4    |    bit3    |    bit2    |    bit1    |    bit0    |
   * @n ---------------------------------------------------------------------------------------------------------
   * @n |  Reserved  |        ALS/UVS Resolution            |  Reserved  |   ALS/UVS Measurement Rate           |
   * @n ---------------------------------------------------------------------------------------------------------
   * @n | ALS/UVS Resolution       |000|20 Bit, Conversion time = 400ms                                         |
   * @n |                          |001|19 Bit, Conversion time = 200ms                                         |
   * @n |                          |010|18 Bit, Conversion time = 100ms(default)                                |
   * @n |                          |011|17 Bit, Conversion time = 50ms                                          |
   * @n |                          |100|16 Bit, Conversion time = 25ms                                          |
   * @n |                          |110/111|Reserved                                                            |
   * @n ---------------------------------------------------------------------------------------------------------
   * @n | ALS/UVS Measurement Rate |000|25ms                                                                    |
   * @n |                          |001|50ms                                                                    |
   * @n |                          |010|100ms (default)                                                         |
   * @n |                          |011|200ms                                                                   |
   * @n |                          |100|500ms                                                                   |
   * @n |                          |101|1000ms                                                                  |
   * @n |                          |110/111|2000ms                                                              |
   * @n ---------------------------------------------------------------------------------------------------------
   * @param bit Set data bit 
   * @param time Set sampling time
   * @return None
   */
 void setALSOrUVSMeasRate(eResolution bit,eMeasurementRate time);

  /**
   * @fn setALSOrUVSGain
   * @brief Set sensor gain 
   * @n ---------------------------------------------------------------------------------------------------------
   * @n |    bit7    |    bit6    |    bit5    |    bit4    |    bit3    |    bit2    |    bit1    |    bit0    |
   * @n ---------------------------------------------------------------------------------------------------------
   * @n |                                    Reserved                    |          ALS/UVS Gain Range          |
   * @n ---------------------------------------------------------------------------------------------------------
   * @n | ALS/UVS Gain Range       |000|Gain Range: 1                                                           |
   * @n |                          |001|Gain Range: 3 (default)                                                 |
   * @n |                          |010|Gain Range: 6                                                           |
   * @n |                          |011|Gain Range: 9                                                           |
   * @n |                          |100|Gain Range: 18                                                          |
   * @n |                          |110/111|Reserved                                                            |
   * @n ---------------------------------------------------------------------------------------------------------                  
   * @param data Control data 
   * @return None
   */
  void setALSOrUVSGain(eGainRange data);


  /**
   * @fn readData
   * @brief Get raw data
   * @return Return the obtained raw data
   */
  uint32_t readOriginalData(void);

9. More Documents

SEN0540 STP 3D Model.rar

SEN0540 2D CAD Dimension.rar

SEN0540_2D_CAD.pdf

[SEN0540 Schematics].pdf

LTR390-UV Datasheet.pdf

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

DFshopping_car1.png Get Gravity: LTR390-UV Sensor from DFRobot Store or DFRobot Distributor.

Turn to the Top