You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking for the board that matches this library - pick up a [SparkFun Spectral UV Sensor - AS7331 (SEN-23517)](https://www.sparkfun.com/sparkfun-spectral-uv-sensor-as7331-qwiic.html) or a [SparkFun Mini Spectral UV Sensor - AS7331 (SEN-23518)](https://www.sparkfun.com/sparkfun-mini-spectral-uv-sensor-as7331-qwiic.html) at www.sparkfun.com.
19
-
20
-
## Functionality
21
-
22
-
This library provides an interface that enables the following functionality when using one of the SparkFun Spectral UV Sensor - AS7331 Sensors:
23
-
24
-
* Read values from the three UV channels of the sensor (UVA, UVB, UVC) separately or as a combined value
25
-
* Adjust the sensors gain values
26
-
* Set sensors clock speed and timing values
27
-
* Change the operating modes of the sensor
28
-
* Control the sensors power-down state
29
-
* Change the I2C address of the sensor
30
-
31
-
## General Use
32
-
33
-
The following outlines the general use of the library in an Arduino Sketch.
34
-
35
-
### Declaration
36
-
37
-
At the start of your sketch, the library header file is included using the following statement:
38
-
39
-
~~~cpp
40
-
#include<SparkFun_AS7331.h>
41
-
~~~
42
-
43
-
Before the arduino ```setup()``` function, create a Soil Sensor object in your file with the following declaration:
44
-
45
-
~~~c
46
-
SfeAS7331ArdI2C myUVSensor // Create an instance of the sensor class
47
-
~~~
48
-
49
-
### Initialization
50
-
51
-
In the Arduino ```setup()``` function, initialize the sensor by calling the begin method. This method is called after the Arduino `Wire` (I2C) library is initialized.
52
-
53
-
~~~cpp
54
-
// Initialize sensor and run default setup.
55
-
if (myUVSensor.begin() == false)
56
-
{
57
-
Serial.println("Sensor failed to begin. Please check your wiring!");
58
-
Serial.println("Halting...");
59
-
while (1)
60
-
;
61
-
}
62
-
~~~
15
+
This library provides full access to the functions of the AS7343 Spectral Sensor through an I2C connection using the SparkFun Qwiic connectors and cables. Interrupt features can also be utilized by soldering tot he INT pin on the 0.1-inch PTH headers.
63
16
64
-
The begin method returns true if the sensor is connected and available, and false if it is not. If a value of *false* is returned in the above example, the sketch execution is halted.
17
+
### Supported Products
18
+
This library is intended for use with the following SparkFun Product - available at [www.sparkfun.com](https://www.sparkfun.com).
65
19
66
-
After the sensor is initialized, any configuration values are normally set. The following demonstrates how to configure the operating mode of the sensor.
20
+
| Product | Description|
21
+
|--|--|
22
+
|[SparkFun Spectral Sensor - AS7343 (Qwiic)](https://www.sparkfun.com/products/23220)| The SparkFun AS7343 Qwiic Spectral Sensor enables users to measure 14 channels of spectral data including both the visible spectrum (VIS) and near-infrared (NIR) ranges, all on a single IC in a compact package. The AS7343 exhibits exceptional sensitivity across its sensing spectrum (~380nm to 1000nm) and operates reliably in low-light environments, including when measuring through tinted glass.|
67
23
68
-
~~~cpp
69
-
// Set measurement mode and change device operating mode to measure.
70
-
if (myUVSensor.prepareMeasurement(MEAS_MODE_CMD) == false)
71
-
{
72
-
Serial.println("Sensor did not get set properly.");
73
-
Serial.println("Halting...");
74
-
while (1)
75
-
;
76
-
}
77
-
~~~
78
-
79
-
The above command sets up the sensor to operate in a *OneShot* mode.
80
-
81
-
### Usage
82
-
83
-
#### Read Value
84
-
85
-
To read a value, the first step is to start a measurement, and wait for at least the sensors "conversion time" to expire.
86
-
87
-
~~~cpp
88
-
// Send a start measurement command.
89
-
if (ksfTkErrOk != myUVSensor.setStartState(true))
90
-
Serial.println("Error starting reading!");
91
-
92
-
// Wait for a bit longer than the conversion time.
93
-
delay(2 + myUVSensor.getConversionTimeMillis());
94
-
~~~
95
-
96
-
Once the conversion period is complete, the values are read from the device with the following command:
97
-
98
-
~~~cpp
99
-
// Read UV values.
100
-
if (ksfTkErrOk != myUVSensor.readAllUV())
101
-
Serial.println("Error reading UV.");
102
-
~~~
103
-
104
-
At this point the values from the sensor are available locally in the library and accessed using the following commands:
105
-
106
-
~~~cpp
107
-
Serial.print("UVA:");
108
-
Serial.print(myUVSensor.getUVA());
109
-
Serial.print(" UVB:");
110
-
Serial.print(myUVSensor.getUVB());
111
-
Serial.print(" UVC:");
112
-
Serial.println(myUVSensor.getUVC());
113
-
~~~
24
+
## Documentation
114
25
115
-
The capabilities of this library are far more that outlined in this section. For more information consult the examples that are part of this library or the libraries documentation.
26
+
|Reference | Description |
27
+
|---|---|
28
+
|[Library Documentation](https://docs.sparkfun.com/SparkFun_AS7343_Arduino_Library/)| The full documentation and API for this Arduino library|
|[Hook Up Guide - SparkFun Spectral Sensor - AS7343 (Qwiic)](https://docs.sparkfun.com/SparkFun_Spectral_Sensor_Breakout_AS7343_Qwiic/)| Hardware Overview and Quick Start for the SparkFun Spectral Sensor - AS7343 (Qwiic)|
31
+
|[AS7343 Datasheet](https://cdn.sparkfun.com/assets/e/f/3/6/c/AS7343_DS001046_6-00.pdf)| Datasheet for the AS7343 IC|
32
+
|[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)| Basic information on how to install an Arduino library|
116
33
117
34
## Examples
118
35
119
36
The following examples are provided with the library
120
37
121
-
-[Basic One Shot](examples/Example01_Basic_OneShot/Example01_Basic_OneShot.ino) - This example shows how operate the AS7331 in the default CMD mode.
122
-
-[CONT Mode](examples/Example02_CONT_Mode/Example02_CONT_Mode.ino) - Shows how operate the AS7331 in CONT mode. The break time register sets the delay between measurements so that the processor can read out the results without interfering with the ADC.
123
-
-[SYNS Mode](examples/Example_03_LEDFlashMoisture/Example_03_LEDFlashMoisture.ino) - Shows how operate the AS7331 in SYNS mode. This uses the active low SYN pin to start the conversion and relies on an interrupt to signal the end of conversion.
124
-
-[SYND Mode](examples/Example04_SYND_Mode/Example04_SYND_Mode.ino) - Shows how operate the AS7331 in SYND mode. This uses the active low SYN pin to both start and stop the conversion. The conversion time is calculated and stored in the `measures.outputConversionTime` field in units of number of clock cycles.
38
+
| Example | Description |
39
+
|---|---|
40
+
|[Basic Readings](examples/Example_01_BasicReadings/Example_01_BasicReadings.ino)| Take basic readings from the sensor (reg/green/blue) and print them to the terminal.|
41
+
|[All Channels](examples/Example_02_AllChannels/Example_02_AllChannels.ino)| Take readings of all channels of data from the sensor and print them to the terminal.|
42
+
|[Gain](examples/Example_03_Gain/Example_03_Gain.ino)| Demonstrates how to adjust the gain of the sensor (making it more or less sensitive).|
43
+
|[Interrupt](examples/Example_04_Interrupt)| Shows how to set up a threshold and trigger an interrupt when the light reading crosses that threshold.|
44
+
|[Flicker Detection](examples/Example_05_FlickerDetection/Example_05_FlickerDetection.ino)| Demonstrates how to setup and use flicker detection. Prints status of detection to terminal. |
45
+
|[Sleep](examples/Example_06_Sleep/Example_06_Sleep.ino)| Shows how to put the sensor into sleep while not taking a reading to save power.|
46
+
|[Web Terminal Bar Graphs](examples/Example_07_WebTerminal_BarGraphs/Example_07_WebTerminal_BarGraphs.ino)| Outputs data in CSV to match nicely with the [SparkFun WebSerialPlotter tool](https://docs.sparkfun.com/SparkFun_WebSerialPlotter/).|
125
47
126
-
## Documentation
127
48
128
-
The full API and use documentation for this library is provided [here](http://docs.sparkfun.com/SparkFun_AS7331_Arduino_Library/). For a quick reference, the main methods available in the library are listed [here](https://docs.sparkfun.com/SparkFun_AS7331_Arduino_Library/class_sfe_a_s7331_ard_i2_c.html).
129
-
130
-
Curious about the hardware this board works with - visit the SparkFun Spectral UV Sensor [hardware repository](https://github.com/sparkfun/SparkFun_Spectral_UV_Sensor_AS7331).
131
-
132
-
The Hookup Guide for the SparkFun Spectral UV Sensor is available [here](https://sparkfun.github.io/SparkFun_Spectral_UV_Sensor_AS7331).
133
49
134
50
## License Information
135
51
136
52
This product is ***open source***!
137
53
138
-
This product is licensed using the [MIT Open Source License](https://opensource.org/license/mit).
54
+
This product is licensed using the [MIT Open Source License](https://opensource.org/license/mit).
0 commit comments