Beginner
10 min

Control external devices via J1031C3VDC.15S and PIC32MZ2048EFH100 based on temperature readings from the NTC thermistor

Temperature monitoring and control solution

Thermostat 5 Click with Flip&Click PIC32MZ

Published Dec 19, 2024

Click board™

Thermostat 5 Click

Dev. board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Monitor and control temperature with flexible analog and digital signal processing ideal for HVAC systems and industrial automation

A

A

Hardware Overview

How does it work?

Thermostat 5 Click is an add-on board designed to monitor temperature and control external devices efficiently. At its core, it features an NTC connector, enabling the integration of an NTC thermistor to measure temperature variations. The signal generated by the thermistor is first processed by the MCP6022, a rail-to-rail input/output operational amplifier from Microchip that amplifies the thermistor's signal, ensuring high precision and reliability in temperature monitoring. Depending on the selected processing mode, the amplified signal is then directed to the host MCU for further analysis. Thermostat 5 Click is an ideal choice for applications that require precise temperature monitoring and responsive control of external devices. Whether used in industrial automation, HVAC systems, or any other temperature-sensitive environments, this board offers reliable performance and versatile integration options. As

mentioned, one of the key features of Thermostat 5 Click is its dual signal processing capability, giving users the flexibility to choose between analog and digital output. This selection is made using the onboard V SEL jumper, which determines whether the signal will be processed in analog or digital form. When the jumper is set to the AN position, the amplified signal is routed to the AN pin of the mikroBUS™ socket, allowing the host MCU to process it as an analog input. On the other hand, when the jumper is set to ADC, the signal is digitized by the MCP3221 A/D converter. This 12-bit resolution converter from Microchip provides accurate digital output, which is transmitted to the host MCU via an I2C-compatible interface. The board also includes a reliable and durable relay for controlling external resistive loads based on the detected temperature. The J1031C3VDC.15S SPDT relay from CIT Relay and Switch can handle

loads of up to 2A and is highly sensitive, ensuring efficient switching with minimal power consumption. The relay's SPDT configuration allows it to switch between normally open (NO) and normally closed (NC) positions, providing flexibility in controlling connected devices. The activation of the relay is controlled via the ON pin of the mikroBUS™ socket, and its status is visually indicated by an orange LED on the board. This design ensures clear feedback and easy monitoring of the relay's operational state. 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.

Thermostat 5 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

You complete me!

Accessories

Epoxy Coated NTC Thermometer Sensor, the GA10K3A1IA from TE Connectivity, is a reliable, durable temperature sensing solution known for its high accuracy and dependable performance for precise thermal monitoring across various applications. This sensor features a tolerance β-value of ±0.5%, ensuring precise resistance-to-temperature measurements. Its lead wires, measuring 76mm (2.992 inches) in length, make it adaptable for easy integration into various systems. The sensor offers a resistance of 10kΩ at 25°C and operates efficiently across a broad temperature range, from -40°C to 125°C (-40°F to 257°F), with a maximum operating temperature of 125°C (257°F). With a β-value of 3976K (25/85), it delivers reliable performance for temperature-sensitive applications. Additionally, the sensor complies with EU RoHS and EU ELV regulations, ensuring it meets modern environmental and safety standards. Combining precision, durability, and compliance, the Epoxy Coated NTC Thermistor Sensor is ideal for use in industrial temperature monitoring, HVAC systems, automotive applications, and other environments requiring accurate and consistent thermal sensing. Its epoxy coating provides added protection, ensuring long-lasting performance even in demanding conditions.

Thermostat 5 Click accessories 1 image

Nickel-plated Brass NTC Thermistor Probe, the A1004BT22P0 thermistor from TE Connectivity, is a high-quality temperature sensor solution for various HVAC/R and surface sensing applications. This probe is known for its reliability and precision. Featuring a nickel-plated brass sensor package, it offers enhanced durability and resistance to environmental factors, making it suitable for demanding usage conditions. This thermistor probe incorporates a 22 AWG zipcord wire with an open-end electrical connection for versatile integration into various systems. The wire length of 3048mm (120 inches) ensures ample flexibility for installation in diverse setups. The probe’s resistance at 25°C is 10kΩ, with a high accuracy of ±0.2°C within a temperature range of 0°C to 70°C. It operates effectively across a broad temperature range from -40°C to 105°C (-40°F to 221°F), making it ideal for both extreme cold and high-temperature environments. The thermistor’s electrical characteristics include a β-value of 3976 K (25/85), contributing to its precise temperature-sensing capabilities. The device meets EU RoHS and EU ELV compliance standards, reflecting its environmentally friendly design and adherence to strict regulations. With its robust construction and reliable performance, this Nickel-plated Brass NTC Thermistor Probe is an excellent choice for applications requiring accurate and consistent temperature monitoring, particularly in heating, ventilation, air conditioning systems, and other surface temperature sensing tasks.

Thermostat 5 Click accessories 2 image

Used MCU Pins

mikroBUS™ mapper

Analog Output
RB11
AN
NC
NC
RST
ID COMM
RA0
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Relay Control
RC14
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RA2
SCL
I2C Data
RA3
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Thermostat 5 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
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Flip&Click PIC32MZ MB1 Access - 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

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Thermostat 5 Click driver.

Key functions:

  • thermostat5_set_relay - This function controls the relay by setting the state of the ON (PWM) pin.

  • thermostat5_get_temperature - This function reads and calculates temperature in degrees Celsius [degC] using NTC thermistors.

  • thermostat5_read_voltage - This function sets the voltage reference for Thermostat 5 click driver.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief Thermostat 5 Click Example.
 *
 * # Description
 * This library contains API for the Thermostat 5 Click driver 
 * for temperature measurement and relay control.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * The initialization of the I2C or ADC module and log UART set the relay to an OFF state.
 *
 * ## Application Task
 * The demo application measures temperature in degrees Celsius.
 * If the temperature increases above 30 degrees Celsius, 
 * the relay will turn ON, otherwise it will turn OFF.
 * Results are being sent to the UART Terminal, where you can track their changes.
 *
 * @note
 * For temperature measurement, we used Semitec 103AT-2 NTC Thermistors. 
 * - Beta parameter:  3435 K	
 * - Resistance:      10 kOhms	
 * - Tolerance:	      1 %
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "thermostat5.h"

// Demo temperature limit for relay control
#define THERMOSTAT5_TEMPERATURE_LIMIT    30.0

static thermostat5_t thermostat5;   /**< Thermostat 5 Click driver object. */
static log_t logger;    /**< Logger object. */

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    thermostat5_cfg_t thermostat5_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.
    thermostat5_cfg_setup( &thermostat5_cfg );
    THERMOSTAT5_MAP_MIKROBUS( thermostat5_cfg, MIKROBUS_1 );
    err_t init_flag = thermostat5_init( &thermostat5, &thermostat5_cfg );
    if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    thermostat5_set_relay( &thermostat5, THERMOSTAT5_RELAY_OFF );
    log_info( &logger, " Application Task " );
    Delay_ms( 100 );
}

void application_task ( void ) 
{
    float temperature = 0;
    if ( THERMOSTAT5_OK == thermostat5_get_temperature( &thermostat5, &temperature ) )
    {
        log_printf( &logger, " Temperatur : %.2f [degC]\r\n", temperature );
        if ( THERMOSTAT5_TEMPERATURE_LIMIT < temperature )
        {
            thermostat5_set_relay( &thermostat5, THERMOSTAT5_RELAY_ON );
            log_printf( &logger, " Relay: ON\r\n" );
        }
        else
        {
            thermostat5_set_relay( &thermostat5, THERMOSTAT5_RELAY_OFF );
            log_printf( &logger, " Relay: OFF\r\n" );
        }
        Delay_ms( 1000 );
    }
}

int main ( void ) 
{
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

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