Discover how our solution brings accuracy and clarity to color analysis in various applications
A
A
Hardware Overview
How does it work?
Color 13 Click is based on the APDS-9999, an RGB and proximity sensor with 940nm VCSEL from Broadcom Limited. The APDS-9999 uses four individual channels of red, green, blue, and IR in a specially designed matrix arrangement, allowing the device to have an optimal angular response and accurate RGB spectral response with high Lux accuracy over various light sources. The device detects light intensity under multiple lighting conditions and through different attenuation materials, including dark glass. The APDS-9999 is configurable as an ambient light and RGB sensor. It is also fast enough to provide proximity detection (PS) information at a high repetition rate, operating well from bright sunlight to dark
rooms. PS resolution can be varied from 8 to 11 bits, with the measurement rate from 6.25ms to 400ms. To offset unwanted reflected light from the cover glass, a PS intelligent cancellation level register allows for an on-chip subtraction of the ADC count contributed by any unwanted reflected light from the cover glass. Adding the micro-optic lenses within the module provides highly efficient transmission and reception of infrared energy, lowering overall power dissipation. In addition, the APDS-9999 can be put into a low-power standby mode, providing low average power consumption. Color 13 Click communicates with MCU using the standard I2C 2-Wire interface to read data and configure settings, supporting Fast Mode
operation with a clock frequency of up to 400kHz. It also features an intelligent interrupt function that generates independent light and proximity interrupt signals, available on the INT pin of the mikroBUS™ socket, which reduces power consumption by eliminating polling communication traffic between the sensor and MCU. 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
EasyAVR v7 is the seventh generation of AVR development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit AVR microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyAVR v7 allows you to connect accessory boards, sensors, and custom electronics more
efficiently than ever. Each part of the EasyAVR v7 development board contains the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-12V AC or 9-15V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B)
connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets which cover a wide range of 16-bit AVR MCUs. EasyAVR v7 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development 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
AVR
MCU Memory (KB)
64
Silicon Vendor
Microchip
Pin count
40
RAM (Bytes)
4096
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for Color 13 Click driver.
Key functions:
color13_get_rgb_ir
- Read color data from devicecolor13_get_als
- Read lux data from device.color13_get_proximity
- Read proximity data from device
Open Source
Code example
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.
/*!
* @file main.c
* @brief Color13 Click example
*
* # Description
* This application showcases ability of click board to read RGB and IR data
* from device. Also it can be configured to read proximity data and
* ALS data in lux units.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initialization of host communication modules (UART, I2C) and additonal pin.
* Read and check device ID, selects example and configures device for it.
*
* ## Application Task
* Depending of selected example in task proximity and als data will be read from
* device, or it will show ADC value for red, green, blue and ir data from device.
*
* ### Additioal function
* static void color13_proximity_als_example ( void );
* static void color13_rgb_example ( void );
*
* @author Luka Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "color13.h"
#define COLOR13_EXAMPLE_PS_LS 3
#define COLOR13_EXAMPLE_RGB 6
static color13_t color13;
static log_t logger;
static uint8_t example_type;
/**
* @brief Proximity and Als data reading.
* @details Example function for reading proximity and als data.
* @return Nothing
*/
static void color13_proximity_als_example ( void );
/**
* @brief RGB data reading.
* @details Example function for reading rgb and ir data.
* @return Nothing
*/
static void color13_rgb_example ( void );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
color13_cfg_t color13_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.
color13_cfg_setup( &color13_cfg );
COLOR13_MAP_MIKROBUS( color13_cfg, MIKROBUS_1 );
err_t init_flag = color13_init( &color13, &color13_cfg );
if ( I2C_MASTER_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
uint8_t temp_data = 0;
init_flag = color13_generic_read( &color13, COLOR13_REG_PART_ID, &temp_data, 1 );
log_printf( &logger, " > ID: 0x%.2X\r\n", ( uint16_t )temp_data );
if ( ( COLOR13_OK != init_flag ) && ( COLOR13_ID != temp_data ) )
{
log_error( &logger, " ID" );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
//Select example
example_type = COLOR13_EXAMPLE_RGB;
color13_generic_write( &color13, COLOR13_REG_MAIN_CTRL, &example_type, 1 );
if ( COLOR13_EXAMPLE_PS_LS == example_type )
{
//Configure proximity data to 11 bit
color13_generic_read( &color13, COLOR13_REG_PS_MEASRATE, &temp_data, 1 );
temp_data |= 0x18;
color13_generic_write( &color13, COLOR13_REG_PS_MEASRATE, &temp_data, 1 );
}
Delay_ms( 1000 );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
switch ( example_type )
{
case COLOR13_EXAMPLE_PS_LS:
{
color13_proximity_als_example( );
break;
}
case COLOR13_EXAMPLE_RGB:
{
color13_rgb_example( );
break;
}
default:
{
log_error( &logger, " Select example!" );
break;
}
}
Delay_ms( 500 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
static void color13_proximity_als_example ( void )
{
//Proximity data
uint16_t ps_data = 0;
err_t error_flag = color13_get_proximity( &color13, &ps_data );
log_printf( &logger, " > PS: %u\r\n", ps_data );
if ( COLOR13_ERROR_OVF == error_flag )
{
log_error( &logger, " Overflow" );
}
//ALS data
float lux = 0;
color13_get_als( &color13, &lux );
log_printf( &logger, " > LS[ lux ]: %.2f\r\n", lux );
log_printf( &logger, "**********************************\r\n" );
}
static void color13_rgb_example ( void )
{
color13_color_t color_data;
color13_get_rgb_ir( &color13, &color_data );
log_printf( &logger, " > R: %u\r\n", color_data.red );
log_printf( &logger, " > G: %u\r\n", color_data.green );
log_printf( &logger, " > B: %u\r\n", color_data.blue );
log_printf( &logger, " > IR: %u\r\n", color_data.ir );
log_printf( &logger, "**********************************\r\n" );
}
// ------------------------------------------------------------------------ END