Proximity detection is no longer science fiction; it's a reality that's here to redefine how we connect with the world
A
A
Hardware Overview
How does it work?
Proximity 11 Click is based on the RPR-0521RS, a digital ambient and proximity sensor from ROHM Semiconductor. It is an accurate and reliable proximity and ambient light sensor, aimed towards the power saving in applications that use TFT or LCD panels. By offering a huge dynamic range, the RPR-0521RS sensor allows to be placed behind a dark glass or a semi-transparent screen bezel, but also to be exposed to a bright sunlight. A proprietary design of the integrated constant-current LED driver enables plug and play proximity detection from 1, up to 100mm, eliminating the need for a calibration procedure. By integrating micro-optics elements within the casing, RPR-0521RS greatly simplifies the application design. Proximity of an object is detected using an IR LED, which emits pulses of light towards the object. The amount of the reflected IR light is measured by an integrated IR photodiode. During LED pulse duration time, the amount of the reflected IR light is measured and
integrated. The background IR light is also measured and integrated, during LED OFF state. It is then subtracted from the final result, allowing for an accurate measurement with the reduced amount of the background IR noise. After it has been scaled to a 16-bit value, the final result is available on the output registers, in the LOW/HIGH byte format. Commonly, photosensitive elements are most sensitive to IR light. A human eye does cannot detect IR light. Therefore, the PD element has to filter out IR light so that only the visible part of the light is allowed through. The channel0 is equipped with such PD, making it usable for the ALS sensing. During the ALS measurement, both channels are measured. The datasheet of the RPR-0521RS offers a conversion formula that can be used to obtain results in physical units (lx). These formulas also take the IR measurement from the channel 1 into the consideration, completely reducing its influence on the final result. By adjusting the integration time (also known
as oversampling), the flickering effect of a fluorescent light can be completely eliminated. The extensive interrupt engine allows an optimized firmware to be written. Four registers are used to specify the low and the high threshold for the ALS and proximity measurements. Whenever these thresholds are exceeded, an interrupt status bit will be set in the respective register. The user has the ability to assign an external pin to an interrupt, so the MCU can be alerted whenever an interrupt event occurs. The interrupt is generated whenever the threshold value is exceeded for a programmed number of times (interrupt persistence). This is useful to prevent false and erratic interrupt reporting. The Click board™ is designed to work with 3.3V only. When using it with MCUs that use 5V levels for their communication, a proper level translation circuit should be used.
Features overview
Development board
PIC32MZ Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller with FPU from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing access anywhere and under
any circumstances. Each part of the PIC32MZ Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the PIC32MZ Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Micro-B connection can provide up to 500mA of current, which is more than enough to operate all onboard
and additional modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. PIC32MZ Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Architecture
PIC32
MCU Memory (KB)
1024
Silicon Vendor
Microchip
Pin count
64
RAM (Bytes)
524288
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for Proximity 11 Click driver.
Key functions:
proximity11_get
- This function reads proximity values from the desired registers.proximity11_update
- This function updates data used to calculate Lux. This function should be called if changing als measurement time and als gain.proximity11_set_als_threshold_high
- This function sets High ALS threshold value.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file
* \brief Proximity11 Click example
*
* # Description
* This appication enables usage of the proximity and ambient light sensors
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes I2C driver and performs device initialization
*
* ## Application Task
* Gets ALS and PS values and logs those values
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "proximity11.h"
// ------------------------------------------------------------------ VARIABLES
static proximity11_t proximity11;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
proximity11_cfg_t cfg;
uint8_t init_status;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
proximity11_cfg_setup( &cfg );
PROXIMITY11_MAP_MIKROBUS( cfg, MIKROBUS_1 );
proximity11_init( &proximity11, &cfg );
Delay_ms ( 500 );
init_status = proximity11_default_cfg( &proximity11 );
if ( init_status == 1 )
{
log_printf( &logger, "> app init fail\r\n" );
while( 1 );
}
else if ( init_status == 0 )
{
log_printf( &logger, "> app init done\r\n" );
}
}
void application_task ( void )
{
// Task implementation
uint16_t ps_value;
float als_value;
proximity11_get_ps_als_values( &proximity11, &ps_value, &als_value );
log_printf( &logger, "PS : %u [count]\r\n", ps_value );
log_printf( &logger, "ALS : %.2f [Lx]\r\n\r\n", als_value );
Delay_ms ( 500 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END