Utilize ambient light intensity sensing to create energy-efficient lighting systems that adapt to the environment, reducing operational costs and environmental impact
A
A
Hardware Overview
How does it work?
Ambient 17 Click is based on the TSL2572, a high-sensitivity light-to-digital converter that transforms light intensity into a digital output signal from ams AG. The TSL2572 provides ambient light sensing (ALS) that approximates the human eye response to light intensity under various lighting conditions and through various attenuation materials. Accurate ALS measurements result from dual-diode technology and the UV rejection filter incorporated in the package. In addition, the TSL2584TSV can detect a wide range of precise lux measurements up to 60klx, even when mounted behind dark glass.
It also has stable performance over a wide temperature range, suitable for measuring the present ambient light. Ambient 17 Click communicates with MCU using the standard I2C 2-Wire interface to read data and configure settings, supporting Standard Mode operation with a clock frequency of 100kHz and Fast Mode up to 400kHz. It also possesses an additional interrupt signal, routed on the INT pin of the mikroBUS™ socket labeled as INT, indicating when a specific interrupt event occurs, such as detecting a meaningful change in light intensity. An interrupt is generated when an ALS
conversion's value exceeds an upper or lower threshold. In addition, a programmable interrupt persistence feature allows the user to determine how many consecutive exceeded thresholds are necessary to trigger an interrupt. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
Clicker 2 for Kinetis is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit ARM Cortex-M4F microcontroller, the MK64FN1M0VDC12 from NXP Semiconductors, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a JTAG programmer connector, and two 26-pin headers for interfacing with external electronics. Its compact design with clear and easily recognizable silkscreen markings allows you to build gadgets with unique functionalities and
features quickly. Each part of the Clicker 2 for Kinetis development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the Clicker 2 for Kinetis programming method, using a USB HID mikroBootloader or an external mikroProg connector for Kinetis programmer, the Clicker 2 board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Micro-B cable, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or
using a Li-Polymer battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several user-configurable buttons and LED indicators. Clicker 2 for Kinetis is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M4
MCU Memory (KB)
1024
Silicon Vendor
NXP
Pin count
121
RAM (Bytes)
262144
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for Ambient 17 Click driver.
Key functions:
ambient17_get_int_pin
- This function returns the INT pin logic stateambient17_set_atime
- This function sets the ATIME register for the selected ALS integration timeambient17_measure_light_level
- This function reads the raw ADC data from two channels and then measures the light level in lux based on those readings
Open Source
Code example
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.
/*!
* @file main.c
* @brief Ambient17 Click example
*
* # Description
* This example demonstrates the use of Ambient 17 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.
*
* ## Application Task
* Waits for the data ready interrupt, then reads the ambient light level in Lux
* and displays the results on the USB UART. By default, the data ready interrupt triggers
* upon every ADC cycle which will be performed every 200ms.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "ambient17.h"
static ambient17_t ambient17;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
ambient17_cfg_t ambient17_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.
ambient17_cfg_setup( &ambient17_cfg );
AMBIENT17_MAP_MIKROBUS( ambient17_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == ambient17_init( &ambient17, &ambient17_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( AMBIENT17_ERROR == ambient17_default_cfg ( &ambient17 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
if ( !ambient17_get_int_pin ( &ambient17 ) )
{
uint16_t lux;
if ( AMBIENT17_OK == ambient17_measure_light_level ( &ambient17, &lux ) )
{
log_printf ( &logger, " Ambient light level [Lux]: %u\r\n\n", lux );
}
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END