This is an Arduino library for the Adafruit OPT4048 breakout board, a high-speed, high-precision tristimulus XYZ color sensor.
The OPT4048 is a high-precision, tristimulus XYZ color sensor that provides accurate color measurements by using an integrated CIE1931 XYZ filter technology.
Key features:
- Four-channel sensor (X, Y, Z, clear)
- High-precision color measurements with CIE1931 filter technology
- Wide dynamic range with auto-ranging capability
- Programmable interrupt with high and low thresholds
- Adjustable conversion time (600μs to 800ms per channel)
- Measures color temperature, illuminance, and chromaticity
- I²C interface
This library depends on the Adafruit BusIO library for I²C communication.
You can install this library through the Arduino Library Manager. Search for "Adafruit OPT4048" and install the latest version.
To manually install:
- Download the .zip file from GitHub
- In the Arduino IDE: Sketch -> Include Library -> Add .ZIP Library
The library includes several examples demonstrating various features:
- opt4048_basictest: Basic usage with continuous readings
- opt4048_fulltest: Demonstrates all sensor configurations
- opt4048_intpin: Using the interrupt pin for data-ready notifications
- opt4048_oneshot: One-shot measurement mode for low power applications
- Initialize the sensor with custom I²C address and Wire interface
- Configure measurement settings (range, conversion time, operating mode)
- Set up and use the interrupt system
- Read raw channel data from all four sensors
- Calculate CIE color coordinates (x, y) and illuminance (lux)
- Determine color temperature in Kelvin
For more information on using this library, check out the examples folder.
Full documentation of the OPT4048 sensor can be found in the datasheet.
This library is released under an MIT license. See the included LICENSE file for details.