VCNL4200 Module¶
This module contains the Zerynth driver for Vishay VCNL4200. The unit integrates a high sensitivity long distance proximity sensor (PS), ambient light sensor (ALS), and 940 nm IRED into one small package.
Communication with this unit is done using I2C.
VCNL4200 class¶
class VCNL4200(drvsel, ps=True, als=True, address=DEFAULT_I2C_ADDR, clk=400000)
Initialize an object representing the VCNL4200 board. The I2C communication is started, and enabled sensors are configured with a stanrdard configuration.
Note
Default settings enable proximity sensor high definition and faster duty time, this results in more accuracy at the cost of more
power usage. Refer to sensor datasheet and use configure_proximity_sensor(), configure_ambient_light_sensor() methods for more advanced settings.
Arguments:
- drvsel – The I2C port to be used. (e.g. I2C0)
- ps – Boolean for enabling the proximity sensor on board (Default: True)
- als – Boolean for enabling the ambient light sensor on board (Default: True)
- address – Byte for selecting the I2C address to be used. (Default: sensor default)
- clk – I2C clock speed to be used (100000 or 400000). (Default: 400000)
get_distance()
Returns an integer representing the proximity read from the sensor.
get_ambient_light()
Returns an integer in range 0-65535 representing the ambient light level read from the sensor.
configure_proximity_sensor(conf1, conf2, conf3)
Write settings for proximity sensor in registers PS_CONF1, PS_CONF2, and PS_CONF3. Refer to datasheet for all the available settings.
Arguments:
- onf1 – Byte to be written in PS_CONF1 register.
- conf2 – Byte to be written in PS_CONF2 register.
- conf3 – Byte to be written in PS_CONF3 register.
configure_ambient_light_sensor(conf)
Write settings for ambient light sensor in register ALS_CONF. Refer to datasheet for all the available settings.
Arguments: conf – Byte to be written in ALS_CONF register.