nanoFramework.Iot.Device.Vcnl4040 1.0.1

Prefix Reserved
dotnet add package nanoFramework.Iot.Device.Vcnl4040 --version 1.0.1
                    
NuGet\Install-Package nanoFramework.Iot.Device.Vcnl4040 -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.Vcnl4040" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Vcnl4040" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Vcnl4040" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.Vcnl4040 --version 1.0.1
                    
#r "nuget: nanoFramework.Iot.Device.Vcnl4040, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.Vcnl4040@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.Vcnl4040&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Vcnl4040&version=1.0.1
                    
Install as a Cake Tool

VCNL4040 - Proximity and Ambient Light Sensor

The VCNL4040 combines a proximity sensor, infrared emitter, ambient light sensor, and white-light channel. The binding supports sensor power control, emitter and receiver configuration, measurements, threshold interrupts, and interrupt flags. Its fixed I2C address is 0x60.

Documentation

Wiring

VCNL4040 ESP32
VIN 3.3 V
GND GND
SDA GPIO21
SCL GPIO22
INT Any input GPIO (optional)

Configure ESP32 I2C pins before creating the device. Other targets use their board-specific I2C pins.

Usage

Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);

I2cConnectionSettings settings = new I2cConnectionSettings(1, Vcnl4040Device.DefaultI2cAddress);
using I2cDevice i2cDevice = I2cDevice.Create(settings);
using Vcnl4040Device sensor = new Vcnl4040Device(i2cDevice);

sensor.AmbientLightSensor.IntegrationTime = AlsIntegrationTime.Time160ms;
sensor.AmbientLightSensor.PowerOn = true;
sensor.ProximitySensor.PowerOn = true;

while (true)
{
    Debug.WriteLine($"Illuminance: {sensor.AmbientLightSensor.Illuminance.Lux:F2} lux");
    Debug.WriteLine($"Proximity reading: {sensor.ProximitySensor.Distance} counts");
    Thread.Sleep(1000);
}

The proximity reading is an uncalibrated reflection count, not a physical distance. Its relationship to distance depends on the target surface, emitter settings, optical layout, and receiver configuration.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 85 9/29/2026