TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 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 (139253 times)
  2. FAT32 Library (71751 times)
  3. Network Ethernet Library (57122 times)
  4. USB Device Library (47430 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42403 times)
  7. GSM click (29835 times)
  8. mikroSDK (28078 times)
  9. PID Library (26885 times)
  10. microSD click (26198 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

Light 3 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.5

mikroSDK Library: 2.0.0.0

Category: Optical

Downloaded: 67 times

Not followed.

License: MIT license  

Light 3 Click is a compact add-on board for precise ambient light measurement in automotive applications. This board features the OPT4003-Q1, an automotive-grade digital ambient light sensor from Texas Instruments. This digital ambient light sensor excels in detecting both visible and near-infrared light with high accuracy, thanks to its dual-channel functionality and filters that mimic the human eye's response while efficiently segregating NIR light.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Light 3 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Light 3 Click" changes.

Do you want to report abuse regarding "Light 3 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Light 3 Click

Light 3 Click is a compact add-on board for precise ambient light measurement in automotive applications. This board features the OPT4003-Q1, an automotive-grade digital ambient light sensor from Texas Instruments. This digital ambient light sensor excels in detecting both visible and near-infrared light with high accuracy, thanks to its dual-channel functionality and filters that mimic the human eye's response while efficiently segregating NIR light.

light3_click.png

Click Product page


Click library

  • Author : Stefan Ilic
  • Date : Jan 2024.
  • Type : I2C type

Software Support

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

Standard key functions :

  • light3_cfg_setup Config Object Initialization function.

    void light3_cfg_setup ( light3_cfg_t *cfg );
  • light3_init Initialization function.

    err_t light3_init ( light3_t *ctx, light3_cfg_t *cfg );
  • light3_default_cfg Click Default Configuration function.

    err_t light3_default_cfg ( light3_t *ctx );

Example key functions :

  • light3_sw_reset This function is used to perform software reset.

    err_t light3_sw_reset ( light3_t *ctx );
  • light3_write_reg This function writes a desired data into the selected register by using I2C serial interface.

    err_t light3_write_reg ( light3_t *ctx, uint8_t reg, uint16_t data_in );
  • light3_get_ch0_data This function reads ambient light data from the Channel 0 and performs the calculatios from raw data to Lux.

    err_t light3_get_ch0_data ( light3_t *ctx, float *lux );

Example Description

This example demonstrates the use of Light 3 Click board by measuring the ambient light level in Lux.

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. */
    light3_cfg_t light3_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.
    light3_cfg_setup( &light3_cfg );
    LIGHT3_MAP_MIKROBUS( light3_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == light3_init( &light3, &light3_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( LIGHT3_ERROR == light3_default_cfg ( &light3 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

Application Task

Reading channel 0 ambient light level in lux as soon as it is available ( once in 1.6 seconds ) and displaying it on the UART terminal.

void application_task ( void ) 
{
    float lux_data = 0;
    if ( LIGHT3_PIN_STATE_LOW == light3_get_int_pin( &light3 ) )
    { 
        light3_get_ch0_data( &light3, &lux_data );
        log_printf( &logger, "Light level: %f lux \r\n", ( float ) lux_data );
    }
}

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

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

Load Cell 4 Click

0

Load Cell 4 Click is a compact add-on board that contains a resistive sensor signal conditioner with a fast power-up data output response. This board features the ZSC31014, a CMOS integrated circuit for highly accurate amplification and analog-to-digital conversion of differential and half-bridge input signals from Renesas.

[Learn More]

Color 3 click

1

Color 3 click is a mikroBUS add-on board with a TCS3771 color sensor (also known as a light-to-digital converter) and a narrow beam Infrared LED. The circuit can also function as a proximity sensor. TCS3771 is a RGBC sensor: it can detect Red, Green, Blue and clear light. The IC performs well under a variety of lighting conditions.

[Learn More]

ADC 19 Click

0

ADC 19 Click is a compact add-on board that contains a high-performance data converter. This board features the ADC122S101, a low-power two-channel CMOS 12-bit analog-to-digital converter from Texas Instruments. This SPI configurable analog-to-digital converter (ADC) is fully specified over a sample rate range of 500ksps to 1Msps, offering high reliability and performance. The converter is based on a successive-approximation register architecture with an internal track-and-hold circuit configurable to accept one or two input signals at its input channels.

[Learn More]