lightmixsens 2.0.0.0
Main Page

Light mix sens click

Light mix-sens Click is carrying TMD37253, an advanced proximity measurement, color sense (RGBC+IR), and digital ambient light sensing (ALS) device. The TMD37253 slim module package has been designed to accommodate a “single hole” aperture approach that incorporates an IR LED and factory calibrated LED driver. The proximity detection feature provides object detection (e.g., mobile device screen to the user’s ear) by photodiode detection of reflected IR energy (sourced by the integrated LED). The ALS detection feature provides photopic light intensity data. The color photodiodes have UV and IR blocking filters and a dedicated data converters producing 16-bit data.

click Product page


Click library

  • Author : MikroE Team
  • Date : jul 2020.
  • Type : I2C type

Software Support

We provide a library for the LightMixSens 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 LightMixSens Click driver.

Standard key functions :

Example key functions :

Examples Description

‍This example show usage of Light Mix Sens Click. It switches the IR light for separate and measure sectar of RGB lights. Click also measure proximity from the object using light source.

The demo application is composed of two sections :

Application Init

‍Initializes all necessary peripherals and pins, initializes I2C driver and performs the Click board default configuration to allow ALS/Color and Proximity measurements.

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.
LIGHTMIXSENS_MAP_MIKROBUS( cfg, MIKROBUS_1 );
lightmixsens_init( &lightmixsens, &cfg );
lightmixsens_default_cfg( &lightmixsens );
lightmixsens_cdata = LIGHTMIXSENS_DUMMY_DATA;
lightmixsens_rdata = LIGHTMIXSENS_DUMMY_DATA;
lightmixsens_gdata = LIGHTMIXSENS_DUMMY_DATA;
lightmixsens_bdata = LIGHTMIXSENS_DUMMY_DATA;
lightmixsens_pdata = LIGHTMIXSENS_DUMMY_DATA;
log_printf( &logger, "* Light mix-sens click initialization done. *\r\n" );
}
#define LIGHTMIXSENS_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition lightmixsens.h:216
#define LIGHTMIXSENS_DUMMY_DATA
Definition lightmixsens.h:191
void application_init(void)
Definition main.c:47

Application Task

‍Waits until ALS/Color integration cycle was done and then reads the entire measurement. The all results will be sent to the selected UART terminal.

void application_task ( void )
{
lightmixsens_wait_atime( &lightmixsens );
lightmixsens_read_word( &lightmixsens, LIGHTMIXSENS_REG_CDATA, &lightmixsens_cdata );
lightmixsens_read_word( &lightmixsens, LIGHTMIXSENS_REG_RDATA, &lightmixsens_rdata );
lightmixsens_read_word( &lightmixsens, LIGHTMIXSENS_REG_GDATA_IRDATA, &lightmixsens_gdata );
lightmixsens_read_word( &lightmixsens, LIGHTMIXSENS_REG_BDATA, &lightmixsens_bdata );
lightmixsens_read_byte( &lightmixsens, LIGHTMIXSENS_REG_PDATA, &lightmixsens_pdata );
log_printf( &logger, "- Clear light: %d lx\r\n", lightmixsens_cdata );
log_printf( &logger, "- Red light: %d lx\r\n", lightmixsens_rdata );
log_printf( &logger, "- Green light: %d lx\r\n", lightmixsens_gdata );
log_printf( &logger, "- Blue light: %d lx\r\n", lightmixsens_bdata );
log_printf( &logger, "** Proximity: %s\r\n", prox_str );
log_printf( &logger, "\r\n" );
Delay_ms ( 1000 );
}
#define LIGHTMIXSENS_REG_CDATA
Definition lightmixsens.h:89
#define LIGHTMIXSENS_REG_PDATA
Definition lightmixsens.h:93
#define LIGHTMIXSENS_REG_RDATA
Definition lightmixsens.h:90
#define LIGHTMIXSENS_REG_BDATA
Definition lightmixsens.h:92
#define LIGHTMIXSENS_REG_GDATA_IRDATA
Definition lightmixsens.h:91
void lightmixsens_wait_atime(lightmixsens_t *ctx)
Wait ALS/Color Intregration Time Done function.
err_t lightmixsens_read_word(lightmixsens_t *ctx, uint8_t reg_addr, uint16_t *data_out)
Generic Read Word function.
void application_task(void)
Definition main.c:82
char prox_str[20]
Definition main.c:35
void prox_app(void)
Light mix sens proximity function.
Definition main.c:126

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.LightMixSens

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.