barometer8 2.2.0
Loading...
Searching...
No Matches
barometer8


Barometer 8 Click

Barometer 8 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 Filipovic
  • Date : Mar 2022.
  • Type : I2C/SPI type

Software Support

Example Description

This example demonstrates the use of Barometer 8 Click board by reading and displaying the pressure and temperature values.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Barometer8

Example Key Functions

Application Init

Initializes the driver and performs the Click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
barometer8_cfg_t barometer8_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
barometer8_cfg_setup( &barometer8_cfg );
BAROMETER8_MAP_MIKROBUS( barometer8_cfg, MIKROBUS_1 );
err_t init_flag = barometer8_init( &barometer8, &barometer8_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( BAROMETER8_ERROR == barometer8_default_cfg ( &barometer8 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ BAROMETER8_ERROR
Definition barometer8.h:301
#define BAROMETER8_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition barometer8.h:222
void application_init(void)
Definition main.c:29

Application Task

Reads and displays the pressure and temperature data on the USB UART every 250ms approximately, as per output data rate (ODR) bits configuration.

void application_task ( void )
{
float pressure, temperature;
if ( BAROMETER8_OK == barometer8_read_data ( &barometer8, &pressure, &temperature ) )
{
log_printf ( &logger, " Pressure: %.1f mBar\r\n", pressure );
log_printf ( &logger, " Temperature: %.2f C\r\n\n", temperature );
}
Delay_ms ( 5 );
}
@ BAROMETER8_OK
Definition barometer8.h:300
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.