Intermediate
30 min

Make your thermal monitor using STS31-DIS and PIC18F87J60

Your temperature experts!

Thermo 26 Click with EasyPIC PRO v7a

Published Feb 20, 2023

Click board™

Thermo 26 Click

Dev Board

EasyPIC PRO v7a

Compiler

NECTO Studio

MCU

PIC18F87J60

Undoubtedly the best choice for highly accurate temperature measurements

A

A

Hardware Overview

How does it work?

Thermo 26 Click is based on the STS31-DIS, a digital temperature sensor from Sensirion with increased intelligence, reliability, NIST traceability, and improved accuracy specifications utilizing the industry-proven CMOSens® Technology. It integrates a digital temperature sensor with a 16-bit analog-to-digital converter (ADC), a data processing circuit, and serial interface logic functions in one package. The voltage is digitized and converted to a 16-bit temperature result in degrees Celsius, with a resolution of 0.01°C. The STS31-DIS temperature sensor gives a fully calibrated, linearized, and supply-voltage-

compensated digital output with outstanding accuracy of up to ±0.2°C typical over a temperature range of 0°C to 90°C. Thermo 26 Click communicates with an MCU using the standard I2C 2-Wire interface to read data and configure settings, supporting Fast Mode Plus up to 1MHz. Also, the STS31-DIS allows choosing the least significant bit (LSB) of its I2C slave address using the SMD jumper labeled ADDR SEL. It also possesses an additional interrupt alert signal, routed on the INT pin of the mikroBUS™ socket labeled as ALT. The ALT pin indicates when a specific

interrupt event occurs, depending on the temperature reading value relative to programmable limits. The general reset function is routed on the RST pin of the mikroBUS™ socket. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. However, the Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development.

Thermo 26 Click top side image
Thermo 26 Click lateral side image
Thermo 26 Click bottom side image

Features overview

Development board

EasyPIC PRO v7a is the seventh generation of PIC development boards specially designed to develop embedded applications rapidly. It supports a wide range of 8-bit PIC microcontrollers from Microchip and a broad set of unique functions, such as the first-ever embedded debugger/programmer over USB-C. 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. With two different connectors for each port, EasyPIC PRO v7a allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of the EasyPIC PRO

v7a 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 block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-23V AC or 9-32V DC via DC connector/screw terminals, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART,

RS-232, and Ethernet are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and a standard TQFP socket for the seventh-generation MCU cards. This socket covers a wide range of 8-bit PIC MCUs, from PIC18LF, PIC16LF, PIC16F, and PIC18F families. EasyPIC PRO v7a 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 PRO v7a double side image

Microcontroller Overview

MCU Card / MCU

default

Type

7th Generation

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

80

RAM (Bytes)

3808

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
RC0
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
Alert Interrupt
RB0
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

Thermo 26 Click Schematic schematic

Step by step

Project assembly

EasyPIC PRO v7a front image hardware assembly

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

EasyPIC PRO v7a front image hardware assembly
Buck 22 Click front image hardware assembly
EasyPIC PRO v7 MCUcard with PIC18F87J50 front image hardware assembly
v7 TQFP 3SOC 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
EasyPIC PRO v7a MCU Selection Necto Step hardware assembly
EasyPIC PRO v7a Display Selection Necto Step 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 via UART Mode

1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.

2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.

3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.

4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART_Application_Output

Software Support

Library Description

This library contains API for Thermo 26 Click driver.

Key functions:

  • thermo26_read_serial_num This function reads the 32-bit unique serial number.

  • thermo26_start_measurement This function starts the measurements by sending the specified command.

  • thermo26_read_temperature This function reads the temperature raw data measurements and converts them to degrees Celsius.

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 Thermo 26 Click example
 *
 * # Description
 * This example demonstrates the use of Thermo 26 click board by reading and displaying
 * the temperature measurements.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and resets the device, and after that reads the serial number and
 * starts the periodic measurements at 2 mps with high repeatability.
 *
 * ## Application Task
 * Reads the temperature measurement in degrees Celsius and displays the results on the USB UART
 * approximately once per second.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "thermo26.h"

static thermo26_t thermo26;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    thermo26_cfg_t thermo26_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.
    thermo26_cfg_setup( &thermo26_cfg );
    THERMO26_MAP_MIKROBUS( thermo26_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == thermo26_init( &thermo26, &thermo26_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    thermo26_reset_device ( &thermo26 );
    
    uint32_t serial_num;
    if ( THERMO26_ERROR == thermo26_read_serial_num ( &thermo26, &serial_num ) )
    {
        log_error( &logger, " Read serial number." );
        for ( ; ; );
    }
    log_printf ( &logger, " Serial number: 0x%.8LX\r\n", serial_num );
    
    if ( THERMO26_ERROR == thermo26_start_measurement ( &thermo26, THERMO26_CMD_PERIODIC_2_MPS_REP_HIGH ) )
    {
        log_error( &logger, " Start measurement." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    float temperature;
    if ( THERMO26_OK == thermo26_read_temperature ( &thermo26, &temperature ) )
    {
        log_printf ( &logger, " Temperature: %.2f\r\n\n", temperature );
    }
    Delay_ms ( 1000 );
}

void main ( void ) 
{
    application_init( );

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

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

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.