Product Overview

1/31/2018 AS726X NIR/VIS Spectral Sensor Hookup Guide - learn.sparkfun.com
https://learn.sparkfun.com/tutorials/as726x-nirvi?_ga=2.149930550.1022152466.1517244327-204410570.1509632255 5/8
Library Overview
Before we get started, we’ll need to download and install SparkFun’s AS726X Arduino library.
DOWNLOAD THE SPARKFUN AS726X LIBRARY
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your
first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously
installed an Arduino library, please check out our installation guide.
Before we get started developing a sketch, let’s look at the available functions of the library.
void begin(TwoWire &wirePort, byte gain, byte measurementMode); — Initializes the sensor with user given
values for the wire port, gain, and measurement
void takeMeasurements(); — Sensor writes spectral measurements to memory locations.
void takeMeasurementsWithBulb(); — Illuminates onboard bulb, calls takeMeasurements(); , then turns off
the onboard bulb.
void printMeasurements(); — Fetches data from memory and outputs calibrated measurements
using Serial.print();
void printUncalibratedMeasurements(); — Fetches data from memory and outputs uncalibrated
measurements using Serial.print();
byte getTemperature(); — Fetches the temperature in degrees Celsius.
float getTemperatureF(); — Fetches the temperature in degrees Fahrenheit.
void setMeasurementMode(byte mode); — Changes the measurement mode to 0, 1, 2, or 3
0: Continuous reading of VBGY (Visible) / STUV (IR)
1: Continuous reading of GYOR (Visible) / RTUX (IR)
2: Continuous reading of all channels
3: One-shot reading of all channels (power-on default)
boolean dataAvailable(); — Returns true or false based on whether or not data is available to be
read.