You'll need the following hardware to follow this guide:

  • VCNL4010 sensor.
  • A board that is Arduino Compatible.  Must have an I2C interface port (often labeled SDA & SCL)
  • Breadboard and jumper wires.  You'll need these parts to connect components to your development board.

Start by soldering the headers to the VCNL4010 breakout board.  Check out the Adafruit guide to excellent soldering if you're new to soldering.  Then continue on below to learn how to wire it to a Metro or Arduino compatible.

The sensor uses I2C address 0x13 and cannot be changed.

Connect the sensor to your board. The following example shows how to connect it to a Metro:

  • Board 5V to Sensor Vin. (Metro is a 5V logic chip)
  • Board ground / GND to sensor ground / GND.
  • Board SCL to sensor SCL.
  • Board SDA to sensor SDA.

Install Adafruit_VCNL4010 library

To begin reading sensor data, you will need to install the Adafruit_VCNL4010 library (code on our github repository). It is available from the Arduino library manager so we recommend using that.

From the IDE open up the library manager...

And type in adafruit vcnl4010 to locate the library. Click Install

Load Demo

Open up File->Examples->Adafruit_VCNL4010->vcnl4010test and upload to your microcontroller wired up to the sensor

Then open up the serial console at 9600 baud, you'll see ambient light and proximity data printed out! Note that both are unitless, it isn't like the proximity is in millimeters or inches, its just higher the closer you are.

This guide was first published on Dec 29, 2017. It was last updated on Jul 22, 2024.

This page (Arduino) was last updated on Mar 08, 2024.

Text editor powered by tinymce.