Using the VCNL4030 breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit_VCNL4030 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 VCNL4030 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit VCNL4030, and select the Adafruit VCNL4030 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!
/*!
* @file simpletest.ino
*
* Basic test for the Adafruit VCNL4030 library.
* Reads proximity, ambient light, and white channel values.
*
* Written by Limor Fried/Ladyada for Adafruit Industries.
*/
#include <Adafruit_VCNL4030.h>
Adafruit_VCNL4030 vcnl;
void setup() {
Serial.begin(115200);
while (!Serial)
delay(10);
Serial.println(F("Adafruit VCNL4030 Simple Test"));
if (!vcnl.begin()) {
Serial.println(F("Could not find a valid VCNL4030 sensor, check wiring!"));
while (1) {
delay(10);
}
}
Serial.println(F("VCNL4030 Found!"));
Serial.println();
}
void loop() {
uint16_t prox = vcnl.readProximity();
uint16_t als = vcnl.readALS();
uint16_t white = vcnl.readWhite();
Serial.print(F("Proximity: "));
Serial.print(prox);
Serial.print(F(" Lux: "));
Serial.print(vcnl.readLux());
Serial.print(F(" White: "));
Serial.println(white);
delay(100);
}
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the VCNL4030 recognized over I2C. Then, the reading values of different light channels will be printed out to the Serial Monitor.
Page last edited March 25, 2026
Text editor powered by tinymce.