spectral 2.0.0.0
Main Page

Spectral click

‍Spectral click is a multispectral light sensing device, which uses the state-of-the-art sensor IC for a very accurate chromatic white color sensing.

click Product page


Click library

  • Author : MikroE Team
  • Date : Mar 2020.
  • Type : UART type

Software Support

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

Standard key functions :

Example key functions :

  • spectral_uart_read Generic read function.
    int32_t spectral_uart_read ( spectral_t *ctx, uint8_t *data_buf, uint16_t max_len );
    int32_t spectral_uart_read(spectral_t *ctx, uint8_t *data_buf, uint16_t max_len)
    Generic read function.
  • spectral_send_command Send Command
    void spectral_send_command ( spectral_t *ctx, uint8_t *command );
    void spectral_send_command(spectral_t *ctx, uint8_t *command)
    Send Command.
  • spectral_get_data Read raw X, Y, Z and NIR data as well as two special internal registers D, & C.
    void spectral_get_data ( uint8_t *rsp, uint16_t *c_data );
    void spectral_get_data(uint8_t *rsp, uint16_t *c_data)
    Read raw X, Y, Z and NIR data as well as two special internal registers D, & C.

Examples Description

‍This example reads and processes data from Spectral clicks.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and configures the sensor.

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.
SPECTRAL_MAP_MIKROBUS( cfg, MIKROBUS_1 );
spectral_init( &spectral, &cfg );
spectral_module_reset( &spectral );
Delay_ms ( 500 );
log_printf( &logger, "Configuring the sensor...\r\n" );
log_printf( &logger, "The sensor has been configured!\r\n" );
Delay_ms ( 1000 );
}
#define SPECTRAL_MAP_MIKROBUS(cfg, mikrobus)
Definition spectral.h:66
void spectral_module_reset(spectral_t *ctx)
Reset module.
void application_init(void)
Definition main.c:113
#define SPECTRAL_CMD_GAIN
Definition main.c:35
#define SPECTRAL_CMD_AT
Definition main.c:34
void spectral_process(void)
Definition main.c:47
#define SPECTRAL_CMD_MODE
Definition main.c:36

Application Task

‍Reads the values of all 6 channels and parses it to the USB UART each second.

void application_task ( void )
{
}
void parser_application()
Definition main.c:94
void application_task(void)
Definition main.c:150

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

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.