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 );
  • spectral_send_command Send Command
    void spectral_send_command ( spectral_t *ctx, uint8_t *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 );

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

Application Task

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

void application_task ( void )
{
}

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.


spectral_init
err_t spectral_init(spectral_t *ctx, spectral_cfg_t *cfg)
Initialization function.
parser_application
void parser_application()
Definition: main.c:94
spectral_cfg_setup
void spectral_cfg_setup(spectral_cfg_t *cfg)
Config Object Initialization function.
spectral_module_reset
void spectral_module_reset(spectral_t *ctx)
Reset module.
spectral_get_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.
spectral_send_command
void spectral_send_command(spectral_t *ctx, uint8_t *command)
Send Command.
SPECTRAL_MAP_MIKROBUS
#define SPECTRAL_MAP_MIKROBUS(cfg, mikrobus)
Definition: spectral.h:52
spectral_cfg_t
Click configuration structure definition.
Definition: spectral.h:104
spectral_process
void spectral_process(void)
Definition: main.c:47
spectral_uart_read
int32_t spectral_uart_read(spectral_t *ctx, uint8_t *data_buf, uint16_t max_len)
Generic read function.
application_task
void application_task(void)
Definition: main.c:150
spectral_t
Click ctx object definition.
Definition: spectral.h:85
SPECTRAL_CMD_GAIN
#define SPECTRAL_CMD_GAIN
Definition: main.c:35
SPECTRAL_CMD_AT
#define SPECTRAL_CMD_AT
Definition: main.c:34
application_init
void application_init(void)
Definition: main.c:113
SPECTRAL_CMD_MODE
#define SPECTRAL_CMD_MODE
Definition: main.c:36