Categories
TUTORIALS

Interpreting AS7263 NIR Spectral Sensor Readings to Determine Plant Foliage Health and Turn on an LED

This tutorial uses the AS7263 NIR (near infrared) spectrometer sensor to assess plant foliage health. It explains how to uses the sensor’s channel readings and the standard Normalized Difference Vegetation Index (NDVI) equation to calculate an estimated NDVI value. It then prints the value and a “HEALTHY” or “UNHEALTHY” statement to the Serial Monitor and turns on an RGB LED to green or red to indicate whether the foliage is within the healthy or unhealthy range, respectively.

Background & Methodology

Leaf colour is a valuable indicator of a plant’s condition, and healthy leaves must have an abundance of chlorophyll to effectively photosynthesize. Our eyes perceive a healthy leaf as green because chlorophyll reflects wavelengths in the green region of the electromagnetic spectrum, while the other visible wavelengths are absorbed – notably those in the red region. Chlorophyll also reflects a high percentage of near-infrared wavelengths that are not visible to the naked eye.

To this end, remote sensing practitioners use NDVI to assess foliage health by measuring the difference between the amount of near-infrared (strongly reflected) and red (easily absorbed) light that is reflected off the foliage, using the following equation:

NDVI always ranges from -1 to +1, and healthy foliage falls within the 0.2 to 0.8 range.

For this tutorial, we will apply this method to a single plant’s leaves by plugging in readings from the AS7263 NIR sensor into the NDVI equation. The sensor detects wavelengths across 6 channels and puts out readings as counts per μW/cm2, which gives a measure of the amount of incident light that is being reflected at each wavelength. Two of the sensor’s channels are close to the wavelengths that are typically used in the NDVI equation. These channels are S and V, giving out readings for the 680 nm (still in the red range) and 810 nm (near-infrared) wavelengths, respectively. Once the NDVI value is calculate, we can use an ifelse statement to signal whether the foliage is within a healthy range.

Parts

  • (1) Arduino Uno microcontroller (MCU)
  • (1) 830 Tie Points Breadboard
  • (1) Qwiic AS7263 NIR Spectral Sensor
  • (1) Qwiic Shield for Arduino
  • (1) Qwiic Cable
  • (4) M-M wires
  • (1) RGB LED

*** In this case, you do not need resistors because the AS7263 sensor and LED together, on average, pull 5V – the MCU’s total output voltage.

Wiring

1. Assuming that the pins are already soldered to the Qwiic Shield, secure the shield to the MCU and use the standard Qwiic cable to connect the AS7263 sensor to the shield. For more information on the sensor’s hook up click here.

2. Then insert the RGB LED pins into the breadboard and connect the pins to the MCU through the shield with the M-M wires, as shown in the diagram below.

3. Connect the MCU to your computer.

*** To achieve optimal performance, the sensor should point down onto the foliage. It is also important to note that, per the sensor’s datasheet, the sensor is not designed for high energy UV (ultraviolet) environments, including upward looking outdoor applications.

AS7263 Spectral sensor and RGB LED wiring to MCU diagram.
Sensor and LED hookup example picture.

Code

1. Open your Arduino software and install the Sparkfun AS726X Arduino Library. Go to Sketch > Include Library > Manage Library… and search for “SparkFun AS726X.” Install the 1.0.4 version of the library. This library includes functions and example code for both the AS7263 NIR and AS7262 VIS (visible wavelengths) sensors.

2. Before running any new code, confirm that your sensor is functioning by running some sample code from the Sparkfun Library. Go to File > Examples > Sparkfun AS726X > Example_BasicReadings. Upload the example code and open your serial monitor, the printouts should look like this:

Serial monitor readings from Sparkfun AS726X Example_BasicReadings code.

3. If the sensor is functioning, then copy and paste the below code into a new sketch and upload, the code is commented throughout for your reference. Point your sensor down at your plant.

4. Open your serial monitor, the printouts should look like this:

Serial monitor readings using the NDVI readings code (above).

and depending on your plant’s condition, your RGB LED should light up as green or red.

References

Detailed Digikey Article about the AS726X’s Design and Operation

Sparksfun AS726X NIR/VIS Spectral Sensor Hookup Guide

NASA Page Describing Near-Infrared’s Use in Determining Vegetation Health

Development of NDVI Index from University of Bonn

One reply on “Interpreting AS7263 NIR Spectral Sensor Readings to Determine Plant Foliage Health and Turn on an LED”

Leave a Reply

Your email address will not be published. Required fields are marked *