Beginner
10 min

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

Temperature monitoring and control solution

Thermostat 5 Click with Curiosity Nano with PIC18F57Q43

Published Dec 19, 2024

Click board™

Thermostat 5 Click

Dev. board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

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

PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive

mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI

GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F57Q43 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

48

RAM (Bytes)

8196

You complete me!

Accessories

Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.

Curiosity Nano Base for Click boards accessories 1 image

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
PA0
AN
NC
NC
RST
ID COMM
PD4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Relay Control
PB0
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB2
SCL
I2C Data
PB1
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

Curiosity Nano Base for Click boards front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity Nano with PIC18F57Q43 as your development board.

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Curiosity Nano with PICXXX Access 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 image step 5 hardware assembly
Necto image step 6 hardware assembly
PIC18F57Q43 Curiosity 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.