Beginner
10 min

Discover the future of temperature measurement with MLX90632 and PIC18LF46K40

Touchless temperature insights

IrThermo 3 Click with EasyPIC v8

Published Nov 07, 2023

Click board™

IrThermo 3 Click

Dev Board

EasyPIC v8

Compiler

NECTO Studio

MCU

PIC18LF46K40

Ensure safety and accuracy in temperature monitoring with our contactless infrared solution, offering a reliable and efficient way to measure object temperatures.

A

A

Hardware Overview

How does it work?

IrThermo 3 Click is based on the MLX90632, a FIR sensor from Melexis as the contactless temperature sensor. This sensor is a thermopile IR sensor. A thermopile sensor is actually a serially connected thermocouple array, with hot junctions located on the heat absorbing membrane. The cold junctions are located on a cold base, providing the reference point for generating the voltage. Due to the low-temperature capacity of the membrane, it will react to the heat radiation, generating voltage via the thermoelectric effect. The ASSP circuitry of the MLX90632 sensor filters and amplifies the sensor signal, preventing interferences from external sources, such as localized thermal variations (air turbulence, or thermal differences across the sensor itself) to affect the measurement, yielding the highest accuracy of up to ±1℃. However, excessive disturbances and variations will affect the accuracy. The device is driven by a state machine, which controls the operation of several internal sections: thermal sensors, programmable gain amplifier, ADC converter, digital filtering, memory, and communication sections. The MLX90632 FIR sensor is factory calibrated in wide temperature range: -20°C to 80°C for ambient (sensor) temperature and --20°C to 200°C for the object temperature. An integrated thermal sensor allows

ambient temperature measurement independently of the thermopile itself, allowing accurate calibration calculations to be performed. EEPROM area with 256 locations of 16-bit words contains the calibration constants and trimming values. Along with the measurement from the integrated ambient temperature sensor (which measures the temperature of the sensor itself), the EEPROM information is used in the calculations. Formulas for the calculations can be found in the MLX90632 datasheet, and the host MCU should contain a firmware which processes the raw data from the sensor, by applying the calculations. The measurement data is stored in RAM locations, which is 96 16-bit words long. The rest of the RAM can be used for storing temporary results or some other auxiliary data. The STATUS register offers information about the status: the device is busy, EEPROM busy, data is ready and so on. The CONTROL register sets operating modes and initiates measurement while in a SLEEP mode. The last register controls the I2C slave address LSB and these three registers are located in the REGISTERS memory area. The entire memory map with the detailed information about all the EEPROM and register locations is provided in the MLX90632 datasheet. There are three modes of operation and depending on the working

conditions, the appropriate mode can be selected in the CONTROL register: SLEEP mode - or SLEEPING STEP mode uses the least power of all modes. The device turns off unneeded sections until a command is received via the CONTROL register (SOC bit). Upon receiving the command, device powers on, performs a measurement and reverts back to the SLEEP mode. STEP mode uses more power as the device remains powered. The actual measurement is paused until a command is received (SOC bit of the CONTROL register). Upon receiving the command, the device performs a measurement and waits for the next command. CONTINUOUS mode performs measurements continuously. This mode consumes the most power, but the new data is constantly gathered, providing most accurate measurement with no lag. The device can be configured to have high refresh rates (down to 16ms). The default refresh rate is 0.5s. There are two SMD jumpers on this Click board™. One jumper is used to set the LSB of the I2C address of the device and it is labeled as the ADDR. The other SMD jumper is labeled as the VCC SEL and it is used to provide reference voltage for the PCA9306, a bi-directional I2C level shifter so that the Click board™ can be interfaced with both 3.3V and 5V MCUs.

IrThermo 3 Click hardware overview image

Features overview

Development board

EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the EasyPIC v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

EasyPIC v8 horizontal image

Microcontroller Overview

MCU Card / MCU

PIC18LF46K40

Architecture

PIC

MCU Memory (KB)

64

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

3728

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RC3
SCL
I2C Data
RC4
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

IrThermo 3 Click Schematic schematic

Step by step

Project assembly

EasyPIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyPIC v8 as your development board.

EasyPIC v8 front image hardware assembly
Buck 22 Click front image hardware assembly
MCU DIP 40 hardware assembly
EasyPIC v8 DIP MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for IrThermo 3 Click driver.

Key functions:

  • irthermo3_cal - Calibration function

  • irthermo3_get_ambient_temp - Read Ambient Temperature function

  • irthermo3_get_object_temp - Read Object Temperature function

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 IrThermo3 Click example
 * 
 * # Description
 * The demo application displays ambient and object temperature measurementss
 * using IrThermo 3 click.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes Driver ,resets the devic and performs calibration.
 *
 * ## Application Task
 * The device measures ambient and object temperatures and displays data in
 * degree centigrade every second.
 * 
 * \author Jovan Stajkovic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "irthermo3.h"

// ------------------------------------------------------------------ VARIABLES

static irthermo3_t irthermo3;
static log_t logger;

static float amb_temp;
static float obj_temp;
uint8_t adr_rst[ 4 ] = { 0x30, 0x05, 0x00, 0x06 };
uint8_t eeprom_unlock[ 4 ] = { 0x30, 0x05, 0x55, 0x4C };

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    irthermo3_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.

    irthermo3_cfg_setup( &cfg );
    IRTHERMO3_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    irthermo3_init( &irthermo3, &cfg );

    irthermo3_global_write ( &irthermo3, adr_rst, 4 );
    irthermo3_cal ( &irthermo3 );
    Delay_ms( 500 );
}

void application_task ( void )
{
    amb_temp = irthermo3_get_ambient_temperature( &irthermo3 );
    log_printf( &logger, "Ambient temperature: %.2f °C \r\n", amb_temp );

    obj_temp = irthermo3_get_object_temperature( &irthermo3 );
    log_printf( &logger, "Object temperature: %.2f °C \r\n", obj_temp );

    log_printf( &logger, "----------------------------\r\n" );
    Delay_ms( 1000 );
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}


// ------------------------------------------------------------------------ END

Additional Support

Resources