![]() |
SparkFun Spectral UV Sensor - AS7331
v2.1.2-21-g3e22fb4
Library for the SparkFun Spectral UV Sensor - AS7331
|
Arduino Library for the SparkFun Spectral UV Sensor - AS7331 Sensor
The SparkFun Spectral UV Sensor - AS7331 (SEN-23517) and SEN-23518 features the AS7331 UV sensor from ams OSRAMĀ©. It measures UV radiation on three channels: UVA (320-400nm), UVB (280-320nm), and UVC (200-280nm) with high sensitivity and accuracy. The three channels on the AS7331 each have individual photodiodes with built-in interference filters. This Mini-sized breakout board is only 0.5in. by 1in. big and has three operating modes: Single Measurement (CMD), Continuous Measurement (CONT), SYNchronized Start (SYNS), and SYNchronized Start & End (SYND), with an automatic power-down sequence between measurements for low current consumption in all three modes.
Looking for the board that matches this library - pick up a SparkFun Spectral UV Sensor - AS7331 (SEN-23517) or a SparkFun Mini Spectral UV Sensor - AS7331 (SEN-23518) at www.sparkfun.com.
This library provides an interface that enables the following functionality when using one of the SparkFun Spectral UV Sensor - AS7331 Sensors:
The following outlines the general use of the library in an Arduino Sketch.
At the start of your sketch, the library header file is included using the following statement:
Before the arduino setup()
function, create a Soil Sensor object in your file with the following declaration:
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.
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.
After the sensor is initialized, any configuration values are normally set. The following demonstrates how to configure the operating mode of the sensor.
The above command sets up the sensor to operate in a OneShot mode.
To read a value, the first step is to start a measurement, and wait for at least the sensors "conversion time" to expire.
Once the conversion period is complete, the values are read from the device with the following command:
At this point the values from the sensor are available locally in the library and accessed using the following commands:
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.
The following examples are provided with the library
measures.outputConversionTime
field in units of number of clock cycles.The full API and use documentation for this library is provided here. For a quick reference, the main methods available in the library are listed here.
Curious about the hardware this board works with - visit the SparkFun Spectral UV Sensor hardware repository.
The Hookup Guide for the SparkFun Spectral UV Sensor is available here.
This product is open source!
This product is licensed using the MIT Open Source License.