In this article we look at another acceleration sensor – this time its the VCNL4010 and we will connect it to an Arduino Uno
First lets look at the sensor
The VCNL4010 is a fully integrated proximity and ambient light sensor. Fully integrated means that the infrared emitter is included in the package. It has 16 bit resolution. It includes a signal processing IC and features standard I2C communication interface. It features an interrupt function.
PROXIMITY FUNCTION
• Built-in infrared emitter and photo-pin-diode for proximity
function
• 16 bit effective resolution for proximity detection range
ensures excellent cross talk immunity
• Programmable LED drive current from 10 mA to 200 mA in
10 mA steps
• Excellent ambient light suppression by modulating the
infrared signal
• Proximity distance up to 200 mm
AMBIENT LIGHT FUNCTION
• Built-in ambient light photo-pin-diode with close-tohuman-eye sensitivity
• 16 bit dynamic range from 0.25 lx to 16 klx
• 100 Hz and 120 Hz flicker noise rejection
FEATURES
• Integrated modules: infrared emitter (IRED), ambient light sensor (ALS-PD), proximity sensor (PD), and signal conditioning IC
• Interrupt function
• Supply voltage range VDD: 2.5 V to 3.6 V
• Supply voltage range IR anode: 2.5 V to 5 V
• Communication via I2C interface
• I2C Bus H-level range: 1.7 V to 5 V
• Low stand by current consumption: 1.5 μA
Parts Required
Schematic/Connection
Code Example
This uses the library from https://github.com/adafruit/Adafruit_VCNL4010
This is the default example
[codesyntax lang=”cpp”]
#include <Wire.h>
#include “Adafruit_VCNL4010.h”
Adafruit_VCNL4010 vcnl;
void setup()
{
Serial.begin(9600);
Serial.println(“VCNL4010 test”);
if (! vcnl.begin())
{
Serial.println(“Sensor not found :(“);
while (1);
}
Serial.println(“Found VCNL4010”);
}
void loop()
{
Serial.print(“Ambient: “);
Serial.println(vcnl.readAmbient());
Serial.print(“Proximity: “);
Serial.println(vcnl.readProximity());
delay(100);
}
[/codesyntax]
Output
Open the serial monitor and you should see something like this
Proximity: 3628
Ambient: 76
Proximity: 5509
Ambient: 66
Proximity: 6417
Ambient: 63
Proximity: 7181
Ambient: 54
Proximity: 8347
Ambient: 53
Proximity: 9443
Ambient: 52
Links
https://www.vishay.com/docs/83462/vcnl4010.pdf