VCNL4010 light sensor and ESP8266 example using the Arduino IDE

In this article we look at another acceleration sensor – this time its the VCNL4010 and we will connect it to a Wemos Mini

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

 

Once again for ease of use I connect a Dual Base Shield with a Wemos Mini and then connect the sensor to that as well

Name Link
Wemos Mini WeMos D1 mini
VCNL4010 Multiple Function Sensor Development Tools Proximity/Light Sensor VCNL4000 (1 piece)
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire
Dual Base Shield Double Socket Dual Base Shield for Wemos D1 Mini

 

Schematic/Connection

ESP8266 and VCNL4010 layout
ESP8266 and VCNL4010 layout

 

Code Example

This uses the library from https://github.com/adafruit/Adafruit_VCNL4010

This is the default example

#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);
}

 

Output

Open the serial monitor and you should see something like this

Ambient: 82
Proximity: 4240
Ambient: 99
Proximity: 2371
Ambient: 118
Proximity: 2358
Ambient: 119
Proximity: 2361
Ambient: 120
Proximity: 2356
Ambient: 119
Proximity: 2361

Links

https://www.vishay.com/docs/83462/vcnl4010.pdf

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*