VEML6070 ultraviolet light sensor and Beaglebone example

0
96

In this article we look at an VEML6070 connected to a Beaglebone first of all lets look at the 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 IndexMedia graphic colorRisk of harm from unprotected sun exposure, for the average adultRecommended protection
0.0–2.9Green“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.9Yellow“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.9Orange“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.9Red“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

 

NameLink
Beaglebone BeagleBone Black TI AM3358 Cortex-A8 development BB-Black Rev.C
VEML6070VEML6070 UV Sensitivity Detection Sensor
Connecting wireDupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic/Connection

beaglebone and veml6070
beaglebone and veml6070

Code Example

This is a controleverything example – they have code examples for various platforms. This is the C example from

Save this as VEML6070.c, I used the Cloud 9 IDE

#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <fcntl.h>
 
void main() 
{
	// Create I2C bus
	int file;
	char *bus = "/dev/i2c-2";
	if((file = open(bus, O_RDWR)) < 0) 
	{
		printf("Failed to open the bus. \n");
		exit(1);
	}
	// Get I2C device, VEML6070 I2C address is 0x38(56)
	ioctl(file, I2C_SLAVE, 0x38);
 
	// Select command register(0x02)
	// Integration time = 0.5T, shutdown mode disabled
	char config[1] = {0};
	config[0] = 0x02;
	write(file, config, 1);
	sleep(1);
 
	// Read 2 bytes of data
	// Read uvlight msb from register(0x73)
	char reg[1] = {0x73};
	write(file, reg, 1);
	char data[1] = {0};
	if(read(file, data, 1) != 1)
	{
		printf("Erorr : Input/output Erorr \n");
		exit(1);
	}
	int data_0 = data[0];
 
	// Read uvlight lsb from register(0x71)
	reg[0] = 0x71;
	write(file, reg, 1);
	read(file, data, 1);
	int data_1 = data[0];
 
	// Convert the data 
	int uvlight = (data_0 * 256 + data_1);
 
	// Output to screen
	printf("UV Light of The Device : %d \n", uvlight);
}

First of all compile the c program.

$>gcc VEML6070.c -o VEML6070

Run the c program.

$>./VEML6070

Output

After running you should see something like this. this was 2 runs and the sensor was indoors

debian@beaglebone:/var/lib/cloud9/ ./veml6070
UV Light of The Device : 0
debian@beaglebone:/var/lib/cloud9/ ./veml6070
UV Light of The Device : 0

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.