ambient14  2.1.0.0
Main Page

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.

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 :

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;
ambient14_cfg_t ambient14_cfg;
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
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 );
}
// Enable and wait for ALS interrupt
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 );
}
}
}

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.


ambient14_write_reg
err_t ambient14_write_reg(ambient14_t *ctx, uint8_t reg, uint8_t data_in)
Ambient 14 write reg function.
ambient14_default_cfg
err_t ambient14_default_cfg(ambient14_t *ctx)
Ambient 14 default configuration function.
AMBIENT14_OK
@ AMBIENT14_OK
Definition: ambient14.h:375
ambient14_get_int_pin
uint8_t ambient14_get_int_pin(ambient14_t *ctx)
Ambient 14 get int pin function.
ambient14_get_illuminance
err_t ambient14_get_illuminance(ambient14_t *ctx, uint16_t als_data, float *illuminance)
Ambient 14 get illuminance function.
AMBIENT14_ERROR
@ AMBIENT14_ERROR
Definition: ambient14.h:376
ambient14_read_proximity
err_t ambient14_read_proximity(ambient14_t *ctx, uint16_t *prox_data)
Ambient 14 read proximity function.
ambient14_cfg_t
Ambient 14 Click configuration object.
Definition: ambient14.h:357
application_task
void application_task(void)
Definition: main.c:66
ambient14_t
Ambient 14 Click context object.
Definition: ambient14.h:337
AMBIENT14_INTENAB_AIEN
#define AMBIENT14_INTENAB_AIEN
Definition: ambient14.h:227
AMBIENT14_REG_INTENAB
#define AMBIENT14_REG_INTENAB
Definition: ambient14.h:112
ambient14_init
err_t ambient14_init(ambient14_t *ctx, ambient14_cfg_t *cfg)
Ambient 14 initialization function.
ambient14_clear_interrupts
err_t ambient14_clear_interrupts(ambient14_t *ctx)
Ambient 14 clear interrupts function.
AMBIENT14_MAP_MIKROBUS
#define AMBIENT14_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: ambient14.h:323
application_init
void application_init(void)
Definition: main.c:30
AMBIENT14_INTENAB_PIEN
#define AMBIENT14_INTENAB_PIEN
Definition: ambient14.h:226
ambient14_read_als_ir
err_t ambient14_read_als_ir(ambient14_t *ctx, uint16_t *als_data, uint16_t *ir_data)
Ambient 14 read als ir function.
ambient14_cfg_setup
void ambient14_cfg_setup(ambient14_cfg_t *cfg)
Ambient 14 configuration object setup function.