color15 2.0.0.0
Main Page

Color 15 click

‍Color 15 Click is a compact add-on board representing an accurate color sensing solution. This board features the CLS-16D24-44-DF8/TR8, a low power, high sensitivity, color light sensor from Everlight Electronics. This Click boardâ„¢, with an I2C configurable color sensor, senses red, green, blue, white (RGBW), and infrared light and converts them to digital values. The RGBW sensor is designed to reject IR in light sources allowing the device to operate in environments from sunlight to dark rooms. The integrating ADC rejects 50Hz and 60Hz flickers caused by artificial light sources.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Apr 2022.
  • Type : I2C type

Software Support

We provide a library for the Color 15 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 from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

‍This library contains API for Color 15 Click driver.

Standard key functions :

Example key functions :

Example Description

‍This example demonstrates the use of Color 15 click board by reading data from 5 channels and converting them to HSL color and displaying those data as

well as the detected color name on the USB UART.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
color15_cfg_t color15_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
color15_cfg_setup( &color15_cfg );
COLOR15_MAP_MIKROBUS( color15_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == color15_init( &color15, &color15_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( COLOR15_ERROR == color15_default_cfg ( &color15 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ COLOR15_ERROR
Definition color15.h:356
#define COLOR15_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition color15.h:280
void application_init(void)
Definition main.c:31

Application Task

‍Waits for the data ready interrupt, then reads the values of all channels and converts them to HSL color and displays those data as well as the detected color name on the USB UART

every 500ms approximately.

void application_task ( void )
{
// Wait for the data ready interrupt indication
while ( color15_get_int_pin ( &color15 ) );
if ( ( COLOR15_OK == color15_clear_interrupt ( &color15 ) ) &&
( COLOR15_OK == color15_get_data ( &color15, &channels ) ) )
{
color15_rgbw_to_hsl ( &color15, &channels, &hsl );
log_printf ( &logger, "\r\n Hue: %.1f deg\r\n", hsl.hue );
log_printf ( &logger, " Saturation: %.1f %%\r\n", hsl.saturation );
log_printf ( &logger, " Lightness: %.1f %%\r\n", hsl.lightness );
switch ( color15_get_color ( &hsl ) )
{
{
log_printf( &logger, " Color: RED\r\n" );
break;
}
{
log_printf( &logger, " Color: YELLOW\r\n" );
break;
}
{
log_printf( &logger, " Color: GREEN\r\n" );
break;
}
{
log_printf( &logger, " Color: CYAN\r\n" );
break;
}
{
log_printf( &logger, " Color: BLUE\r\n" );
break;
}
{
log_printf( &logger, " Color: MAGENTA\r\n" );
break;
}
{
log_printf( &logger, " Color: WHITE\r\n" );
break;
}
{
log_printf( &logger, " Color: BLACK\r\n" );
break;
}
default:
{
log_printf( &logger, " Color: UNKNOWN\r\n" );
break;
}
}
}
}
@ COLOR15_OK
Definition color15.h:355
#define COLOR15_YELLOW_COLOR
Definition color15.h:221
#define COLOR15_WHITE_COLOR
Definition color15.h:226
#define COLOR15_BLACK_COLOR
Definition color15.h:227
#define COLOR15_RED_COLOR
Definition color15.h:220
#define COLOR15_BLUE_COLOR
Definition color15.h:224
#define COLOR15_MAGENTA_COLOR
Definition color15.h:225
#define COLOR15_GREEN_COLOR
Definition color15.h:222
#define COLOR15_CYAN_COLOR
Definition color15.h:223
err_t color15_clear_interrupt(color15_t *ctx)
Color 15 clear interrupt function.
uint8_t color15_get_int_pin(color15_t *ctx)
Color 15 get int pin function.
void application_task(void)
Definition main.c:67
float hue
Definition color15.h:343
float saturation
Definition color15.h:344
float lightness
Definition color15.h:345

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Color15

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. UART terminal is available in all MikroElektronika compilers.