|
5 | 5 | * Paul Clark
|
6 | 6 | * SparkFun Electronics
|
7 | 7 | * November 4th 2021
|
8 |
| - * |
| 8 | + * |
9 | 9 | * This example demonstrates how to change the VEML7700's sensitivity (gain) and integration time settings.
|
10 |
| - * |
| 10 | + * |
11 | 11 | * Want to support open source hardware? Buy a board from SparkFun!
|
12 | 12 | * <br>SparkX smôl Environmental Peripheral Board (SPX-18976): https://www.sparkfun.com/products/18976
|
13 |
| - * |
| 13 | + * |
14 | 14 | * Please see LICENSE.md for the license information
|
15 |
| - * |
| 15 | + * |
16 | 16 | */
|
17 | 17 |
|
18 | 18 | #include <SparkFun_VEML7700_Arduino_Library.h> // Click here to get the library: http://librarymanager/All#SparkFun_VEML7700
|
19 | 19 |
|
20 |
| -VEML7700 mySensor; // Create a VEML7700 object |
| 20 | +SparkFunVEML7700 mySensor; // Create a VEML7700 object |
21 | 21 |
|
22 | 22 | void setup()
|
23 | 23 | {
|
24 |
| - Serial.begin(115200); |
25 |
| - Serial.println(F("SparkFun VEML7700 Example")); |
| 24 | + Serial.begin(115200); |
| 25 | + Serial.println(F("SparkFun VEML7700 Example")); |
26 | 26 |
|
27 |
| - Wire.begin(); |
| 27 | + Wire.begin(); |
28 | 28 |
|
29 |
| - //mySensor.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial |
| 29 | + // mySensor.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial |
30 | 30 |
|
31 |
| - // Begin the VEML7700 using the Wire I2C port |
32 |
| - // .begin will return true on success, or false on failure to communicate |
33 |
| - if (mySensor.begin() == false) |
34 |
| - { |
35 |
| - Serial.println("Unable to communicate with the VEML7700. Please check the wiring. Freezing..."); |
36 |
| - while (1) |
37 |
| - ; |
38 |
| - } |
| 31 | + // Begin the VEML7700 using the Wire I2C port |
| 32 | + // .begin will return true on success, or false on failure to communicate |
| 33 | + if (mySensor.begin() == false) |
| 34 | + { |
| 35 | + Serial.println("Unable to communicate with the VEML7700. Please check the wiring. Freezing..."); |
| 36 | + while (1) |
| 37 | + ; |
| 38 | + } |
39 | 39 |
|
40 |
| - //The default integration time is 100ms. |
41 |
| - //Possible values are: |
42 |
| - //VEML7700_INTEGRATION_25ms |
43 |
| - //VEML7700_INTEGRATION_50ms |
44 |
| - //VEML7700_INTEGRATION_100ms |
45 |
| - //VEML7700_INTEGRATION_200ms |
46 |
| - //VEML7700_INTEGRATION_400ms |
47 |
| - //VEML7700_INTEGRATION_800ms |
48 |
| - //Let's change the integration time to 50ms: |
49 |
| - mySensor.setIntegrationTime(VEML7700_INTEGRATION_50ms); |
| 40 | + // The default integration time is 100ms. |
| 41 | + // Possible values are: |
| 42 | + // VEML7700_INTEGRATION_25ms |
| 43 | + // VEML7700_INTEGRATION_50ms |
| 44 | + // VEML7700_INTEGRATION_100ms |
| 45 | + // VEML7700_INTEGRATION_200ms |
| 46 | + // VEML7700_INTEGRATION_400ms |
| 47 | + // VEML7700_INTEGRATION_800ms |
| 48 | + // Let's change the integration time to 50ms: |
| 49 | + mySensor.setIntegrationTime(VEML7700_INTEGRATION_50ms); |
50 | 50 |
|
51 |
| - //Confirm the integration time was set correctly |
52 |
| - Serial.print(F("The sensor integration time is: ")); |
53 |
| - Serial.println(mySensor.getIntegrationTimeStr()); |
| 51 | + // Confirm the integration time was set correctly |
| 52 | + Serial.print(F("The sensor integration time is: ")); |
| 53 | + Serial.println(mySensor.integrationTimeString()); |
54 | 54 |
|
55 |
| - //The default gain (sensitivity mode) is x1 |
56 |
| - //Possible values are: |
57 |
| - //VEML7700_SENSITIVITY_x1 |
58 |
| - //VEML7700_SENSITIVITY_x2 |
59 |
| - //VEML7700_SENSITIVITY_x1_8 |
60 |
| - //VEML7700_SENSITIVITY_x1_4 |
61 |
| - //Let's change the sensitivity to x2: |
62 |
| - mySensor.setSensitivityMode(VEML7700_SENSITIVITY_x2); |
| 55 | + // The default gain (sensitivity mode) is x1 |
| 56 | + // Possible values are: |
| 57 | + // VEML7700_SENSITIVITY_x1 |
| 58 | + // VEML7700_SENSITIVITY_x2 |
| 59 | + // VEML7700_SENSITIVITY_x1_8 |
| 60 | + // VEML7700_SENSITIVITY_x1_4 |
| 61 | + // Let's change the sensitivity to x2: |
| 62 | + mySensor.setSensitivityMode(VEML7700_SENSITIVITY_x2); |
63 | 63 |
|
64 |
| - //Confirm that the sensitivity mode was set correctly |
65 |
| - Serial.print(F("The sensor gain (sensitivity mode) is: ")); |
66 |
| - Serial.println(mySensor.getSensitivityModeStr()); |
| 64 | + // Confirm that the sensitivity mode was set correctly |
| 65 | + Serial.print(F("The sensor gain (sensitivity mode) is: ")); |
| 66 | + Serial.println(mySensor.sensitivityModeString()); |
67 | 67 |
|
68 |
| - //We can also change the persistence ptotect number. Default is 1. |
69 |
| - //Possible values are: |
70 |
| - //VEML7700_PERSISTENCE_1 |
71 |
| - //VEML7700_PERSISTENCE_2 |
72 |
| - //VEML7700_PERSISTENCE_4 |
73 |
| - //VEML7700_PERSISTENCE_8 |
74 |
| - //Let's change the persistence protect to 4: |
75 |
| - mySensor.setPersistenceProtect(VEML7700_PERSISTENCE_4); |
| 68 | + // We can also change the persistence ptotect number. Default is 1. |
| 69 | + // Possible values are: |
| 70 | + // VEML7700_PERSISTENCE_1 |
| 71 | + // VEML7700_PERSISTENCE_2 |
| 72 | + // VEML7700_PERSISTENCE_4 |
| 73 | + // VEML7700_PERSISTENCE_8 |
| 74 | + // Let's change the persistence protect to 4: |
| 75 | + mySensor.setPersistenceProtect(VEML7700_PERSISTENCE_4); |
76 | 76 |
|
77 |
| - //Confirm that the persistence protect was set correctly |
78 |
| - Serial.print(F("The sensor persistence protect setting is: ")); |
79 |
| - Serial.println(mySensor.getPersistenceProtectStr()); |
| 77 | + // Confirm that the persistence protect was set correctly |
| 78 | + Serial.print(F("The sensor persistence protect setting is: ")); |
| 79 | + Serial.println(mySensor.persistenceProtectString()); |
80 | 80 |
|
81 |
| - Serial.println(F("Lux:\tAmbient:\tWhite Level:")); |
| 81 | + Serial.println(F("Lux:\tAmbient:\tWhite Level:")); |
82 | 82 | }
|
83 | 83 |
|
84 | 84 | void loop()
|
85 | 85 | {
|
86 |
| - Serial.print(mySensor.getLux(), 4); // Read the lux from the sensor and print it |
87 |
| - Serial.print("\t"); |
88 |
| - Serial.print(mySensor.getAmbientLight()); // Read the ambient light level |
89 |
| - Serial.print("\t"); |
90 |
| - Serial.println(mySensor.getWhiteLevel()); // Read the white channel level |
91 |
| - delay(250); |
| 86 | + Serial.print(mySensor.getLux(), 4); // Read the lux from the sensor and print it |
| 87 | + Serial.print("\t"); |
| 88 | + Serial.print(mySensor.getAmbientLight()); // Read the ambient light level |
| 89 | + Serial.print("\t"); |
| 90 | + Serial.println(mySensor.getWhiteLevel()); // Read the white channel level |
| 91 | + delay(250); |
92 | 92 | }
|
0 commit comments