proximity7 2.0.0.0
Main Page

PROXIMITY 7 click

Proximity 7 click is an advanced proximity and ambient light sensing Click boardâ„¢. It features the ADPS9930, a digital sensor IC equipped with two photodiodes (PD) and an IR LED, driven by a proprietary LED driver circuit. It allows an accurate proximity detection for a maximum distance of 100mm.

click Product page


Click library

  • Author : MikroE Team
  • Date : Dec 2019.
  • Type : I2C type

Software Support

We provide a library for the Proximity7 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

‍This library contains API for Proximity7 Click driver.

Standard key functions :

  • Config Object Initialization function.

    ‍void proximity7_cfg_setup ( proximity7_cfg_t *cfg );

    - Initialization function.

    ‍PROXIMITY7_RETVAL proximity7_init ( proximity7_t *ctx, proximity7_cfg_t *cfg );

  • Click Default Configuration function.

    ‍void proximity7_default_cfg ( proximity7_t *ctx );

Example key functions :

‍This application give us lux level and proximiti data.

The demo application is composed of two sections :

Application Init

‍Initializes I2C driver and writes basic settings to device registers

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
PROXIMITY7_MAP_MIKROBUS( cfg, MIKROBUS_1 );
proximity7_init( &proximity7, &cfg );
Delay_ms ( 100 );
log_printf( &logger, "> > > app init done < < <\r\n" );
}
#define PROXIMITY7_MAP_MIKROBUS(cfg, mikrobus)
Definition proximity7.h:67
uint8_t proximity7_init(proximity7_t *ctx, proximity7_cfg_t *cfg)
Initialization function.
void proximity7_cfg_setup(proximity7_cfg_t *cfg)
Config Object Initialization function.
void application_init(void)
Definition main.c:36
Click configuration structure definition.
Definition proximity7.h:285

Application Task

‍Logs lux level and proximity data

void application_task ( void )
{
uint8_t write_buffer[ 2 ];
uint8_t read_buffer[ 1 ] ;
float lux_level;
uint16_t proximity;
uint8_t als_valid;
uint8_t proximity_valid;
proximity7_generic_read( &proximity7, PROXIMITY7_STATUS | PROXIMITY7_REPEATED_BYTE, &read_buffer[ 0 ], 1 );
als_valid = read_buffer[ 0 ] & PROXIMITY7_ALS_VALID_MASK;
proximity_valid = read_buffer[ 0 ] & PROXIMITY7_PROXIMITY_VALID_MASK;
if ( ( als_valid != 0 ) && ( proximity_valid != 0 ) )
{
log_printf( &logger, " " );
lux_level = proximity7_get_lux_level( &proximity7 );
log_printf( &logger, "> > > Lux level : %f lx\r\n", lux_level );
proximity = proximity7_get_proximity_data( &proximity7 );
log_printf( &logger, "> > > Proximity : %d\r\n", proximity );
}
Delay_ms ( 300 );
}
void proximity7_generic_write(proximity7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint16_t proximity7_get_proximity_data(proximity7_t *ctx)
Getting proximity measurement data.
float proximity7_get_lux_level(proximity7_t *ctx)
Calculating LUX level.
void proximity7_generic_read(proximity7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
#define PROXIMITY7_STATUS
Definition proximity7.h:131
#define PROXIMITY7_PROXIMITY_AND_ALS_INT_PIN_CLEAR
Definition proximity7.h:107
#define PROXIMITY7_PROXIMITY_VALID_MASK
Definition proximity7.h:228
#define PROXIMITY7_ALS_VALID_MASK
Definition proximity7.h:229
#define PROXIMITY7_REPEATED_BYTE
Definition proximity7.h:94
#define PROXIMITY7_SPECIAL_FUNCTION
Definition proximity7.h:97
void application_task(void)
Definition main.c:67

Note

‍- When setting LED drive strength please note that if "proximity drive level - PDL" bit in "configuration register" is set to 1, LED drive current values are reduced by 9.

  • When setting wait time note that if "wait long - WLONG" bit is set to 1, time is 12x longer. Therefore if WLONG == 1 set time between 33ms and 8386.56ms.
  • When setting ALS gain note that if "ALS gain level - AGL" bit is set to 1, ALS gains are scaled by 0.16, otherwise, they are scaled by 1.

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Proximity7

Additional notes and informations

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.