Navigate with confidence in diverse environments and conditions, as our thermal imaging technology delivers accurate, real-time temperature data, enabling you to identify issues, monitor trends, and respond swiftly
A
A
Hardware Overview
How does it work?
IR Grid 2 Click is based on the MLX90640, a 32x24 IR array sensor from Melexis. This sensor contains 8 Kbit EEPROM, used to store all the compensation and calibration parameters, along with some editable user parameters, such as the config registers, I2C address and similar. These sensors can measure temperature relative to the cold junction temperature, and for this reason, the MLX90640ESF-BAB IR sensor incorporates a PTAT (Proportional to Absolute Temperature) compensation sensor. The device also contains the power supply voltage measurement feature, allowing power supply monitoring. It is recommended that the supply voltage stay as accurate as possible, which is taken care of if used with the MikroElektronika development systems. The IR sensor array, as well as the PTAT sensor readings, are sampled by the internal Analog to Digital Converter (ADC) and stored to RAM, which can be accessed via the I2C interface. The resolution of the ADC can be programmed between 16 bits and 19bits. The MLX90640ESF-BAB IR sensor used on this Click board™ has a Field of View (FOV) of 55˚x32˚, with the IR sensing elements arranged in a 32x28 grid. Each sensor measures the temperature in its individual FOV, allowing the host MCU to build a thermal image or calculate the temperature at each spot of the viewed scene. The measurement results are stored to RAM. The entire RAM area is divided in two pages, with access patterns controlled by the configuration registers (chess pattern, or
interleaved pattern). The compensation parameters stored in the EEPROM are factory calibrated for chess pattern access, yielding the most accurate results when using this mode. The chess pattern mode is selected by default. The configuration and control registers allow to set the operational parameters of the IR grid sensor. These registers contain bits that control the behavior of the sensor IC: the refresh rate, the ADC resolution, measurement mode (continuous or step mode), sleep mode, I2C mode (FM or FM+), and more. On restart, the data from the corresponding copies of these register locations in EEPROM is mirrored to the operational register locations in RAM, preparing the device to be instantly operated. This allows changing of the default values, since they are actually stored in EEPROM, rather than being hard-coded into the device. Besides the default working parameters, the EEPROM area contains all the compensation parameters for each IR element, necessary for completing the accurate thermal calculations. Those calculations include ambient temperature calculation, pixel offset calculation, pixel to pixel sensitivity difference compensation, object emissivity compensation, and object temperature calculation. The datasheet of the MLX90640ESF-BAB IR sensor contains equations which use these parameters stored in EEPROM. However, this Click board™ is supplied with the library, which contains functions that simplify working with this sensor, saving time. Two modes of operation are available: the device can
continuously sample data from the IR elements, with the programmed refresh rate (up to 64 frames per second), or it can take one frame, by sampling the selected page. The status byte contains flags that indicate that the reading of a specific page is done. It should be noted that the sensor measures the IR emissivity of an object, so it is to be expected that some materials cannot be accurately measured by this sensor due to their low emissivity, such as the aluminum. To better understand the emissivity property of the materials, a person wearing clothes, can be taken as an example: the measured temperature will reflect the clothes temperature, rather than the body temperature itself, which is known to be about 37 ˚C Care should be taken not to expose the Click board™ to a cold or hot air flow, as it will cause false readings of the real temperature. This sensor requires the temperature across the sensor package to be constant. The MLX90640ESF-BAB IR sensor uses 3.3V for optimal results. While the power for the IR sensor itself is taken from the 3.3V mikroBUS™ rail, in order to support MCUs which use 5V compatible logic levels, the Click board™ comes equipped with PCA9306, a bi-directional I2C level translator IC, produced by Texas Instruments. This allows the logic voltage level to be selected by the SMD jumper labeled as VCC SEL. Besides I2C bus lines, no additional lines of the mikroBUS™ are used. I2C bus lines are routed to the respective pins of the mikroBUS™.
Features overview
Development board
Curiosity HPC, standing for Curiosity High Pin Count (HPC) development board, supports 28- and 40-pin 8-bit PIC MCUs specially designed by Microchip for the needs of rapid development of embedded applications. This board has two unique PDIP sockets, surrounded by dual-row expansion headers, allowing connectivity to all pins on the populated PIC MCUs. It also contains a powerful onboard PICkit™ (PKOB), eliminating the need for an external programming/debugging tool, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, a set of indicator LEDs, push button switches and a variable potentiometer. All
these features allow you to combine the strength of Microchip and Mikroe and create custom electronic solutions more efficiently than ever. Each part of the Curiosity HPC development board contains the components necessary for the most efficient operation of the same board. An integrated onboard PICkit™ (PKOB) allows low-voltage programming and in-circuit debugging for all supported devices. When used with the MPLAB® X Integrated Development Environment (IDE, version 3.0 or higher) or MPLAB® Xpress IDE, in-circuit debugging allows users to run, modify, and troubleshoot their custom software and hardware
quickly without the need for additional debugging tools. Besides, it includes a clean and regulated power supply block for the development board via the USB Micro-B connector, alongside all communication methods that mikroBUS™ itself supports. Curiosity HPC development board allows you to create a new application in just a few steps. Natively supported by Microchip software tools, it covers many aspects of prototyping thanks to many number of different Click boards™ (over a thousand boards), the number of which is growing daily.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
40
RAM (Bytes)
1536
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output
After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.
After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.
Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.
Software Support
Library Description
This library contains API for IR Grid 2 Click driver.
Key functions:
irgrid2_generic_write
- This function reads a desired number of data bytes starting from the selected register by using I2C serial interfaceirgrid2_get_frame_data
- This function is used for getting frame datairgrid2_get_pixel_temperature
- This function is used for getting pixels temperature
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 main.c
* @brief IRGrid2 Click example
*
* # Description
* The demo application displays a reading of ambient temperature and
* a 32x24 pixel object temperature matrix.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Configures the click and log objects and sets the click default configuration.
*
* ## Application Task
* Reads the temperature of all pixels every 500ms
* and displays it on USB UART in a form of a 32x24 matrix.
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "irgrid2.h"
static irgrid2_t irgrid2;
static log_t logger;
void application_init ( void ) {
log_cfg_t log_cfg; /**< Logger config object. */
irgrid2_cfg_t irgrid2_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.
irgrid2_cfg_setup( &irgrid2_cfg );
IRGRID2_MAP_MIKROBUS( irgrid2_cfg, MIKROBUS_1 );
err_t init_flag = irgrid2_init( &irgrid2, &irgrid2_cfg );
if ( I2C_MASTER_ERROR == init_flag ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
irgrid2_default_cfg ( &irgrid2 );
Delay_ms ( 1000 );
log_info( &logger, "---- Start measurement ----" );
}
void application_task ( void ) {
float px_matrix[ 768 ];
float temp_ambient;
irgrid2_get_pixel_temperature( &irgrid2, &temp_ambient, px_matrix );
log_printf( &logger, "\r\n>> Pixel temperature matrix 32x24 <<\r\n" );
for ( uint16_t cnt = 1 ; cnt < 769 ; cnt++) {
log_printf( &logger, "%.2f", px_matrix[ cnt - 1 ] );
if ( ( ( cnt % 32 ) == 0 ) ) {
log_printf( &logger, "\r\n" );
} else {
log_printf( &logger, " | " );
}
}
log_printf( &logger, "\r\n** Ambient (sensor) temperature is %.2f Celsius\r\n", temp_ambient );
Delay_ms ( 500 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
/*!
* @file main.c
* @brief IRGrid2 Click example
*
* # Description
* The demo application displays a reading of ambient temperature and
* a 32x24 pixel object temperature matrix.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Configures the click and log objects and sets the click default configuration.
*
* ## Application Task
* Reads the temperature of all pixels every 500ms
* and displays it on USB UART in a form of a 32x24 matrix.
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "irgrid2.h"
static irgrid2_t irgrid2;
static log_t logger;
void application_init ( void ) {
log_cfg_t log_cfg; /**< Logger config object. */
irgrid2_cfg_t irgrid2_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.
irgrid2_cfg_setup( &irgrid2_cfg );
IRGRID2_MAP_MIKROBUS( irgrid2_cfg, MIKROBUS_1 );
err_t init_flag = irgrid2_init( &irgrid2, &irgrid2_cfg );
if ( I2C_MASTER_ERROR == init_flag ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
irgrid2_default_cfg ( &irgrid2 );
Delay_ms ( 1000 );
log_info( &logger, "---- Start measurement ----" );
}
void application_task ( void ) {
float px_matrix[ 768 ];
float temp_ambient;
irgrid2_get_pixel_temperature( &irgrid2, &temp_ambient, px_matrix );
log_printf( &logger, "\r\n>> Pixel temperature matrix 32x24 <<\r\n" );
for ( uint16_t cnt = 1 ; cnt < 769 ; cnt++) {
log_printf( &logger, "%.2f", px_matrix[ cnt - 1 ] );
if ( ( ( cnt % 32 ) == 0 ) ) {
log_printf( &logger, "\r\n" );
} else {
log_printf( &logger, " | " );
}
}
log_printf( &logger, "\r\n** Ambient (sensor) temperature is %.2f Celsius\r\n", temp_ambient );
Delay_ms ( 500 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END