thermostat5  2.1.0.0
Main Page

Thermostat 5 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Nenad Filipovic
  • Date : Feb 2024.
  • Type : ADC/I2C type

Software Support

We provide a library for the Thermostat 5 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for Thermostat 5 Click driver.

Standard key functions :

Example key functions :

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.

void application_init ( void )
{
log_cfg_t log_cfg;
thermostat5_cfg_t thermostat5_cfg;
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 ( ; ; );
}
log_info( &logger, " Application Task " );
Delay_ms( 100 );
}

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.

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 )
{
log_printf( &logger, " Relay: ON\r\n" );
}
else
{
log_printf( &logger, " Relay: OFF\r\n" );
}
Delay_ms( 1000 );
}
}

Note

For temperature measurement, we used Semitec 103AT-2 NTC Thermistors.

  • Beta parameter: 3435 K
  • Resistance: 10 kOhms
  • Tolerance: 1 %

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Thermostat5

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


THERMOSTAT5_OK
@ THERMOSTAT5_OK
Definition: thermostat5.h:177
THERMOSTAT5_MAP_MIKROBUS
#define THERMOSTAT5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: thermostat5.h:113
THERMOSTAT5_TEMPERATURE_LIMIT
#define THERMOSTAT5_TEMPERATURE_LIMIT
Definition: main.c:35
thermostat5_read_voltage
err_t thermostat5_read_voltage(thermostat5_t *ctx, float *voltage)
Thermostat 5 read voltage level function.
application_task
void application_task(void)
Definition: main.c:73
THERMOSTAT5_RELAY_ON
#define THERMOSTAT5_RELAY_ON
Definition: thermostat5.h:80
thermostat5_init
err_t thermostat5_init(thermostat5_t *ctx, thermostat5_cfg_t *cfg)
Thermostat 5 initialization function.
THERMOSTAT5_RELAY_OFF
#define THERMOSTAT5_RELAY_OFF
Thermostat 5 relay states.
Definition: thermostat5.h:79
thermostat5_set_relay
void thermostat5_set_relay(thermostat5_t *ctx, uint8_t state)
Thermostat 5 set relay function.
thermostat5_cfg_setup
void thermostat5_cfg_setup(thermostat5_cfg_t *cfg)
Thermostat 5 configuration object setup function.
application_init
void application_init(void)
Definition: main.c:40
thermostat5_t
Thermostat 5 Click context object.
Definition: thermostat5.h:138
thermostat5_get_temperature
err_t thermostat5_get_temperature(thermostat5_t *ctx, float *temperature)
Thermostat 5 get temperature function.
thermostat5_cfg_t
Thermostat 5 Click configuration object.
Definition: thermostat5.h:155