Beginner
10 min

Immerse yourself in advanced temperature logging with TMP1826 and PIC32MZ2048EFH100

Measure, store, and explore: The power of precision with extra memory!

Temp-Log 7 Click with Flip&Click PIC32MZ

Published Nov 11, 2023

Click board™

Temp-Log 7 Click

Dev.Board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Step into the next generation of temperature logging with our innovative solution powered by advanced EEPROM memory.

A

A

Hardware Overview

How does it work?

Temp-Log 7 Click is based on the TMP1826, a digital output temperature sensor from Texas Instruments designed for thermal management and protection applications. The TMP1826 features an integrated 2-kbit user EEPROM that allows the host to store application data in increments of 64 bits. With a user-programmable 256-bit page size write protection to avoid accidental overwrite, the EEPROM can be used as non-volatile, read-only memory. The TMP1826 also features an integrated CRC that may be used for ensuring data integrity during communication. It consists of an internal thermal BJT (NIST traceable factory-programmed non-erasable), a high-resolution analog-to-digital converter (ADC), and a data processing circuit in one package. The voltage is digitized and converted to a 16-bit temperature result in degrees Celsius, giving a digital output with outstanding accuracy of up to ±0.1°C (typical)/±0.3°C (maximum) and temperature resolution of 7.8125m°C, typical over a temperature range of –20°C to +85°C. This Click board™ communicates with MCU using the 1-Wire interface that, by definition, requires only one data line (and ground) for communication with MCU. The 1-Wire

communication line is routed to the SMD jumper labeled GP SEL, which allows routing of the 1-Wire communication either to the GP0 pin or the GP1 pin of the mikroBUS™ socket. These pins are labeled, respectively, the same as the SMD jumper positions, making the selection of the desired pin simple and straightforward. The TMP1826 can operate as a 1-Wire half-duplex bus in supply or bus-powered mode. Selection is made by positioning the SMD jumper marked VDD SEL to the appropriate position labeled VCC or GND. With the jumper set on the VCC position, the TMP1826 is powered by the same supply as this Click board™ or bus powered with the jumper set on the GND position where the device is supplied parasitically from the 1-Wire bus. Also, the TMP1826 can be configured to operate in various one-shot temperature-conversion modes, such as basic one-shot, auto, and stacked conversion modes. Each conversion mode has a single temperature sample, but the host can enable 8 sample averages in the device for improved accuracy. Depending on the user application case, the TMP1826 also provides user and application configurable address modes. These modes exist

alongside the standard device address and are useful for applications requiring faster access and device position identification. One of the ways of setting the address is through the R9 resistor, which, depending on the value of the resistor, provides the possibility of using one of 16 addresses. The TMP1826 also includes advanced features like a programmable alarm function and three digital I/O pins on an unpopulated header, configurable for general purposes or to identify the device's position on a shared bus. An alarm (interrupt) signal, routed to the ALR pin of the mikroBUS™ socket, is alarming when a specific temperature event occurs that depends on the value of the temperature reading relative to programmable limits. 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. Also, this 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.

Temp-Log 7 Click hardware overview image

Features overview

Development board

Flip&Click PIC32MZ is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,

it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication

methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows 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.

Flip&Click PIC32MZ double image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

1-Wire Data IN/OUT
RB11
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
1-Wire Data IN/OUT
RC14
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Temp-Log 7 Click Schematic schematic

Step by step

Project assembly

Flip&Click PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Flip&Click PIC32MZ as your development board.

Flip&Click PIC32MZ front image hardware assembly
Buck 22 Click front image hardware assembly
Prog-cut hardware assembly
Flip&Click PIC32MZ - 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
Flip&Click PIC32MZ MCU step 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

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

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

Application Output Step 3

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.

Application Output Step 4

Software Support

Library Description

This library contains API for Temp-Log 7 Click driver.

Key functions:

  • templog7_read_temperature - This function starts the one shot measurement and reads the temperature value in Celsius.

  • templog7_write_eeprom - This function writes a desired number of data bytes to the EEPROM memory.

  • templog7_read_eeprom - This function reads a desired number of data bytes from the EEPROM memory.

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 Temp-Log 7 Click Example.
 *
 * # Description
 * This example demonstrates the use of Temp-Log 7 click board by reading
 * the temperature in Celsius, then writing the specified data to the memory
 * and reading it back.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration which
 * clears the EEPROM memory, sets the temperature resolution to 16-bit, enables
 * alert interrupt and sets the temperature alerts to 5 degrees Celsius for low
 * and 40 degrees for high level. Other three IO pins are configured as INPUT.
 *
 * ## Application Task
 * Reads the temperature in degrees Celsius and the gpio state. After that writes
 * a desired number of bytes to the memory and then verifies if it is written
 * correctly by reading from the same memory location and displaying the memory
 * content. All data is displayed on the USB UART where you can track changes.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "templog7.h"

#define DEMO_TEXT_MESSAGE           "MikroE - Temp-Log 7 click"
#define STARTING_ADDRESS            0x00

static templog7_t templog7;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    templog7_cfg_t templog7_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.
    templog7_cfg_setup( &templog7_cfg );
    TEMPLOG7_MAP_MIKROBUS( templog7_cfg, MIKROBUS_1 );
    if ( ONE_WIRE_ERROR == templog7_init( &templog7, &templog7_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( TEMPLOG7_ERROR == templog7_default_cfg ( &templog7 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    uint8_t eeprom_data[ 64 ] = { 0 };
    uint8_t gpio_state = 0;
    float temperature = 0;
    if ( TEMPLOG7_OK == templog7_read_temperature ( &templog7, &temperature ) )
    {
        log_printf( &logger, "\r\n Temperature: %.2f C\r\n", temperature );
    }
    if ( TEMPLOG7_OK == templog7_read_gpio ( &templog7, &gpio_state ) )
    {
        log_printf( &logger, " GPIO state: 0x%.2X\r\n", ( uint16_t ) gpio_state );
    }
    if ( TEMPLOG7_OK == templog7_write_eeprom ( &templog7, STARTING_ADDRESS, DEMO_TEXT_MESSAGE, 
                                                    sizeof ( DEMO_TEXT_MESSAGE ) ) )
    {
        log_printf ( &logger, " EEPROM write: %s\r\n", ( uint8_t * ) DEMO_TEXT_MESSAGE );
    }
    if ( TEMPLOG7_OK == templog7_read_eeprom ( &templog7, STARTING_ADDRESS, eeprom_data, 
                                                   sizeof ( DEMO_TEXT_MESSAGE ) ) )
    {
        log_printf ( &logger, " EEPROM read: %s\r\n", eeprom_data );
    }
    if ( !templog7_get_alert_pin ( &templog7 ) )
    {
        log_info( &logger, " ALERT detected " );
    }
    Delay_ms ( 1000 );
}

void main ( void ) 
{
    application_init( );

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

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

Additional Support

Resources