TOP Contributors

  1. MIKROE (2752 codes)
  2. Alcides Ramos (372 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (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 (139067 times)
  2. FAT32 Library (71594 times)
  3. Network Ethernet Library (56989 times)
  4. USB Device Library (47330 times)
  5. Network WiFi Library (43006 times)
  6. FT800 Library (42297 times)
  7. GSM click (29777 times)
  8. mikroSDK (27874 times)
  9. PID Library (26858 times)
  10. microSD click (26129 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 click

Rating:

5

Author: MIKROE

Last Updated: 2020-07-20

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: Optical

Downloaded: 2407 times

Not followed.

License: MIT license  

Spectrometer Click features an 11-channel spectrometer for spectral identification and color matching applications. The spectral response is defined in the wavelengths from approximately 350nm to 1000nm. Control and Spectral data access are implemented through a serial I²C interface with very a low power consumption.

No Abuse Reported

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

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

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

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

Spectrometer Click

Spectrometer Click

Native view of the Spectrometer Click board.

View full image
Spectrometer Click

Spectrometer Click

Front and back view of the Spectrometer Click board.

View full image

Library Description

The library covers necessary functions that enables the usage of the Spectrometer click board. User can read or write data in and from registers, check interrupt state, set diferent configuration and read data from all channels available.

Key functions:

  • void spectrometer_raw_rd_val_mode_1 ( uint8_t *adc_data ); - Function is used to read out channels with SMUX configration 1; F1-F4, Clear.
  • void spectrometer_raw_rd_val_mode_2 ( uint8_t *adc_data ); - Function is used to read out channels with SMUX configration 2; F5-F8, Clear.
  • uint8_t spectrometer_flicker_detection ( ); - Function is used to detect flicker for 100 and 120 Hz.

Examples description

The application is composed of three sections :

  • System Initialization - Initializes I2C module, LOG structure and sets INT pin as input.
  • Application Initialization - Initalizes I2C driver, performs safety check and makes an initial log.
  • Application Task - This example shows the capabilities of the Spectrometer click by reading out channels with SMUX configrations 1 and 2, detecting flicker for 100 and 120 Hz and displaying data via USART terminal.
void application_task ( )
{  
    spectrometer_def_cfg( );
    
    spectrometer_raw_rd_val_mode_1( adc_buf );
    
    ch_0 = adc_buf[ 1 ];
    ch_0 <<= 8;
    ch_0 |= adc_buf[ 0 ];
    WordToStr( ch_0, log_txt );
    mikrobus_logWrite( " ADC0/F1 : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    ch_1 = adc_buf[ 3 ];
    ch_1 <<= 8;
    ch_1 |= adc_buf[ 2 ];
    WordToStr( ch_1, log_txt );
    mikrobus_logWrite( " ADC1/F2 : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    ch_2 = adc_buf[ 5 ];
    ch_2 <<= 8;
    ch_2 |= adc_buf[ 4 ];
    WordToStr( ch_2, log_txt );
    mikrobus_logWrite( " ADC2/F3 : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    ch_3 = adc_buf[ 7 ];
    ch_3 <<= 8;
    ch_3 |= adc_buf[ 6 ];
    WordToStr( ch_3, log_txt );
    mikrobus_logWrite( " ADC3/F4 : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    ch_4 = adc_buf[ 9 ];
    ch_4 <<= 8;
    ch_4 |= adc_buf[ 8 ];
    WordToStr( ch_4, log_txt );
    mikrobus_logWrite( " ADC4/Clear : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    spectrometer_raw_rd_val_mode_2( adc_buf );
    
    ch_0 = adc_buf[ 1 ];
    ch_0 <<= 8;
    ch_0 |= adc_buf[ 0 ];
    WordToStr( ch_0, log_txt );
    mikrobus_logWrite( " ADC0/F5 : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    ch_1 = adc_buf[ 3 ];
    ch_1 <<= 8;
    ch_1 |= adc_buf[ 2 ];
    WordToStr( ch_1, log_txt );
    mikrobus_logWrite( " ADC1/F6 : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    ch_2 = adc_buf[ 5 ];
    ch_2 <<= 8;
    ch_2 |= adc_buf[ 4 ];
    WordToStr( ch_2, log_txt );
    mikrobus_logWrite( " ADC2/F7 : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    ch_3 = adc_buf[ 7 ];
    ch_3 <<= 8;
    ch_3 |= adc_buf[ 6 ];
    WordToStr( ch_3, log_txt );
    mikrobus_logWrite( " ADC3/F8 : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    ch_4 = adc_buf[ 9 ];
    ch_4 <<= 8;
    ch_4 |= adc_buf[ 8 ];
    WordToStr( ch_4, log_txt );
    mikrobus_logWrite( " ADC4/Clear : ", _LOG_TEXT );
    Ltrim( log_txt );
    mikrobus_logWrite( log_txt, _LOG_LINE );

    f_val = spectrometer_flicker_detection( );
    if ( f_val == SPECTROMETER_UNKNOWN_FREQ )
    {
        mikrobus_logWrite( "Unknown frequency", _LOG_LINE );
    }
    else if ( f_val == SPECTROMETER_DETECTED_100_HZ )
    {
        mikrobus_logWrite( "100 Hz detected", _LOG_LINE );
    }
    else if ( f_val == SPECTROMETER_DETECTED_120_HZ )
    {
        mikrobus_logWrite( "120 Hz detected", _LOG_LINE );
    }
    else
    {
        mikrobus_logWrite( "Error in reading", _LOG_LINE );
    }

    mikrobus_logWrite( "-----------------", _LOG_LINE );
    Delay_ms( 1000 );
}

Other mikroE Libraries used in the example:

  • I2C
  • UART
  • Conversions

Additional notes and informations

Depending on the development board you are using, you may need USB UART clickUSB 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.

ALSO FROM THIS AUTHOR

H-Bridge 8 Click

0

H-Bridge 8 Click is a compact add-on board that contains H-bridge current regulator. This board features the MP6519, a monolithic, step-down, current-source driver for applications that require accurate and fast current-response control from Monolithic Power Systems (MPS). It achieves excellent load and line regulation over a wide input supply range up to 28V. The four integrated MOSFET H-bridge control provide a fast dynamic load response and an ultra-high efficiency solution. Complete protection features include load open, load-short protection, over-current protection (OCP), over-temperature protection (OTP), and input over-voltage protection (OVP). This Click board™ is suitable as a current-regulator brushed DC motor/solenoid driver for various applications

[Learn More]

RTC 9 Click

0

RTC 9 Click is a real-time clock module that has an extremely low power consumption, allowing it to be used with a single button cell battery, for an extended period of time. This board features the M41T82, real-time clock (RTC) with battery switchover, from ST Microelectronics.

[Learn More]

Thermostat click

1

Thermostat click carries the MAX7502 IC digital temperature sensor, that also provides an overtemperature alarm/interrupt/shutdown output, and an SN74LVC1G126 single bus buffer from Texas Instruments. MAX7502 IC can measure temperatures from -25°C to +100°C, within the accuracy of ±1.5°C.

[Learn More]