TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (387 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (120 codes)
  5. Bugz Bensce (97 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 (140168 times)
  2. FAT32 Library (72621 times)
  3. Network Ethernet Library (57641 times)
  4. USB Device Library (47955 times)
  5. Network WiFi Library (43553 times)
  6. FT800 Library (42942 times)
  7. GSM click (30140 times)
  8. mikroSDK (28669 times)
  9. PID Library (27056 times)
  10. microSD click (26552 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 4 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-11-25

Package Version: 2.1.0.4

mikroSDK Library: 2.0.0.0

Category: Optical

Downloaded: 34 times

Not followed.

License: MIT license  

Light 4 Click is a compact add-on board designed for precise ambient light, UV index, and light flicker detection. This board features the TSL2585 sensor from ams OSRAM, which incorporates photopic, infrared (IR), and ultraviolet (UV) photodiodes to enable multiple concurrent sensing functions. The TSL2585 continuously monitors ambient light, calculates irradiance, and detects light flicker using optimized filters and dedicated IR and UV channels. It communicates with the host MCU via a standard I2C interface, includes interrupt-driven events for threshold-based alerts, and operates with 3.3V logic voltage.

No Abuse Reported

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

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

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

  • Information
  • Comments (0)

mikroSDK Library Blog


Light 4 Click

Light 4 Click is a compact add-on board designed for precise ambient light, UV index, and light flicker detection. This board features the TSL2585 sensor from ams OSRAM, which incorporates photopic, infrared (IR), and ultraviolet (UV) photodiodes to enable multiple concurrent sensing functions. The TSL2585 continuously monitors ambient light, calculates irradiance, and detects light flicker using optimized filters and dedicated IR and UV channels. It communicates with the host MCU via a standard I2C interface, includes interrupt-driven events for threshold-based alerts, and operates with 3.3V logic voltage.

light4_click.png

Click Product page


Click library

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

Software Support

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

Standard key functions :

  • light4_cfg_setup Config Object Initialization function.

    void light4_cfg_setup ( light4_cfg_t *cfg );
  • light4_init Initialization function.

    err_t light4_init ( light4_t *ctx, light4_cfg_t *cfg );
  • light4_default_cfg Click Default Configuration function.

    err_t light4_default_cfg ( light4_t *ctx );

Example key functions :

  • light4_write_reg This function writes a byte into the selected register by using I2C serial interface.

    err_t light4_write_reg ( light4_t *ctx, uint8_t reg, uint8_t data_in );
  • light4_sw_reset This function is used to perform software reset of Light 4 Click board.

    err_t light4_sw_reset ( light4_t *ctx );
  • light4_read_channel_data This function is used to read data from selected channel of Light 4 Click board.

    err_t light4_read_channel_data ( light4_t *ctx, uint8_t channel_sel, float *channel_data );

Example Description

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

The demo application is composed of two sections :

Application Init

Initializes the driver, performs the Click default configuration and checking I2C Communication by reading Device ID.


void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    light4_cfg_t light4_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.
    light4_cfg_setup( &light4_cfg );
    LIGHT4_MAP_MIKROBUS( light4_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == light4_init( &light4, &light4_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( LIGHT4_ERROR == light4_default_cfg ( &light4 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    uint8_t dev_id = 0;
    light4_read_reg ( &light4, LIGHT4_REG_ID, &dev_id ); 
    if ( LIGHT4_DEVICE_ID == dev_id )
    {
        log_printf( &logger, " Device ID: 0x%.2X \r\n", ( uint16_t ) dev_id );
    }
    else
    {
        log_error( &logger, " Read error." );
        for ( ; ; );
    }

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

Application Task

Reading channel 0 ambient light level in lux once per second and displaying it on the UART terminal.

void application_task ( void ) 
{
    float channel_data = 0;
    err_t error_flag;

    error_flag = light4_read_channel_data( &light4, LIGHT4_CHANNEL0_SEL, &channel_data );
    if( LIGHT4_OK == error_flag )
    {
        log_printf( &logger, " Data: %.2f Lux \r\n", channel_data );
    }
    else if ( LIGHT4_ANALOG_SAT == error_flag )
    {
        log_error( &logger, " Analog saturation \r\n" );
    }

    Delay_ms ( 1000 );
}

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

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

UT-L 7-SEG R Click

0

UT-L 7-SEG R Click carries two SMD ultra thin LED 7-SEG displays and the MAX6969 constant-current LED driver from Maxim Integrated. The Click is designed to run on either 3.3V or 5V power supply. It communicates with the target microcontroller over SPI interface.

[Learn More]

Color 18 Click

0

Color 18 Click is a compact add-on board for accurate ambient light detection and flicker monitoring. This board features the TCS3530, a true color ambient light sensor from ams OSRAM. The TCS3530 features true color XYZ sensing, flicker detection up to 7kHz, and eight concurrent sensing channels with independent gain configurations. It also includes a UV/IR blocking filter for precise light measurements and a unique Click Snap feature, allowing the main sensor area to become movable by breaking the PCB for flexible implementation.

[Learn More]

DHT22 2 Click

0

DHT22 2 Click is used for measuring the environmental temperature and relative humidity. It uses the AM2322 sensor, with very accurate thermal and humidity measuring capabilities. It can use either 1-Wire or I2C protocol to communicate with the integrated circuit.

[Learn More]