Unlock a world of precision with our color sensing solution, empowering you to capture and utilize the full spectrum of colors for unparalleled applications.
A
A
Hardware Overview
How does it work?
Color 17 Click is based on the OPT4048, a high-speed precision tristimulus XYZ color sensor from Texas Instruments, designed to mimic the human eye’s normal vision. The human eye has spectral sensitivity in a range of short, middle, and long wavelengths but in a correlation with a range of brightness. The CIE XYZ color space represents all color sensations visible to an average human eye, where the X is a mix of the three CIE RGB curves, the Y is the illuminance, and the Z is a quasi-equal to blue, according to the CIE 1931 model. The CIE XYZ is fixed color space, and one must note that there is a difference between the objects that emit light (and color) and objects that reflect light (and color). To put it more clearly, the monitor you look at and the wall behind it. The OPT4048 has three channels closely matching the CIE tristimulus spectra and a fourth with a wide-band spectral response. Measures from these channels give us the characteristics of the lighting environment, such as the light intensity, color, LUV coordinates, and correlated color temperature. While closely mimicking the human eye, the OPT4084
rejects the wavelengths from their peaks, especially the NIR region (infrared) that the human eye does not see, which is a crucial part of this sensor. To achieve excellent filter performance even at higher angles of light incidence, the OPT4084 uses advanced filter technology, high-resolution color measurements, and built-in automatic full-scale light range selection logic. By default, the OPT4048 is configured to operate in an automatic full-scale range detection mode that always selects the best full-scale range setting for the given lighting conditions. There are seven full-scale range settings, one of which can also be selected manually. Setting the device to operate in automatic full-scale range detection mode frees the user from having to program their software for potential iterative cycles of measurement and readjustment of the full-scale range until good for any given measurement. It also shows excellent linearity over the entire 26-bit dynamic range of measurement from 2.15mlux up to 144klux, with a highly linear response within each range. The Color 17 Click uses an I2C 2-Wire interface
supporting a Fast mode of up to 400kHz, and I2C burst mode to communicate with the host MCU. The I2C address can be selected via the ADDR SEL jumper with 0 selected by default. The sensor has several modes of operation: Power-Down mode, Continuous mode as a normal mode of operation, and a one-shot mode in which the sensor can be triggered to work depending on the user setup. One of the triggers can be the interrupt functionality, where the INT pin is used for hardware-synchronized triggers and interrupts. The OPT4084 features a threshold detection logic that allows the MCU to sleep or do other things while the sensor watches when an appropriate interrupt event occurs. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
Flip&Click PIC32MZ is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,
it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication
methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC32
MCU Memory (KB)
2048
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
524288
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for Color 17 Click driver.
Key functions:
color17_get_cct
- Color 17 gets correlated color temperature data function.color17_get_measurement
- Color 17 gets light and color measurement data function.color17_set_config
- Color 17 set the configuration function.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* @file main.c
* @brief Color 17 Click example
*
* # Description
* This library contains API for the Color 17 Click driver.
* This example displays CCT data, Light intensity level
* and the light color names.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initialization of I2C module and log UART.
* After driver initialization, default settings turn on the device.
*
* ## Application Task
* This example demonstrates the use of the Color 17 Click board™.
* Reads and displays the correlated color temperature
* and Light intensity level.
* This example also detects and displays the light color names.
* Results are being sent to the UART Terminal, where you can track their changes.
*
* @note
* Color detection is obtained based on the analysis
* of calculate the correlated color temperature (CCT) data
* and the CIE 1931 chromaticity diagram. For more details please refer to the
* “OPT4048 High Speed High Precision Tristimulus XYZ Color Sensor datasheet”
* (https://www.ti.com/lit/gpn/OPT4048).
* @author Nenad Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "color17.h"
#define COLOR17_LIM_DARK_LUX 10.0
#define COLOR17_CCT_LIM_BLUE_COLOR 7000
#define COLOR17_CCT_LIM_LIGHT_BLUE_COLOR 4000
#define COLOR17_CCT_LIM_GREEN_COLOR 3100
#define COLOR17_CCT_LIM_YELLOW_COLOR 2400
#define COLOR17_CCT_LIM_ORANGE_COLOR 1950
#define COLOR17_CCT_LIM_RED_COLOR 1600
static color17_t color17;
static log_t logger;
static float light_intensity, cct;
/**
* @brief Color 17 display color function.
* @details This function displays the light color names.
* @return Nothing.
* @note None.
*/
void color17_display_color ( void );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
color17_cfg_t color17_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
color17_cfg_setup( &color17_cfg );
COLOR17_MAP_MIKROBUS( color17_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == color17_init( &color17, &color17_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( COLOR17_ERROR == color17_default_cfg ( &color17 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
Delay_ms( 100 );
}
void application_task ( void )
{
if ( COLOR17_OK == color17_get_cct( &color17, &cct, &light_intensity ) )
{
log_printf( &logger, " CCT: %.2f\r\n", cct );
log_printf( &logger, " LIL: %.2f\r\n", light_intensity );
log_printf( &logger, " - - - - - - - - - - - \r\n" );
color17_display_color( );
}
log_printf( &logger, " ----------------------\r\n" );
Delay_ms( 1000 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
void color17_display_color ( void )
{
if ( light_intensity < COLOR17_LIM_DARK_LUX )
{
log_printf( &logger, " Color DARK\r\n", cct );
}
else if ( cct > COLOR17_CCT_LIM_BLUE_COLOR )
{
log_printf( &logger, " Color BLUE\r\n", cct );
}
else if ( cct > COLOR17_CCT_LIM_LIGHT_BLUE_COLOR )
{
log_printf( &logger, " Color LIGHT BLUE\r\n", cct );
}
else if ( cct > COLOR17_CCT_LIM_GREEN_COLOR )
{
log_printf( &logger, " Color GREEN\r\n", cct );
}
else if ( cct > COLOR17_CCT_LIM_YELLOW_COLOR )
{
log_printf( &logger, " Color YELLOW\r\n", cct );
}
else if ( cct > COLOR17_CCT_LIM_ORANGE_COLOR )
{
log_printf( &logger, " Color ORANGE\r\n", cct );
}
else if ( cct > COLOR17_CCT_LIM_RED_COLOR )
{
log_printf( &logger, " Color RED\r\n", cct );
}
else
{
log_printf( &logger, " Color BLUE\r\n", cct );
}
}
// ------------------------------------------------------------------------ END