Proximity 22 Click
Proximity 22 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Mar 2025.
- Type : I2C type
Software Support
Example Description
This example demonstrates the use of the Proximity 22 Click board by reading and displaying proximity, ambient light (ALS), and temperature measurements. The data is read only when a new measurement is ready, indicated by an interrupt.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Proximity22
Example Key Functions
- proximity22_cfg_setup This function initializes Click configuration structure to initial values.
void proximity22_cfg_setup(proximity22_cfg_t *cfg)
Proximity 22 configuration object setup function.
Proximity 22 Click configuration object.
Definition proximity22.h:466
- proximity22_init This function initializes all necessary pins and peripherals used for this Click board.
err_t proximity22_init(proximity22_t *ctx, proximity22_cfg_t *cfg)
Proximity 22 initialization function.
Proximity 22 Click context object.
Definition proximity22.h:446
- proximity22_default_cfg This function executes a default configuration of Proximity 22 Click board.
err_t proximity22_default_cfg(proximity22_t *ctx)
Proximity 22 default configuration function.
- proximity22_get_int_pin This function returns the logic state of the INT pin.
uint8_t proximity22_get_int_pin(proximity22_t *ctx)
Proximity 22 get INT pin function.
- proximity22_read_data This function reads proximity, temperature, and ALS data if available.
err_t proximity22_read_data(proximity22_t *ctx, proximity22_data_t *data_out)
Proximity 22 read sensor data function.
Proximity 22 Click data object.
Definition proximity22.h:507
Application Init
Initializes the logger and the Proximity 22 Click driver, then sets the default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define PROXIMITY22_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition proximity22.h:432
void application_init(void)
Definition main.c:31
@ PROXIMITY22_ERROR
Definition proximity22.h:485
Application Task
Waits for a data ready interrupt and then reads the proximity, temperature, and ALS data (red, green, blue, and clear channels), displaying the results via UART approximately every 200 ms.
{
{
log_printf ( &logger,
" Proximity: %u\r\n", meas_data.
proximity );
log_printf ( &logger,
" Temperature: %.1f degC\r\n", meas_data.
temperature );
log_printf ( &logger,
" ALS data (RGBC): %u;%u;%u;%u\r\n\n", meas_data.
als.
red,
}
}
void application_task(void)
Definition main.c:67
@ PROXIMITY22_OK
Definition proximity22.h:484
uint16_t clear
Definition proximity22.h:495
uint16_t blue
Definition proximity22.h:498
uint16_t green
Definition proximity22.h:497
uint16_t red
Definition proximity22.h:496
proximity22_als_t als
Definition proximity22.h:510
uint16_t proximity
Definition proximity22.h:508
float temperature
Definition proximity22.h:509
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
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.