Proximity 3 Click Board
Proximity 3 Click Board
The Proximity 3 Click Board™ is an intelligent proximity and light sensing device, which features the VCNL4200 sensor from Vishay - high sensitivity long-distance proximity sensor (PS), an ambient light sensor (ALS) and 940 nm IRED, all in one small package. With its smart sensing and light conditioning properties, the Proximity 3 Click Board™ can be used in a wide range of applications: adjusting the brightness of the TFT screen depending on ambient light, turning off the TFT background light if it is covered, very accurate lux meters, reliable security sensors and so on.
Software Support
We provide a demo application for the Proximity 3 Click Board™ on our LibStock page, developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards with minimal change to the code depending on the microcontroller used.
Library Description
This library contains a set of functions, necessary to work with the Proximity 3 Click Board™.
Key functions
uint16_t prox3_readALS()
- Reads value from ALS register
uint16_t prox3_readPS()
- Reads value from PS register
uint16_t prox3_getDistance()
- Calculating distance
uint16_t prox3_getIlluminance()
- Calculating illuminance
Example Description
This is a simple demonstration of sensor functionality, where the user can read the distance and illuminance data from Proximity 3 click. Distance and illuminance values are sent via UART.
The application is composed of three sections:
- System Initialization - I2C and UART module initialization
- Application Initialization - Sends HAL pointers, and initializes the VCNL4200
- Application Task - Sequential reading of the distance, proximity and ambient light data from the sensor and logging it to UART, every second
void applicationTask() { // DISTANCE READ AND CONVERT VALUE TO STRING resultPS = prox3_getDistance(); IntToStr( resultPS, txt1 ); // WRITES INFORMATION TO UART UART1_Write_Text( "Proximity: ~ " ); UART1_Write_Text( txt1 ); UART1_Write_Text( " cmrn" ); // AMBIENT LIGHT READ AND CONVERT VALUE TO STRING resultALS = prox3_getIlluminance(); IntToStr( resultALS, txt2 ); // WRITES INFORMATION TO UART UART1_Write_Text( "Ambient Light: " ); UART1_Write_Text( txt2 ); UART1_Write_Text( " luxrn" ); Delay_ms(1000); }
The full application code, and ready to use projects can be found on our LibStock page.
Other mikroE Libraries used in the example:
- I2C
- UART
- Conversions
Additional Notes and Information
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.
Proximity 3 Click Board
Frequently Asked Questions
Have a Question?
Be the first to ask a question about this.