Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Sensors & Modules

AS7341 Spectral Sensor: Measure Light Colors with Arduino

AS7341 Spectral Sensor: Measure Light Colors with Arduino

March 11, 2026 /Posted byJayesh Jain / 0

Most light sensors measure brightness — but what if you need to know the exact color of light, its spectral composition, or compare two light sources for color matching? The AS7341 spectral sensor from ams OSRAM is a breakthrough 11-channel visible light spectrometer that fits on a tiny breakout board and communicates via I2C. With Arduino, you can measure 8 spectral channels from violet (415 nm) to near-infrared (940 nm), clear light, and a near-IR channel — opening up applications from plant grow-light monitoring to industrial color inspection.

This tutorial covers the AS7341 in depth: how it works, wiring to Arduino, library setup, code examples, and real-world project ideas. No prior spectroscopy experience required.

Table of Contents

  1. What Is the AS7341 Spectral Sensor?
  2. The 11 Spectral Channels Explained
  3. How the AS7341 Measures Light Color
  4. Full Specifications
  5. Wiring AS7341 to Arduino
  6. Library Installation
  7. Basic Spectral Reading Code
  8. Flicker Detection Code
  9. Calculating Correlated Color Temperature (CCT)
  10. Project Ideas and Use Cases
  11. Recommended Products from Zbotic
  12. Frequently Asked Questions
  13. Conclusion

1. What Is the AS7341 Spectral Sensor?

The AS7341 is an 11-channel multispectral sensor IC made by ams OSRAM. It uses an array of on-chip photodiodes, each with a different optical interference filter, to measure the intensity of light at 11 specific wavelength bands simultaneously. Unlike a simple RGB sensor (which has only 3 broad channels), the AS7341’s 8 narrow visible-spectrum channels plus clear and near-IR channels give you a much more detailed picture of any light source.

Key differentiators of the AS7341:

  • 11 sensing channels (8 spectral + clear + NIR + flicker)
  • Built-in flicker detection (detects 50Hz and 60Hz light flicker from fluorescent/LED sources)
  • I2C interface with configurable gain (0.5× to 512×) and integration time
  • Built-in LED driver for illuminating samples in reflectance measurements
  • Very low power — suitable for battery-powered devices
  • Excellent repeatability: <1% channel-to-channel variation

The AS7341 is available on breakout boards from Adafruit (Product #4698) and other vendors, making it easy to prototype with Arduino, ESP32, or Raspberry Pi.

2. The 11 Spectral Channels Explained

The AS7341 measures light at the following channels:

Register Name Wavelength (nm) Color Band Notes
F1 415 nm Violet Near UV boundary
F2 445 nm Indigo/Blue Deep blue
F3 480 nm Blue Cyan-blue
F4 515 nm Green Blue-green
F5 555 nm Green-Yellow Peak human eye sensitivity
F6 590 nm Yellow-Orange Amber range
F7 630 nm Orange-Red Deep orange
F8 680 nm Red Deep red (plant photosynthesis)
Clear (NIR) Broadband All visible Unfiltered, no NIR blocking
NIR 910 nm Near Infrared Useful for plant health (NDVI)
Flicker Broadband Flicker detection Detects 50Hz / 60Hz flicker

The 8 spectral channels (F1–F8) span 415–680 nm, covering the full visible spectrum in meaningful segments. The 20 nm bandwidth (FWHM) of each filter is narrow enough to distinguish meaningful spectral features.

3. How the AS7341 Measures Light Color

The AS7341 uses silicon photodiodes with optical interference filters deposited directly on the chip surface using semiconductor fabrication processes. Each photodiode has a different filter optimized for a specific wavelength band.

The measurement process:

  1. Integration: The sensor opens its photodiode “shutters” for a configurable integration time (2.78 µs to 711 ms). Longer integration = more sensitivity in dark conditions.
  2. Amplification: An analog gain (0.5× to 512×) multiplies the photodiode current. Higher gain for dark scenes, lower gain in bright light.
  3. ADC conversion: Each channel has its own 16-bit ADC, giving counts from 0 to 65535.
  4. I2C readout: You read 16-bit values for each channel via I2C registers.

The raw counts are proportional to the irradiance (W/m²) at each wavelength. To get physically meaningful spectral power distribution, you apply calibration coefficients from the datasheet. For most maker projects, the raw ratios between channels are sufficient for color comparison, classification, and analysis.

The flicker channel uses a separate high-speed circuit that can detect 50 Hz (European/Indian grid) and 60 Hz (American grid) flicker from artificial lighting — useful for identifying light source types and for camera sync applications.

4. Full Specifications

  • Spectral channels: 8 visible (F1–F8) + Clear + NIR + Flicker = 11 total
  • Wavelength range: 415 nm to 940 nm (spectral channels 415–680 nm visible)
  • ADC resolution: 16-bit (0–65535 counts)
  • Gain: 0.5×, 1×, 2×, 4×, 8×, 16×, 32×, 64×, 128×, 256×, 512×
  • Integration time: 2.78 µs to 711 ms (ATIME × ASTEP configurable)
  • Supply voltage: 1.7V to 3.6V (I/O); 1.7V to 3.6V (power)
  • Current draw: ~90 µA in measurement mode (low power mode available)
  • Interface: I2C (address 0x39)
  • Built-in LED driver: Up to 258 mA for illuminating samples
  • External INT pin: Configurable threshold interrupt
  • Package: QFN-40 (2.0 × 2.0 mm chip; available on larger breakout modules)
  • Flicker detection: 1.0 Hz to 65 kHz (configurable)

5. Wiring AS7341 to Arduino

The Adafruit AS7341 breakout module is the easiest starting point. It includes a 3.3V regulator, I2C level shifting, and a white LED for reflectance measurements. Wire it as follows:

AS7341 Breakout Pin Arduino Uno ESP32
VIN 5V 3.3V
GND GND GND
SDA A4 GPIO 21
SCL A5 GPIO 22
INT (optional) Pin 2 (interrupt) Any GPIO
LED (optional) Not needed for ambient Not needed for ambient

The AS7341 chip operates at 1.7–3.6V; the Adafruit breakout handles the level conversion from 5V Arduino I2C lines. If you’re wiring the bare IC, use 3.3V logic only and 4.7kΩ pull-up resistors on SDA/SCL.

6. Library Installation

Adafruit maintains an easy-to-use Arduino library for the AS7341:

  1. Open Arduino IDE → Tools → Manage Libraries
  2. Search for “Adafruit AS7341”
  3. Install it (ensure you accept the Adafruit BusIO and Adafruit Unified Sensor dependencies)

Alternatively, clone from GitHub: https://github.com/adafruit/Adafruit_AS7341

SparkFun also offers a library if you prefer their breakout: search for “SparkFun AS7341” in Library Manager.

7. Basic Spectral Reading Code

// AS7341 - Read all spectral channels
// Requires: Adafruit AS7341 library
#include <Adafruit_AS7341.h>

Adafruit_AS7341 as7341;

void setup() {
  Serial.begin(115200);
  while (!Serial);

  if (!as7341.begin()) {
    Serial.println("AS7341 not found! Check wiring.");
    while (1);
  }

  // Set integration time and gain
  as7341.setATIME(100);  // Integration steps (100 = ~277ms)
  as7341.setASTEP(999);  // Step size
  as7341.setGain(AS7341_GAIN_256X); // High gain for indoor light

  Serial.println("AS7341 Spectral Sensor Ready");
}

void loop() {
  uint16_t readings[12];

  if (!as7341.readAllChannels(readings)) {
    Serial.println("Error reading channels!");
    return;
  }

  Serial.println("--- Spectral Readings ---");
  Serial.print("F1 (415nm Violet): "); Serial.println(readings[0]);
  Serial.print("F2 (445nm Blue):   "); Serial.println(readings[1]);
  Serial.print("F3 (480nm Blue):   "); Serial.println(readings[2]);
  Serial.print("F4 (515nm Green):  "); Serial.println(readings[3]);
  Serial.print("F5 (555nm Yellow): "); Serial.println(readings[6]);
  Serial.print("F6 (590nm Orange): "); Serial.println(readings[7]);
  Serial.print("F7 (630nm Red):    "); Serial.println(readings[8]);
  Serial.print("F8 (680nm Deep R): "); Serial.println(readings[9]);
  Serial.print("Clear:             "); Serial.println(readings[10]);
  Serial.print("NIR (910nm):       "); Serial.println(readings[11]);
  Serial.println();

  delay(1000);
}

Note on channel order: The Adafruit library’s readAllChannels() returns channels in a specific order — F1-F4 in indices 0–3, then F5-F8 in indices 6–9, with internal channels at 4–5 (not spectral). Always refer to the library documentation for the current mapping.

8. Flicker Detection Code

Detecting light flicker (the 50/60 Hz modulation from fluorescent and LED lights powered by AC mains) has practical uses in photography, spectroscopy, and quality control:

// AS7341 - Flicker Detection
#include <Adafruit_AS7341.h>

Adafruit_AS7341 as7341;

void setup() {
  Serial.begin(115200);
  as7341.begin();
  as7341.setGain(AS7341_GAIN_256X);
  as7341.setATIME(29);
  as7341.setASTEP(599);

  Serial.println("Flicker Detection Mode");
}

void loop() {
  as7341_color_data_t colorData;

  uint16_t flickerHz = as7341.detectFlickerHz();

  if (flickerHz == 50) {
    Serial.println("50Hz flicker detected (European/Indian AC grid - fluorescent/LED)");
  } else if (flickerHz == 60) {
    Serial.println("60Hz flicker detected (American/Japanese AC grid)");
  } else if (flickerHz == 0) {
    Serial.println("No flicker detected (sunlight or DC-powered LED)");
  } else {
    Serial.print("Flicker at "); Serial.print(flickerHz); Serial.println(" Hz");
  }

  delay(500);
}

This is useful for identifying light source types in a room and for camera shutter-sync applications to avoid banding in video capture.

9. Calculating Correlated Color Temperature (CCT)

Correlated Color Temperature (CCT) describes the warmth or coolness of white light in Kelvin — 2700K is warm/incandescent, 6500K is cool/daylight. You can estimate CCT from the AS7341 readings:

// Estimate CCT from AS7341 spectral data
// Simplified McCamy formula using tristimulus values
float estimateCCT(uint16_t* readings) {
  // Approximate CIE tristimulus from spectral channels
  // These coefficients are approximations for AS7341
  float X = 0.016f * readings[0] + 0.024f * readings[1] +
            0.156f * readings[2] + 0.290f * readings[3] +
            0.030f * readings[6] + 0.100f * readings[7];
  float Y = 0.002f * readings[1] + 0.040f * readings[2] +
            0.214f * readings[3] + 0.430f * readings[6] +
            0.223f * readings[7] + 0.074f * readings[8];
  float Z = 0.130f * readings[0] + 0.460f * readings[1] +
            0.610f * readings[2] + 0.110f * readings[3];

  float sum = X + Y + Z;
  if (sum == 0) return 0;

  float x = X / sum;
  float y = Y / sum;

  // McCamy formula
  float n = (x - 0.3320f) / (0.1858f - y);
  float CCT = 449.0f * n*n*n + 3525.0f * n*n + 6823.3f * n + 5520.33f;

  return CCT;
}

// In loop():
// float cct = estimateCCT(readings);
// Serial.print("Estimated CCT: "); Serial.print(cct); Serial.println(" K");

For more accurate CCT calculations, Sensirion and ams publish sensor-specific color matrices that translate raw channel counts to CIE XYZ coordinates. These are available in the AS7341 application notes.

10. Project Ideas and Use Cases

1. Plant Grow-Light Spectrum Analyzer

Plants primarily use blue (445–480 nm) and red (630–680 nm) light for photosynthesis. The AS7341 can measure the red-to-blue ratio and NIR channel of your grow light to verify its spectrum is optimized for vegetative growth (more blue) or flowering (more red). Monitor PAR (Photosynthetically Active Radiation) coverage across your grow tent.

2. Color Matching Station

Place an object under the AS7341’s built-in LED and measure its reflected spectrum. Compare readings against a stored reference to check if paint, ink, fabric, or food meets color specifications. Far more accurate than RGB comparison for quality control.

3. Sun Tracker / Daylight Sensor

Track how the solar spectrum changes throughout the day (sunrise is redder, noon is bluer). Automate window blinds or photography lighting to maintain consistent color temperature indoors.

4. Smart Aquarium Light Controller

Measure the light spectrum inside a reef aquarium and automatically adjust a multi-channel LED fixture to maintain the ideal 420–430 nm (actinic blue) and 450–460 nm ratios for coral health and fluorescence.

5. Counterfeit Detection Aid

Many security inks have distinctive UV-fluorescence peaks. Under a 365 nm UV source, measure the emission spectrum with the AS7341 to verify authenticity of documents, banknotes, or branded products.

6. NDVI Vegetation Index Calculator

Using the Red (F7/F8) and NIR channels, calculate NDVI = (NIR – Red) / (NIR + Red) to assess plant health and chlorophyll content from a handheld meter. This is the same index used by satellites for crop monitoring.

11. Recommended Products from Zbotic

Complement your AS7341 spectral sensor with these environmental and sensing modules from Zbotic:

LM35 Temperature Sensors

LM35 Temperature Sensors

Add temperature sensing to your spectral measurement setup — temperature affects light source spectra, particularly the CCT of LEDs, so compensating for it improves accuracy.

View on Zbotic

DHT20 SIP Packaged Temperature and Humidity Sensor

DHT20 SIP Packaged Temperature and Humidity Sensor

In plant grow-light monitoring projects, combine the AS7341 spectrum reading with DHT20 temperature and humidity data for complete grow-room environmental control.

View on Zbotic

Capacitive Soil Moisture Sensor

Capacitive Soil Moisture Sensor

For smart agriculture projects, pair the AS7341 NDVI measurement with soil moisture sensing to build a complete plant health monitoring station.

View on Zbotic

12. Frequently Asked Questions

What is the I2C address of the AS7341?

The AS7341 has a fixed I2C address of 0x39. It cannot be changed via hardware pins. If you need multiple AS7341 sensors on the same I2C bus, use an I2C multiplexer such as the TCA9548A.

What is the difference between AS7341 and TCS34725?

The TCS34725 is a 4-channel RGB + Clear sensor — it measures broad red, green, blue, and clear bands. The AS7341 has 8 narrow spectral channels plus clear and NIR, giving much more detailed spectral information. The AS7341 can distinguish subtle differences in color that the TCS34725 cannot. For basic color sensing, TCS34725 suffices; for spectral analysis, use the AS7341.

Can the AS7341 measure UV light?

The shortest spectral channel on the AS7341 is F1 at 415 nm, which is at the very edge of visible violet — not UV. The AS7341 does not measure UV (100–400 nm). For UV measurement, you need a dedicated UV sensor like the VEML6070 or AS7331.

How do I avoid saturation (overflow) on bright light?

If any channel reads 65535 (the 16-bit maximum), that channel is saturated. Reduce gain (e.g., from 256× to 16×) and/or shorten integration time (reduce ATIME value). Some sketches implement auto-gain: if max channel > 60000, halve the gain; if max channel < 1000, double the gain. The Adafruit library provides setGain() and setATIME() for this purpose.

Can I use the AS7341 in sunlight?

Yes, but you must reduce gain significantly in direct sunlight to avoid saturation. Start with the lowest gain (0.5×) and shortest integration time in bright outdoor conditions. The AS7341 measures ambient light effectively in sunlight — it’s an excellent solar spectrum characterization tool with the right gain settings.

What library should I use for the AS7341?

The most popular options are the Adafruit AS7341 library (easiest to use, excellent documentation) and the SparkFun AS7341 library. Both are available via the Arduino Library Manager. The ams OSRAM official SDK is available for more advanced applications requiring precise radiometric calibration.

13. Conclusion

The AS7341 spectral sensor brings laboratory-grade multispectral measurement capability to Arduino projects. Its 8 narrow-band visible channels, NIR channel, flicker detection, and built-in LED driver make it far more powerful than any RGB color sensor. Whether you’re measuring plant light quality, characterizing LED sources, building a color matching tool, or calculating NDVI vegetation indices, the AS7341 provides the spectral data you need.

Getting started is straightforward: wire up the breakout module to your Arduino’s I2C pins, install the Adafruit library, and you’re reading all 11 channels within minutes. From there, the applications are limited only by your imagination.

Explore more sensors for your next project. Visit Zbotic Sensors & Modules for a wide range of environmental, light, and specialty sensors available with fast shipping across India.
Tags: Arduino light color sensor, AS7341 spectral sensor, AS7341 tutorial, light spectrum measurement, multispectral sensor Arduino
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Brushless vs Brushed DC Motor:...
blog brushless vs brushed dc motor which is better for your project 596634
blog tp4056 with protection vs without which module to buy 596641
TP4056 with Protection vs With...

Related posts

Svg%3E
Read more

Encoder Module: Position and Speed Measurement with Arduino

April 1, 2026 0
A rotary encoder converts the angular position and rotation speed of a shaft into electrical signals that Arduino can count... Continue reading
Svg%3E
Read more

Infrared Obstacle Sensor: Line Follower and Object Detection

April 1, 2026 0
Infrared obstacle sensors are the building blocks of line-following robots, edge detection systems, and proximity triggers. These tiny modules emit... Continue reading
Svg%3E
Read more

Rain Sensor and Raindrop Detection Module: Arduino Guide

April 1, 2026 0
A rain sensor module detects the presence of water droplets on its surface, giving Arduino a simple signal to trigger... Continue reading
Svg%3E
Read more

LiDAR Sensor TFmini: Distance Measurement Beyond Ultrasonic

April 1, 2026 0
When ultrasonic sensors hit their limits — range too short, accuracy too coarse, outdoor sunlight causing interference — LiDAR sensors... Continue reading
Svg%3E
Read more

Pressure Sensor BMP280: Weather Station and Altitude Meter

April 1, 2026 0
The BMP280 barometric pressure sensor by Bosch measures atmospheric pressure with ±1 hPa accuracy and temperature with ±1°C precision. These... Continue reading

Add comment Cancel reply

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

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now