MSP430FR4133 LaunchPad and VEML6070 sensor example using Energia

In this example we look at an VEML6070 UV sensor and connect it to a MSP430FR4133 LaunchPad.

First a little about this sensor

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.

You can find out about the UV index at the following link – https://en.wikipedia.org/wiki/Ultraviolet_index

This is the key chart from this site and one of the reasons that a UV index meter is so important

UV Index Media graphic color Risk of harm from unprotected sun exposure, for the average adult Recommended protection
0.0–2.9 Green “Low” A UV Index reading of 0 to 2 means low danger from the sun’s UV rays for the average person.Wear sunglasses on bright days. If you burn easily, cover up and use broad spectrum SPF 30+ sunscreen. Bright surfaces, such as sand, water and snow, will increase UV exposure.
3.0–5.9 Yellow “Moderate” A UV Index reading of 3 to 5 means moderate risk of harm from unprotected sun exposure.Stay in shade near midday when the sun is strongest. If outdoors, wear sun protective clothing, a wide-brimmed hat, and UV-blocking sunglasses. Generously apply broad spectrum SPF 30+ sunscreen every 2 hours, even on cloudy days, and after swimming or sweating. Bright surfaces, such as sand, water and snow, will increase UV exposure.
6.0–7.9 Orange “High” A UV Index reading of 6 to 7 means high risk of harm from unprotected sun exposure. Protection against skin and eye damage is needed.Reduce time in the sun between 10 a.m. and 4 p.m. If outdoors, seek shade and wear sun protective clothing, a wide-brimmed hat, and UV-blocking sunglasses. Generously apply broad spectrum SPF 30+ sunscreen every 2 hours, even on cloudy days, and after swimming or sweating. Bright surfaces, such as sand, water and snow, will increase UV exposure.
8.0–10.9 Red “Very high” A UV Index reading of 8 to 10 means very high risk of harm from unprotected sun exposure. Take extra precautions because unprotected skin and eyes will be damaged and can burn quickly.Minimize sun exposure between 10 a.m. and 4 p.m. If outdoors, seek shade and wear sun protective clothing, a wide-brimmed hat, and UV-blocking sunglasses. Generously apply broad spectrum SPF 30+ sunscreen every 2 hours, even on cloudy days, and after swimming or sweating. Bright surfaces, such as sand, water and snow, will increase UV exposure.
11.0+ Violet “Extreme” A UV Index reading of 11 or more means extreme risk of harm from unprotected sun exposure. Take all precautions because unprotected skin and eyes can burn in minutes.Try to avoid sun exposure between 10 a.m. and 4 p.m. If outdoors, seek shade and wear sun protective clothing, a wide-brimmed hat, and UV-blocking sunglasses. Generously apply broad spectrum SPF 30+ sunscreen every 2 hours, even on cloudy days, and after swimming or sweating. Bright surfaces, such as sand, water and snow, will increase UV exposure.

The easiest way to work with this sensor is to buy a module – this is a picture of the module that I bought

Parts Required

 

Name Link
MSP430FR4133 LaunchPad MSP430FR4133 LaunchPad development board MSP-EXP430FR4133
VEML6070 CJMCU-6070 GY-VEML6070 UV UV light sensor
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Schematic/Connection

Here are the connectors on the launchpad

 

MSP430FR4133 Launchpad Sensor
3.3v Vdd
Gnd Gnd
SDA P8_2 SDA
SCL P8_3 SCL

 

Code

[codesyntax lang=”cpp”]

#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);     
}

[/codesyntax]

Output

Open the serial monitor – just as a note in my example I was indoors – hence the UV value was 0

UV light level: 0
UV light level: 0
UV light level: 0
UV light level: 0

 

 

Related posts

MSP430FR4133 LaunchPad and SHT31 sensor example using Energia

MSP430FR4133 LaunchPad and ADS1115 ADC example using Energia

MSP430FR4133 LaunchPad and TSL2561 Sensor example using Energia