TOP Contributors

  1. MIKROE (2663 codes)
  2. Alcides Ramos (358 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (137081 times)
  2. FAT32 Library (70223 times)
  3. Network Ethernet Library (56095 times)
  4. USB Device Library (46413 times)
  5. Network WiFi Library (42032 times)
  6. FT800 Library (41377 times)
  7. GSM click (29109 times)
  8. mikroSDK (26556 times)
  9. PID Library (26487 times)
  10. microSD click (25486 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

Spectrometer 2 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.5

mikroSDK Library: 2.0.0.0

Category: Optical

Downloaded: 67 times

Not followed.

License: MIT license  

Spectrometer 2 Click is a compact add-on board that collects light waves. This board features the VD6283TX, a color sensor with advanced light flicker extraction from STMicroelectronics. The VD6283TX performs fast and accurate light measurements thanks to an individual ADC and a readout for each color channel - red, green, blue, IR, clear, and visible. It uses hybrid color filters with precise responses allowing accurate computation of the correlated color temperature (CCT) and Lux information. Its patented architecture and a high-performance photodiode design can also extract light-flickering frequencies to avoid banding effects or check that they are safe for the human eye.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Spectrometer 2 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Spectrometer 2 click" changes.

Do you want to report abuse regarding "Spectrometer 2 click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Spectrometer 2 click

Spectrometer 2 Click is a compact add-on board that collects light waves. This board features the VD6283TX, a color sensor with advanced light flicker extraction from STMicroelectronics. The VD6283TX performs fast and accurate light measurements thanks to an individual ADC and a readout for each color channel - red, green, blue, IR, clear, and visible. It uses hybrid color filters with precise responses allowing accurate computation of the correlated color temperature (CCT) and Lux information. Its patented architecture and a high-performance photodiode design can also extract light-flickering frequencies to avoid banding effects or check that they are safe for the human eye.

spectrometer2_click.png

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Apr 2022.
  • Type : I2C type

Software Support

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

Standard key functions :

  • spectrometer2_cfg_setup Config Object Initialization function.

    void spectrometer2_cfg_setup ( spectrometer2_cfg_t *cfg );
  • spectrometer2_init Initialization function.

    err_t spectrometer2_init ( spectrometer2_t *ctx, spectrometer2_cfg_t *cfg );
  • spectrometer2_default_cfg Click Default Configuration function.

    err_t spectrometer2_default_cfg ( spectrometer2_t *ctx );

Example key functions :

  • spectrometer2_get_data This function reads data from 6 ALS channels (Red, Visible, Blue, Green, IR, Clear).

    err_t spectrometer2_get_data ( spectrometer2_t *ctx, spectrometer2_als_channels_t *als_channels );
  • spectrometer2_rgbc_to_hsl This function converts RGBC (red, green, blue, clear) to HSL (hue, saturation, lightness) color value.

    void spectrometer2_rgbc_to_hsl ( spectrometer2_als_channels_t *rgbc, spectrometer2_hsl_t *hsl );
  • spectrometer2_get_color This function returns the color name flag from the input HSL color.

    uint8_t spectrometer2_get_color ( spectrometer2_hsl_t *hsl );

Example Description

This example demonstrates the use of Spectrometer 2 click board by reading data from 6 ALS 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;  /**< Logger config object. */
    spectrometer2_cfg_t spectrometer2_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.
    spectrometer2_cfg_setup( &spectrometer2_cfg );
    SPECTROMETER2_MAP_MIKROBUS( spectrometer2_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == spectrometer2_init( &spectrometer2, &spectrometer2_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( SPECTROMETER2_ERROR == spectrometer2_default_cfg ( &spectrometer2 ) )
    {
        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 ALS channels and converts them to HSL color and displays those data as well as the detected color name on the USB UART every 200ms approximately.

void application_task ( void )
{
    // Wait for the data ready interrupt indication
    while ( !spectrometer2_get_int_pin ( &spectrometer2 ) );

    spectrometer2_als_channels_t als_channels;
    if ( ( SPECTROMETER2_OK == spectrometer2_clear_interrupt ( &spectrometer2 ) ) &&
         ( SPECTROMETER2_OK == spectrometer2_get_data ( &spectrometer2, &als_channels ) ) )
    {
        spectrometer2_hsl_t hsl;
        spectrometer2_rgbc_to_hsl( &als_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 ( spectrometer2_get_color ( &hsl ) )
        {
            case SPECTROMETER2_RED_COLOR:
            {
                log_printf( &logger, " Color: RED\r\n" );
                break;
            }
            case SPECTROMETER2_YELLOW_COLOR:
            {
                log_printf( &logger, " Color: YELLOW\r\n" );
                break;
            }
            case SPECTROMETER2_GREEN_COLOR:
            {
                log_printf( &logger, " Color: GREEN\r\n" );
                break;
            }
            case SPECTROMETER2_CYAN_COLOR:
            {
                log_printf( &logger, " Color: CYAN\r\n" );
                break;
            }
            case SPECTROMETER2_BLUE_COLOR:
            {
                log_printf( &logger, " Color: BLUE\r\n" );
                break;
            }
            case SPECTROMETER2_MAGENTA_COLOR:
            {
                log_printf( &logger, " Color: MAGENTA\r\n" );
                break;
            }
            case SPECTROMETER2_WHITE_COLOR:
            {
                log_printf( &logger, " Color: WHITE\r\n" );
                break;
            }
            case SPECTROMETER2_BLACK_COLOR:
            {
                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.Spectrometer2

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.


ALSO FROM THIS AUTHOR

MUX 9 click

0

MUX 9 Click is a compact add-on board that contains a precise multiplexing solution. This board features the ADG1438, a CMOS 8-channel analog matrix switch with a high-speed serially controlled 4-wire interface from Analog Devices. Each switch is software-controlled (by a bit of the appropriate register) and conducts equally well in both directions, making it ideal for mux/demux applications. It is specified for a wide supply range ±15V/+12V/±5V where all channels exhibit break-before-make switching action, preventing momentary shorting when switching channels.

[Learn More]

IrDA 4 click

0

IrDA 4 Click is a compact add-on board that provides a cost-effective solution for sending and receiving IR serial data. This board features the TFBS4650, an infrared transceiver from Vishay Semiconductors. The transceiver includes a PIN photodiode, an infrared emitter, and a low-power integral circuit and complies with the IrDA physical layer specification.

[Learn More]

9DOF click

0

9DOF click carries ST’s LSM9DS1 inertial measurement module that combines a 3D accelerometer, a 3D gyroscope and a 3D magnetometer into a single device outputting so called nine degrees of freedom data...

[Learn More]