VEML6070 ultraviolet light sensor and micro:bit example

VEML6070 is an advanced ultraviolet (UV) light sensor with I2C protocol interface and designed by the CMOS process. It is easily operated via a simple I2C command. The active acknowledge (ACK) feature with threshold windows setting allows the UV sensor to send out a UVI alert message.

Under a strong solar UVI condition, the smart ACK signal can be easily implemented by the software programming.

VEML6070 incorporates a photodiode, amplifiers, and analog / digital circuits into a single chip. VEML6070’s adoption of FiltronTM UV technology provides the best spectral sensitivity to cover UV spectrum sensing. It has an
excellent temperature compensation and a robust refresh rate setting that does not use an external RC low pass filter.

VEML6070 has linear sensitivity to solar UV light and is easily adjusted by an external resistor. Software shutdown mode is provided, which reduces power consumption to be less than 1 μA. VEML6070’s operating voltage ranges from 2.7 V to 5.5 V.

 

Shopping List

Amount Part Type
1 VEML6070
1 BBC micro:bit bulk micro-controller with motion detection, compass, LED display and Bluetooth

Schematics/Layout

 

microbit and VEML6070
microbit and VEML6070

Code

No libraries in this example

#include <Wire.h>
 
// VEML6070 I2C address is 0x38(56)
#define Addr 0x38
 
void setup()
{
  // Initialise I2C communication as MASTER
  Wire.begin();
  // Initialise serial communication, set baud rate = 9600
  Serial.begin(9600);
 
    // Start I2C Transmission
    Wire.beginTransmission(Addr);
    // Select command register
    // Integration time = 0.5T, shutdown mode disable 
    Wire.write(0x02);
    // Stop I2C Transmission
    Wire.endTransmission();
  delay(300);
}
 
void loop() 
{
  unsigned int data[2];
 
  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Select data msb register
  Wire.write(0x73);
  // Stop I2C Transmission
    Wire.endTransmission();
 
  // Request 1 byte of data
  Wire.requestFrom(Addr, 1);
 
  // Read 1 byte of data
    if(Wire.available() == 1)
    {
    data[0] = Wire.read();
    }
 
  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Select data register
  Wire.write(0x71);
    // Stop I2C Transmission
    Wire.endTransmission();
 
  // Request 1 byte of data
    Wire.requestFrom(Addr, 1);
 
    // Read 1 byte of data
    if(Wire.available() == 1)
    {
        data[1] = Wire.read();
    }
 
  // Convert the data
  float uvlight = data[0] * 256.0 + data[1];
 
  // Output data to serial monitor
    Serial.print("UV Light Of The Device");
    Serial.println(uvlight);
    delay(1000);     
}

 

Output

Open the serial monitor – this is what I saw. I was indoors at the time

UV Light Of The Device0.00
UV Light Of The Device0.00
UV Light Of The Device0.00
UV Light Of The Device0.00
UV Light Of The Device0.00
UV Light Of The Device0.00

 

Links

https://www.vishay.com/docs/84277/veml6070.pdf

VEML6070 UV Sensitivity Detection Sensor for Arduino