Using the APDS9999 breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit_APDS9999 library, and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the sensor VIN.
Here is an Adafruit Metro wired up to the sensor using the STEMMA QT connector:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
Here is an Adafruit Metro wired up using a solderless breadboard:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
Library Installation
You can install the Adafruit_APDS9999 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_APDS9999, and select the Adafruit_APDS9999 library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!
/*
* Simple color sensor example for APDS-9999
*/
#include "Adafruit_APDS9999.h"
Adafruit_APDS9999 apds;
void setup() {
Serial.begin(115200);
while (!Serial)
delay(10);
if (!apds.begin()) {
Serial.println("Failed to find APDS-9999");
while (1)
delay(10);
}
apds.enableLightSensor(true);
apds.setRGBMode(true);
Serial.println("APDS-9999 Color Sensor");
}
void loop() {
uint32_t r, g, b, ir;
if (apds.getRGBIRData(&r, &g, &b, &ir)) {
Serial.print("R:");
Serial.print(r);
Serial.print(" G:");
Serial.print(g);
Serial.print(" B:");
Serial.print(b);
Serial.print(" IR:");
Serial.print(ir);
Serial.print(" Lux:");
Serial.println(apds.calculateLux(g));
}
delay(100);
}
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the APDS9999 recognized over I2C. Then, the RGB, IR, and calculated lux values will be printed out to the Serial Monitor.
Page last edited March 10, 2026
Text editor powered by tinymce.