-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathveml7700_autolux.ino
52 lines (45 loc) · 1.66 KB
/
veml7700_autolux.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* VEML7700 Auto Lux Example
*
* This example sketch demonstrates reading lux using the automatic
* method which adjusts gain and integration time as needed to obtain
* a good reading. A non-linear correction is also applied if needed.
*
* See Vishy App Note "Designing the VEML7700 Into an Application"
* Vishay Document Number: 84323, Fig. 24 Flow Chart
*/
#include "Adafruit_VEML7700.h"
Adafruit_VEML7700 veml = Adafruit_VEML7700();
void setup() {
Serial.begin(115200);
while (!Serial) { delay(10); }
Serial.println("Adafruit VEML7700 Auto Lux Test");
if (!veml.begin()) {
Serial.println("Sensor not found");
while (1);
}
Serial.println("Sensor found");
}
void loop() {
// to read lux using automatic method, specify VEML_LUX_AUTO
float lux = veml.readLux(VEML_LUX_AUTO);
Serial.println("------------------------------------");
Serial.print("Lux = "); Serial.println(lux);
Serial.println("Settings used for reading:");
Serial.print(F("Gain: "));
switch (veml.getGain()) {
case VEML7700_GAIN_1: Serial.println("1"); break;
case VEML7700_GAIN_2: Serial.println("2"); break;
case VEML7700_GAIN_1_4: Serial.println("1/4"); break;
case VEML7700_GAIN_1_8: Serial.println("1/8"); break;
}
Serial.print(F("Integration Time (ms): "));
switch (veml.getIntegrationTime()) {
case VEML7700_IT_25MS: Serial.println("25"); break;
case VEML7700_IT_50MS: Serial.println("50"); break;
case VEML7700_IT_100MS: Serial.println("100"); break;
case VEML7700_IT_200MS: Serial.println("200"); break;
case VEML7700_IT_400MS: Serial.println("400"); break;
case VEML7700_IT_800MS: Serial.println("800"); break;
}
delay(1000);
}