Intermediate
30 min

Make your thermal monitor using STS31-DIS and PIC18F47J53

Your temperature experts!

Thermo 26 Click with PIC clicker

Published Feb 25, 2023

Click board™

Thermo 26 Click

Dev Board

PIC clicker

Compiler

NECTO Studio

MCU

PIC18F47J53

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

PIC Clicker 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 has an onboard 8-bit PIC microcontroller, the PIC18F47J53 from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances. Each part of the PIC Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the PIC Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Mini-B connection can provide up to 500mA of current, which is more than enough to operate all onboard and additional

modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. PIC Clicker 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.

PIC clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

44

RAM (Bytes)

3800

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
RB2
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
RD4
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RD0
SCL
I2C Data
RD1
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Thermo 26 Click Schematic schematic

Step by step

Project assembly

STM32 M4 clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the PIC clicker as your development board.

STM32 M4 clicker front image hardware assembly
Thermo 26 Click front image hardware assembly
Prog-cut hardware assembly
Mini B Connector clicker - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Necto_MCU_Select_PICPLC16 hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware 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.

DEBUG_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.