tempalarm 2.2.0
Loading...
Searching...
No Matches
tempalarm


Temp Alarm Click

Temp Alarm 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.


Click Library

  • Author : Stefan Ilic
  • Date : Aug 2023.
  • Type : I2C type

Software Support

Example Description

This example demonstrates the use of Temp Alarm Click board by reading and displaying the temperature measurements and monitoring it.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.TempAlarm

Example Key Functions

  • tempalarm_cfg_setup Config Object Initialization function.
    void tempalarm_cfg_setup(tempalarm_cfg_t *cfg)
    Temp Alarm configuration object setup function.
    Temp Alarm Click configuration object.
    Definition tempalarm.h:251
  • tempalarm_init Initialization function.
    err_t tempalarm_init(tempalarm_t *ctx, tempalarm_cfg_t *cfg)
    Temp Alarm initialization function.
    Temp Alarm Click context object.
    Definition tempalarm.h:233
  • tempalarm_default_cfg Click Default Configuration function.
    err_t tempalarm_default_cfg(tempalarm_t *ctx)
    Temp Alarm default configuration function.
  • tempalarm_write_reg Temp Alarm register writing function.
    err_t tempalarm_write_reg ( tempalarm_t *ctx, uint8_t reg, uint8_t data_in );
    err_t tempalarm_write_reg(tempalarm_t *ctx, uint8_t reg, uint8_t data_in)
    Temp Alarm register writing function.
  • tempalarm_read_remote_temperature Temp Alarm remote sensor read temperature function.
    err_t tempalarm_read_remote_temperature ( tempalarm_t *ctx, float *temperature );
  • tempalarm_set_alarm_high_limit Temp Alarm remote sensor set limit high temperature function.
    err_t tempalarm_set_alarm_high_limit ( tempalarm_t *ctx, float max_temperature );
    err_t tempalarm_set_alarm_high_limit(tempalarm_t *ctx, float max_temperature)
    Temp Alarm remote sensor set limit high temperature function.

Application Init

Initializes the driver and sets the Local sensor critical temperature at 30 degC with hysteresis of 1 degC, and Remote sensor alarm temperature at 30 degC.

void application_init ( void )
{
log_cfg_t log_cfg;
tempalarm_cfg_t tempalarm_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
tempalarm_cfg_setup( &tempalarm_cfg );
TEMPALARM_MAP_MIKROBUS( tempalarm_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == tempalarm_init( &tempalarm, &tempalarm_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( TEMPALARM_ERROR == tempalarm_default_cfg ( &tempalarm ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define TEMPALARM_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition tempalarm.h:219
void application_init(void)
Definition main.c:30
@ TEMPALARM_ERROR
Definition tempalarm.h:270

Application Task

Reads the temperature measurement in degrees Celsius and displays the results on the USB UART approximately once per second. Monitoring alarm and critical state.

void application_task ( void )
{
uint8_t flag_data = 0;
int8_t local_temp = 0;
float remote_temp = 0;
tempalarm_get_alarms( &tempalarm, &flag_data );
{
tempalarm_read_temperature( &tempalarm, &local_temp );
tempalarm_read_remote_temp( &tempalarm, &remote_temp );
log_printf( &logger, " Local temperature : %d degC \r\n" , ( int16_t ) local_temp );
log_printf( &logger, " Remote temperature : %.3f degC \r\n" , remote_temp );
log_printf( &logger, " -------------------------------- \r\n" );
}
{
log_printf( &logger, " Alarm is on, remote temperature \r\n" );
log_printf( &logger, " is higher then 30 degC \r\n" );
log_printf( &logger, " -------------------------------- \r\n" );
}
{
log_printf( &logger, " Alarm is on, local temperature \r\n" );
log_printf( &logger, " is higher then 30 degC \r\n" );
log_printf( &logger, " -------------------------------- \r\n" );
}
Delay_ms ( 1000 );
}
#define TEMPALARM_PIN_STATE_LOW
Definition tempalarm.h:181
#define TEMPALARM_ADC_BUSY_MASK
Temp Alarm flags setting.
Definition tempalarm.h:130
err_t tempalarm_read_remote_temp(tempalarm_t *ctx, float *temperature)
Temp Alarm remote sensor read temperature function.
err_t tempalarm_read_temperature(tempalarm_t *ctx, int8_t *temperature)
Temp Alarm local sensor read temperature function.
uint8_t tempalarm_get_tcr_pin(tempalarm_t *ctx)
Temp Alarm get critical temperature alert pin state function.
err_t tempalarm_get_alarms(tempalarm_t *ctx, uint8_t *alarms)
Temp Alarm read alarms state function.
uint8_t tempalarm_get_alr_pin(tempalarm_t *ctx)
Temp Alarm get alarm pin state function.
void application_task(void)
Definition main.c:66

Application Output

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.

Additional Notes and Information

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.