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 (140167 times)
  2. FAT32 Library (72621 times)
  3. Network Ethernet Library (57641 times)
  4. USB Device Library (47954 times)
  5. Network WiFi Library (43553 times)
  6. FT800 Library (42942 times)
  7. GSM click (30140 times)
  8. mikroSDK (28669 times)
  9. PID Library (27055 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

Ambient 14 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.2

mikroSDK Library: 2.0.0.0

Category: Optical

Downloaded: 21 times

Not followed.

License: MIT license  

Ambient 14 Click is a compact add-on board for ambient light and proximity detection applications. This board features the TMD2755, an advanced sensor from ams OSRAM, which combines ambient light sensing (ALS) and proximity detection in a single, compact module. The TMD2755 features an integrated infrared VCSEL and driver and a proximity engine that includes offset adjustment and ambient light subtraction for enhanced accuracy. It provides 16-bit data output for ALS and proximity detection, allowing precise control of backlight brightness in devices.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Ambient 14 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Ambient 14 Click" changes.

Do you want to report abuse regarding "Ambient 14 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Ambient 14 Click

Ambient 14 Click is a compact add-on board for ambient light and proximity detection applications. This board features the TMD2755, an advanced sensor from ams OSRAM, which combines ambient light sensing (ALS) and proximity detection in a single, compact module. The TMD2755 features an integrated infrared VCSEL and driver and a proximity engine that includes offset adjustment and ambient light subtraction for enhanced accuracy. It provides 16-bit data output for ALS and proximity detection, allowing precise control of backlight brightness in devices.

ambient14_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jun 2024.
  • Type : I2C type

Software Support

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

Standard key functions :

  • ambient14_cfg_setup Config Object Initialization function.

    void ambient14_cfg_setup ( ambient14_cfg_t *cfg );
  • ambient14_init Initialization function.

    err_t ambient14_init ( ambient14_t *ctx, ambient14_cfg_t *cfg );
  • ambient14_default_cfg Click Default Configuration function.

    err_t ambient14_default_cfg ( ambient14_t *ctx );

Example key functions :

  • ambient14_read_proximity This function reads the raw proximity data. The higher the value, the closer the detected object is.

    err_t ambient14_read_proximity ( ambient14_t *ctx, uint16_t *prox_data );
  • ambient14_read_als_ir This function reads the raw ALS and IR data.

    err_t ambient14_read_als_ir ( ambient14_t *ctx, uint16_t *als_data, uint16_t *ir_data );
  • ambient14_get_illuminance This function calculates the illuminance level (Lux) from ALS data counts input.

    err_t ambient14_get_illuminance ( ambient14_t *ctx, uint16_t als_data, float *illuminance );

Example Description

This example demonstrates the use of Ambient 14 Click board by measuring the illuminance level (Lux) and the proximity data 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. */
    ambient14_cfg_t ambient14_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.
    ambient14_cfg_setup( &ambient14_cfg );
    AMBIENT14_MAP_MIKROBUS( ambient14_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == ambient14_init( &ambient14, &ambient14_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( AMBIENT14_ERROR == ambient14_default_cfg ( &ambient14 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

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

Application Task

Reads the proximity, ALS, and IR raw data counts when data is ready. Calculates the illuminance level in Lux from ALS data counts and displays the results on the USB UART approximately every 500ms.

void application_task ( void )
{
    uint16_t proximity = 0;
    uint16_t als_data = 0;
    uint16_t ir_data = 0;
    float illuminance = 0;

    // Enable and wait for proximity interrupt
    ambient14_write_reg ( &ambient14, AMBIENT14_REG_INTENAB, AMBIENT14_INTENAB_PIEN );
    while ( ambient14_get_int_pin ( &ambient14 ) );

    // Read proximity data and clear interrupts
    if ( AMBIENT14_OK == ambient14_read_proximity ( &ambient14, &proximity ) )
    {
        log_printf ( &logger, " Proximity: %u\r\n", proximity );
    }
    ambient14_clear_interrupts ( &ambient14 );

    // Enable and wait for ALS interrupt
    ambient14_write_reg ( &ambient14, AMBIENT14_REG_INTENAB, AMBIENT14_INTENAB_AIEN );
    while ( ambient14_get_int_pin ( &ambient14 ) );

    // Read ALS and IR data counts, calculates illuminance level, and clear interrupts
    if ( AMBIENT14_OK == ambient14_read_als_ir ( &ambient14, &als_data, &ir_data ) )
    {
        log_printf ( &logger, " ALS: %u\r\n", als_data );
        log_printf ( &logger, " IR: %u\r\n", ir_data );
        if ( AMBIENT14_OK == ambient14_get_illuminance ( &ambient14, als_data, &illuminance ) )
        {
            log_printf ( &logger, " Illuminance: %.1f Lux\r\n\n", illuminance );
        }
    }
    ambient14_clear_interrupts ( &ambient14 );
}

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

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

Expand 18 Click

0

Expand 18 Click is a compact add-on board used for expanding the I/O capabilities of various microcontroller (MCU) systems. This board features the PCAL9714, an ultra-low-voltage 14-bit SPI I/O expander from NXP. This board supports both 3.3V and 5V logic levels, features integrated level shifting for mixed-voltage systems, and operates via a high-speed 5MHz SPI interface. Additionally, it offers Agile I/O capabilities such as programmable output drive strength, latchable inputs, and interrupt management. Expand 18 Click is ideal for interfacing MCUs with sensors, keypads, and push buttons in power-sensitive applications.

[Learn More]

Brushless 11 Click

0

Brushless 11 Click is a compact add-on board that controls brushless DC motors with any MCU. This board features the A4931, a 3-phase brushless DC motor pre-driver from Allegro Microsystems. It drives six onboard N-channel power MOSFETs and supplies the motor with 8V up to 30V voltages. This pre-driver offers enable, direction, and brake inputs that can control motor functions and logic outputs for measuring motor rotation.

[Learn More]

EEPROM 12 Click

0

EEPROM 12 Click is a compact add-on board that contains a highly reliable, nonvolatile memory solution. This board features the M24256E, an EEPROM from STMicroelectronics. It is a 256Kbit (32KB) EEPROM with a page size of 64 bytes and an additional identification page with the same size. This identification page can be read or written and (later) permanently locked in read-only mode and can be used to store sensitive application parameters.

[Learn More]