Ambient 14 Click
Ambient 14 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Jun 2024.
- Type : I2C type
Software Support
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.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Ambient14
Example Key Functions
- ambient14_cfg_setup Config Object Initialization function.
void ambient14_cfg_setup(ambient14_cfg_t *cfg)
Ambient 14 configuration object setup function.
Ambient 14 Click configuration object.
Definition ambient14.h:357
- ambient14_init Initialization function.
err_t ambient14_init(ambient14_t *ctx, ambient14_cfg_t *cfg)
Ambient 14 initialization function.
Ambient 14 Click context object.
Definition ambient14.h:337
- ambient14_default_cfg Click Default Configuration function.
err_t ambient14_default_cfg(ambient14_t *ctx)
Ambient 14 default configuration function.
- 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)
Ambient 14 read proximity function.
- 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)
Ambient 14 read als ir function.
- 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)
Ambient 14 get illuminance function.
Application Init
Initializes the driver and performs the Click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
ambient14_init( &ambient14, &ambient14_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ AMBIENT14_ERROR
Definition ambient14.h:376
#define AMBIENT14_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition ambient14.h:323
void application_init(void)
Definition main.c:30
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.
{
uint16_t proximity = 0;
uint16_t als_data = 0;
uint16_t ir_data = 0;
float illuminance = 0;
{
log_printf ( &logger, " Proximity: %u\r\n", proximity );
}
{
log_printf ( &logger, " ALS: %u\r\n", als_data );
log_printf ( &logger, " IR: %u\r\n", ir_data );
{
log_printf ( &logger, " Illuminance: %.1f Lux\r\n\n", illuminance );
}
}
}
@ AMBIENT14_OK
Definition ambient14.h:375
#define AMBIENT14_REG_INTENAB
Definition ambient14.h:112
#define AMBIENT14_INTENAB_AIEN
Definition ambient14.h:227
#define AMBIENT14_INTENAB_PIEN
Definition ambient14.h:226
err_t ambient14_write_reg(ambient14_t *ctx, uint8_t reg, uint8_t data_in)
Ambient 14 write reg function.
err_t ambient14_clear_interrupts(ambient14_t *ctx)
Ambient 14 clear interrupts function.
uint8_t ambient14_get_int_pin(ambient14_t *ctx)
Ambient 14 get int pin function.
void application_task(void)
Definition main.c:66
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.