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 " );
}

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;
}
}
}
}

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.


COLOR15_WHITE_COLOR
#define COLOR15_WHITE_COLOR
Definition: color15.h:222
color15_hsl_t::lightness
float lightness
Definition: color15.h:341
color15_get_int_pin
uint8_t color15_get_int_pin(color15_t *ctx)
Color 15 get int pin function.
COLOR15_YELLOW_COLOR
#define COLOR15_YELLOW_COLOR
Definition: color15.h:217
COLOR15_BLUE_COLOR
#define COLOR15_BLUE_COLOR
Definition: color15.h:220
color15_init
err_t color15_init(color15_t *ctx, color15_cfg_t *cfg)
Color 15 initialization function.
color15_get_data
err_t color15_get_data(color15_t *ctx, color15_channels_t *channels)
Color 15 get data function.
color15_default_cfg
err_t color15_default_cfg(color15_t *ctx)
Color 15 default configuration function.
color15_cfg_setup
void color15_cfg_setup(color15_cfg_t *cfg)
Color 15 configuration object setup function.
application_task
void application_task(void)
Definition: main.c:67
COLOR15_CYAN_COLOR
#define COLOR15_CYAN_COLOR
Definition: color15.h:219
color15_rgbw_to_hsl
void color15_rgbw_to_hsl(color15_t *ctx, color15_channels_t *rgbw, color15_hsl_t *hsl)
Color 15 rgbw to hsl function.
COLOR15_RED_COLOR
#define COLOR15_RED_COLOR
Definition: color15.h:216
COLOR15_OK
@ COLOR15_OK
Definition: color15.h:351
COLOR15_BLACK_COLOR
#define COLOR15_BLACK_COLOR
Definition: color15.h:223
color15_channels_t
Color 15 RGBWIR channels data object.
Definition: color15.h:324
COLOR15_MAP_MIKROBUS
#define COLOR15_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: color15.h:276
color15_hsl_t::saturation
float saturation
Definition: color15.h:340
color15_clear_interrupt
err_t color15_clear_interrupt(color15_t *ctx)
Color 15 clear interrupt function.
application_init
void application_init(void)
Definition: main.c:31
COLOR15_ERROR
@ COLOR15_ERROR
Definition: color15.h:352
color15_get_color
uint8_t color15_get_color(color15_hsl_t *hsl)
Color 15 get color function.
color15_hsl_t::hue
float hue
Definition: color15.h:339
color15_t
Color 15 Click context object.
Definition: color15.h:289
COLOR15_MAGENTA_COLOR
#define COLOR15_MAGENTA_COLOR
Definition: color15.h:221
COLOR15_GREEN_COLOR
#define COLOR15_GREEN_COLOR
Definition: color15.h:218
color15_hsl_t
Color 15 HSL color data object.
Definition: color15.h:338
color15_cfg_t
Color 15 Click configuration object.
Definition: color15.h:308