Temp-Log 6 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 : MikroE Team
- Date : Dec 2019.
- Type : I2C type
The example starts off with the initialization and configuration of the Click and logger modules, tests the communication channel and reads and displays local and remote temperature values every second.
- MikroSDK.Board
- MikroSDK.Log
- Click.TempLog6
templog6_cfg_setup
Config Object Initialization function.
void templog6_cfg_setup ( templog6_cfg_t *cfg );
templog6_init
Initialization function.
err_t templog6_init ( templog6_t *ctx, templog6_cfg_t *cfg );
templog6_default_cfg
Click Default Configuration function.
void templog6_default_cfg ( templog6_t *ctx );
templog6_write_byte
Writes one byte of data.
void templog6_write_byte ( templog6_t *ctx, uint8_t reg, uint8_t data_buf );
templog6_read_byte
Reads one byte of data.
uint8_t templog6_read_byte ( templog6_t *ctx, uint8_t reg );
templog6_get_interrupt
Gets the INT pin.
uint8_t templog6_get_interrupt ( templog6_t *ctx );
Initializes and configures the Click and logger modules and tests the communication for errors.
void application_init ( )
{
log_cfg_t log_cfg;
templog6_cfg_t cfg;
uint8_t test;
/**
* 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.
templog6_cfg_setup( &cfg );
TEMPLOG6_MAP_MIKROBUS( cfg, MIKROBUS_1 );
templog6_init( &templog6, &cfg );
// Test communication
test = templog6_read_byte( &templog6, TEMPLOG6_REG_MANUFACTURER_ID );
if ( test == TEMPLOG6_MANUFACTURER_ID )
{
log_printf( &logger, "--- Comunication OK!!! ---\r\n" );
}
else
{
log_printf( &logger, "--- Comunication ERROR!!! ---\r\n" );
for ( ; ; );
}
templog6_default_cfg( &templog6 );
log_printf( &logger, "--- Start measurement ---\r\n" );
}
Reads and displays local and remote temperature values every second.
void application_task ( void )
{
float remote_temp;
float local_temp;
local_temp = templog6_read_byte( &templog6, TEMPLOG6_REG_LOCAL_TEMPERATURE );
log_printf( &logger, "--- Local Temperature: %f C\r\n", local_temp );
remote_temp = templog6_read_byte( &templog6, TEMPLOG6_REG_REMOTE_TEMPERATURE );
log_printf( &logger, "--- Remote Temperature: %f C\r\n", remote_temp );
log_printf( &logger, "-----------------------------\r\n" );
Delay_ms ( 1000 );
}
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.