22 #ifndef __SENSORS_VEML6070_h__
23 #define __SENSORS_VEML6070_h__
25 #define VEML6070_ADDR_H 0x39
26 #define VEML6070_ADDR_L 0x38
37 typedef enum veml6070_integrationtime {
42 } veml6070_integrationtime_t;
46 template <u
int8_t INTEGRATION_TIME=VEML6070_1_T>
54 if (Wire.requestFrom(VEML6070_ADDR_H, 1) != 1)
return -1;
55 uint16_t uvi = Wire.read();
57 if (Wire.requestFrom(VEML6070_ADDR_L, 1) != 1)
return -1;
64 Wire.beginTransmission(VEML6070_ADDR_L);
65 Wire.write((INTEGRATION_TIME << 2) | 0x02);
66 Wire.endTransmission();
68 _present = (readUV() < 65535);
71 void measure (__attribute__((unused))
bool async=
false) {
72 if( present() ==
true ) {
74 if (INTEGRATION_TIME == VEML6070_HALF_T) {
75 DPRINTLN(F(
"UV Index calc. with VEML6070_HALF_T not supported"));
78 uint8_t _integration_time_factor = (INTEGRATION_TIME == VEML6070_4_T) ? 4 : INTEGRATION_TIME;
79 _uvindex = (_uvvalue < (12 * (187 * _integration_time_factor))) ? (_uvvalue + 1) / (187 * _integration_time_factor) : 11;
82 uint16_t UVValue () {
return _uvvalue; }
83 uint8_t UVIndex () {
return _uvindex; }