概述
VEML6075是一个能够检测UVA和UVB波段紫外线强度的传感器,从而测量出紫外线指数UVI。内置温度补偿可以很好的抑制温度对传感器的输出数据的影响。每通道数据输出可达16bit精度。IIC数字通信接口。工作电压1.7V-3.6V。下图为归一化光谱响应范围
Arduino UNO与VEML6075接线
Arduino UNO | VEML6075 |
---|---|
A4 | SDA |
A5 | SCL |
3.3V | VCC |
GND | GND |
示例程序
打开Arduino IDE的库管理器搜索VEML6075并安装一个库,打开示例程序
#include <Wire.h>
#include <DFRobot_VEML6075.h>
#define VEML6075_ADDR 0x10
DFRobot_VEML6075_IIC VEML6075(&Wire, VEML6075_ADDR); // create object
void setup()
{
Serial.begin(115200);
delay(2000);
while (!Serial);
Serial.println();
while (VEML6075.begin() != true) {
Serial.println("VEML6075 begin faild");
delay(2000);
}
Serial.println("VEML6075 begin successed");
}
void loop()
{
uint16_t UvaRaw = VEML6075.readUvaRaw(); // read UVA raw
uint16_t UvbRaw = VEML6075.readUvbRaw(); // read UVB raw
uint16_t comp1Raw = VEML6075.readUvComp1Raw(); // read COMP1 raw
uint16_t comp2Raw = VEML6075.readUvComp2Raw(); // read COMP2 raw
float Uva = VEML6075.getUva(); // get UVA
float Uvb = VEML6075.getUvb(); // get UVB
float Uvi = VEML6075.getUvi(Uva, Uvb); // get UV index
Serial.println();
Serial.println("======== start print ========");
Serial.print("UVA raw: ");
Serial.println(UvaRaw);
Serial.print("UVB raw: ");
Serial.println(UvbRaw);
Serial.print("COMP1 raw: ");
Serial.println(comp1Raw);
Serial.print("COMP2 raw: ");
Serial.println(comp2Raw);
Serial.print("UVA: ");
Serial.println(Uva, 2);
Serial.print("UVB: ");
Serial.println(Uvb, 2);
Serial.print("UVIndex: ");
Serial.print(Uvi, 2);
if (Uvi < UVI_LOW)
Serial.println(" UVI low");
else if (Uvi < UVI_MODERATE)
Serial.println(" UVI moderate");
else if (Uvi < UVI_HIGH)
Serial.println(" UVI high");
else if (Uvi < UVI_VERY_HIGH)
Serial.println(" UVI very high");
else
Serial.println(" UVI extreme");
Serial.print("mw/cm^2: ");
Serial.println(Uvi2mwpcm2(Uvi), 2);
Serial.println("======== end print ========");
delay(1000);
}
在室内普通光线下测的结果为