Seamlessly integrate light intensity measurements into digital systems, enabling automation, analytics, and enhanced decision-making capabilities
A
A
Hardware Overview
How does it work?
Illuminance Click is based on the TSL2583, a high-sensitivity light-to-digital converter from ams. The TSL2583 combines one broadband photodiode (visible plus infrared) and one infrared-responding photodiode on a single CMOS integrated circuit capable of providing a near-photopic response over an effective 16-bit dynamic range (16-bit resolution). Two integrating analog-to-digital converters (ADC) convert the photodiode currents to a digital output representing the irradiance measured on each channel. Besides general-purpose light sensing applications, the TSL2583 is explicitly designed for displays (LCD, OLED) to extend battery life and provide optimum viewing in diverse lighting conditions. The TSL2583 communicates with the MCU using the standard
I2C 2-Wire interface with a maximum frequency of 400kHz. Besides, it allows choosing the least significant bit (LSB) of its I2C slave address using the SMD jumper labeled I2C ADD. An integration of both ADC channels co-occurs. Upon completion of the conversion cycle, the conversion result is transferred to the Channel 0 and Channel 1 data registers, respectively. The transfers are double-buffered to ensure that the integrity of the data is maintained. After the transfer, the device automatically begins the next integration cycle. This sensor also supports an interrupt feature, routed to the INT pin on the mikroBUS™ socket, that simplifies and improves system efficiency by eliminating the need to poll a sensor for a light intensity value. The purpose of the interrupt
function is to detect a meaningful change in light intensity, where the user can define the concept of a significant change in light intensity and time or persistence. Users can define a threshold above and below the current light level, where an interrupt generates when the conversion value exceeds either of these limits. 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. However, the Click board™ 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
PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive
mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI
GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
48
RAM (Bytes)
8196
You complete me!
Accessories
Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output
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 Illuminance Click driver.
Key functions:
illuminance_set_atime
- This function sets the timing register for the selected integration timeilluminance_set_gain
- This function sets the gain levelilluminance_read_raw_data
- This function checks if the data is ready and then reads the raw ADC data from two channels
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* \file
* \brief Illuminance Click example
*
* # Description
* This example demonstrates basic Illuminance Click functionality.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initialize device and driver.
*
* ## Application Task
* Every second calculate illuminance measured by sensor and log
* results to UART Terminal.
*
* *note:*
* By default, integration time is set to 402ms but it may be modified
* by user using illuminance_write_data() function and provided macros.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "illuminance.h"
// ------------------------------------------------------------------ VARIABLES
static illuminance_t illuminance;
static log_t logger;
static uint16_t value_ch0;
static uint16_t value_ch1;
static uint16_t lux_value;
static uint16_t lux_value_old;
static uint8_t sensitivity;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
illuminance_cfg_t cfg;
/**
* 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.
illuminance_cfg_setup( &cfg );
ILLUMINANCE_MAP_MIKROBUS( cfg, MIKROBUS_1 );
illuminance_init( &illuminance, &cfg );
illuminance_default_cfg ( &illuminance );
// Variable Initializations for this example.
lux_value_old = 0;
sensitivity = 50;
}
void application_task ( void )
{
illuminance_get_result( &illuminance, &value_ch0, &value_ch1 );
lux_value = illuminance_calculate_lux( ILLUMINANCE_TSL2561_GAIN_0X, ILLUMINANCE_TSL2561_INTEGRATIONTIME_402MS , value_ch0, value_ch1 );
Delay_ms( 1000 );
if ( ( ( lux_value - lux_value_old ) > sensitivity ) && ( ( lux_value_old - lux_value ) > sensitivity ) )
{
log_printf( &logger, "\r\n--------------------------------" );
log_printf( &logger, "\r\nFull Spectrum: %u [ lux ]", lux_value );
log_printf( &logger, "\r\nVisible Value: %u [ lux ]", value_ch0 - value_ch1 );
log_printf( &logger, "\r\nInfrared Value: %u [ lux ]", value_ch1 );
log_printf( &logger, "\r\n--------------------------------\r\n" );
lux_value_old = lux_value;
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END