Thermo 31 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
- Author : Stefan Filipovic
- Date : Dec 2025.
- Type : I2C type
This example demonstrates the use of the Thermo 31 Click board for temperature measurement. The application reads temperature data via the I2C interface and displays the measured value on the serial terminal.
- MikroSDK.Board
- MikroSDK.Log
- Click.Thermo31
thermo31_cfg_setupThis function initializes Click configuration structure to initial values.
void thermo31_cfg_setup ( thermo31_cfg_t *cfg );thermo31_initThis function initializes all necessary pins and peripherals used for this Click board.
err_t thermo31_init ( thermo31_t *ctx, thermo31_cfg_t *cfg );thermo31_default_cfgThis function executes a default configuration of Thermo 31 Click board.
err_t thermo31_default_cfg ( thermo31_t *ctx );thermo31_read_unique_idThis function reads the three 16-bit words of the device unique ID and stores them in the provided buffer.
err_t thermo31_read_unique_id ( thermo31_t *ctx, uint16_t *unique_id );thermo31_read_temperatureThis function reads the raw temperature result register and converts it to temperature in degrees Celsius.
err_t thermo31_read_temperature ( thermo31_t *ctx, float *temperature );Initializes the logger and Thermo 31 Click driver, applies the default configuration, and reads the device unique identifier.
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
thermo31_cfg_t thermo31_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.
thermo31_cfg_setup( &thermo31_cfg );
THERMO31_MAP_MIKROBUS( thermo31_cfg, MIKROBUS_POSITION_THERMO31 );
if ( I2C_MASTER_ERROR == thermo31_init( &thermo31, &thermo31_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( THERMO31_ERROR == thermo31_default_cfg ( &thermo31 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
uint16_t unique_id[ 3 ] = { 0 };
if ( THERMO31_OK == thermo31_read_unique_id ( &thermo31, unique_id ) )
{
log_printf ( &logger, " Device Unique ID: 0x%.2X%.2X%.2X\r\n",
unique_id[ 0 ], unique_id[ 1 ], unique_id[ 2 ] );
}
log_info( &logger, " Application Task " );
}Periodically reads the temperature value from the sensor and logs the result to the serial terminal.
void application_task ( void )
{
float temperature = 0;
if ( THERMO31_OK == thermo31_read_temperature ( &thermo31, &temperature ) )
{
log_printf ( &logger, " Temperature: %.2f degC\r\n\n", temperature );
}
Delay_ms ( 500 );
}This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
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.