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
- barometer8_cfg_setup Config Object Initialization function.
void barometer8_cfg_setup(barometer8_cfg_t *cfg)
Barometer 8 configuration object setup function.
Barometer 8 Click configuration object.
Definition barometer8.h:275
- barometer8_init Initialization function.
struct barometer8_s barometer8_t
Barometer 8 Click context object.
err_t barometer8_init(barometer8_t *ctx, barometer8_cfg_t *cfg)
Barometer 8 initialization function.
- barometer8_default_cfg Click Default Configuration function.
err_t barometer8_default_cfg(barometer8_t *ctx)
Barometer 8 default configuration function.
- barometer8_write_register This function writes a desired data byte to the selected register.
err_t barometer8_write_register(barometer8_t *ctx, uint8_t reg, uint8_t data_in)
Barometer 8 write register function.
- barometer8_read_register This function reads a data byte from the selected register.
err_t barometer8_read_register(barometer8_t *ctx, uint8_t reg, uint8_t *data_out)
Barometer 8 read register function.
- barometer8_read_data This function reads the pressure and temperature raw data and converts them to mBar and Celsius.
err_t barometer8_read_data(barometer8_t *ctx, float *pressure, float *temperature)
Barometer 8 read data function.
Application Init
Initializes the driver and performs the Click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
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.
{
float 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.