thermo18  2.0.0.0
Main Page

Thermo 18 click

Thermo 18 Click is a compact add-on board that provides an accurate temperature measurement. This board features the WSEN-TIDS, a silicon-based, high-precision digital temperature sensor with embedded analog and digital signal processing unit from Würth Elektronik.

click Product page


Click library

  • Author : Luka FIlipovic
  • Date : Aug 2021.
  • Type : I2C type

Software Support

We provide a library for the Thermo18 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 Thermo18 Click driver.

Standard key functions :

Example key functions :

Example Description

The example application showcases ability of device

to read temperature and detect and assert interrupt on undertemperature or overtemperature thresholds.

The demo application is composed of two sections :

Application Init

Initialization of communication modules and interrupt pin.

Reads device ID to check comunication. Then resets device, and sets undertemperature and overtemperature thresholds on 24 and 30 degrees Celsius. In the end enables OneShot temperature conversion.

void application_init ( void )
{
log_cfg_t log_cfg;
thermo18_cfg_t thermo18_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
thermo18_cfg_setup( &thermo18_cfg );
THERMO18_MAP_MIKROBUS( thermo18_cfg, MIKROBUS_1 );
err_t init_flag = thermo18_init( &thermo18, &thermo18_cfg );
if ( I2C_MASTER_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
uint8_t temp_data = 0;
thermo18_generic_read( &thermo18, THERMO18_REG_DEVICE_ID, &temp_data );
log_printf( &logger, " > ID: 0x%.2X\r\n", ( uint16_t )temp_data );
if ( THERMO18_DEVICE_ID != temp_data )
{
log_error( &logger, " Device ID. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
if ( thermo18_default_cfg ( &thermo18 ) )
{
log_error( &logger, " Default configuration. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
Delay_ms( 2000 );
//One shot reading
log_info( &logger, " Application Task " );
}

Application Task

Checks status to see if the temperature conversion is finished.

When it's finished reads and logs calculated temperature data. Then checks if status is asserted for threshold detection, and logs if detected. In the end re-enables OneShot conversion.

void application_task ( void )
{
uint8_t status;
//Check if data is ready
{
//Temperature reading
float temp = 0.0;
thermo18_read_temperature( &thermo18, &temp );
log_printf( &logger, " > Temperature[degC]: %.2f\r\n", temp );
//Check threshold
if ( 0 != status )
{
{
log_info( &logger, " Overtemperature Threshold detected." );
}
else if ( THERMO18_STATUS_UNDERTEMPERATURE == status )
{
log_info( &logger, " Undertemperature Threshold detected." );
}
}
//Re-Enable One shot reading
}
Delay_ms( 300 );
}

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

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.


THERMO18_STATUS_DATA_READY
#define THERMO18_STATUS_DATA_READY
Thermo 18 description status values.
Definition: thermo18.h:101
THERMO18_STATUS_OVERTEMPERATURE
#define THERMO18_STATUS_OVERTEMPERATURE
Definition: thermo18.h:103
THERMO18_STATUS_DATA_BUSY
#define THERMO18_STATUS_DATA_BUSY
Definition: thermo18.h:102
thermo18_generic_write
err_t thermo18_generic_write(thermo18_t *ctx, uint8_t reg, uint8_t tx_data)
Thermo 18 I2C writing function.
THERMO18_CONTROL_ONESHOT_ENABLED
#define THERMO18_CONTROL_ONESHOT_ENABLED
Thermo 18 control settings.
Definition: thermo18.h:94
thermo18_default_cfg
err_t thermo18_default_cfg(thermo18_t *ctx)
Thermo 18 default configuration function.
thermo18_read_temperature
err_t thermo18_read_temperature(thermo18_t *ctx, float *temperature)
Reads and calculates temperature value.
thermo18_t
Thermo 18 Click context object.
Definition: thermo18.h:148
application_task
void application_task(void)
Definition: main.c:90
THERMO18_REG_DEVICE_ID
#define THERMO18_REG_DEVICE_ID
Thermo 18 description register.
Definition: thermo18.h:69
thermo18_cfg_setup
void thermo18_cfg_setup(thermo18_cfg_t *cfg)
Thermo 18 configuration object setup function.
thermo18_cfg_t
Thermo 18 Click configuration object.
Definition: thermo18.h:165
THERMO18_DEVICE_ID
#define THERMO18_DEVICE_ID
Thermo 18 description setting.
Definition: thermo18.h:110
THERMO18_STATUS_UNDERTEMPERATURE
#define THERMO18_STATUS_UNDERTEMPERATURE
Definition: thermo18.h:104
THERMO18_MAP_MIKROBUS
#define THERMO18_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: thermo18.h:135
application_init
void application_init(void)
Definition: main.c:36
thermo18_generic_read
err_t thermo18_generic_read(thermo18_t *ctx, uint8_t reg, uint8_t *rx_data)
Thermo 18 I2C reading function.
THERMO18_REG_CTRL
#define THERMO18_REG_CTRL
Definition: thermo18.h:72
thermo18_reset
err_t thermo18_reset(thermo18_t *ctx)
Resets device.
thermo18_set_temperature_threshold
err_t thermo18_set_temperature_threshold(thermo18_t *ctx, uint8_t threshold_reg, float threshold_limit)
Sets temperature threshold.
THERMO18_REG_STATUS
#define THERMO18_REG_STATUS
Definition: thermo18.h:73
thermo18_init
err_t thermo18_init(thermo18_t *ctx, thermo18_cfg_t *cfg)
Thermo 18 initialization function.