MicroPython VCNL4010 Library¶
vcnl4010¶
MicroPython Driver for the Vishay VCNL4010 Proximity and Ambient Light Sensor
Author(s): Jose D. Montoya
-
class micropython_vcnl4010.vcnl4010.VCNL4010(i2c, address: int =
0x13)[source]¶ Driver for the VCNL4010 Sensor connected over I2C.
- Parameters:¶
- Raises:¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
VCNL4010class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_vcnl4010 import vcnl4010Once this is done you can define your
machine.I2Cobject and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) vcnl4010 = vcnl4010.VCNL4010(i2c)Now you have access to the attributes
- property ambient_light_average : str¶
Sensor ambient_light_average
Mode
Value
vcnl4010.AL_AVERAGE10b000vcnl4010.AL_AVERAGE20b001vcnl4010.AL_AVERAGE40b010vcnl4010.AL_AVERAGE80b011vcnl4010.AL_AVERAGE160b100vcnl4010.AL_AVERAGE320b101vcnl4010.AL_AVERAGE640b110vcnl4010.AL_AVERAGE1280b111
- property ambient_light_rate : str¶
Sensor ambient_light_rate
Mode
Value
vcnl4010.AMBIENT_LIGHT_RATE10b000vcnl4010.AMBIENT_LIGHT_RATE20b001vcnl4010.AMBIENT_LIGHT_RATE30b010vcnl4010.AMBIENT_LIGHT_RATE40b011vcnl4010.AMBIENT_LIGHT_RATE50b100vcnl4010.AMBIENT_LIGHT_RATE60b101vcnl4010.AMBIENT_LIGHT_RATE80b110vcnl4010.AMBIENT_LIGHT_RATE100b111
- property irl_led_current : int¶
IR LED current = Value (dec.) x 10 mA. Valid Range = 0 to 20d. e.g. 0 = 0 mA , 1 = 10 mA, …., 20 = 200 mA (2 = 20 mA = DEFAULT) LED Current is limited to 200 mA for values higher as 20d.
- property proximity_rate : str¶
Sensor proximity_rate
Mode
Value
vcnl4010.SAMPLERATE_1_950b000vcnl4010.SAMPLERATE_3_906250b001vcnl4010.SAMPLERATE_7_81250b010vcnl4010.SAMPLERATE_16_6250b011vcnl4010.SAMPLERATE_31_250b100vcnl4010.SAMPLERATE_62_50b101vcnl4010.SAMPLERATE_1250b110vcnl4010.SAMPLERATE_2500b111