We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2024-10-31
Package Version: 2.1.0.17
mikroSDK Library: 2.0.0.0
Category: Pressure
Downloaded: 203 times
Not followed.
License: MIT license
This application measures temperature and pressure data.
Do you want to subscribe in order to receive notifications regarding "Barometer Click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Barometer Click" changes.
Do you want to report abuse regarding "Barometer Click".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
4123_barometer_click.zip [386.79KB] | mikroC AI for ARM GCC for ARM Clang for ARM mikroC AI for PIC mikroC AI for PIC32 XC32 GCC for RISC-V Clang for RISC-V mikroC AI for AVR mikroC AI for dsPIC XC16 |
|
Barometer Click carries the LPS25HB IC, which is a piezoresistive absolute pressure sensor with a measurement range from 260 to 1260 hPa.
We provide a library for the Barometer Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.
This library contains API for Barometer Click driver.
Config Object Initialization function.
void barometer_cfg_setup ( barometer_cfg_t *cfg );
Initialization function.
BAROMETER_RETVAL barometer_init ( barometer_t ctx, barometer_cfg_t cfg );
Click Default Configuration function.
void barometer_default_cfg ( barometer_t *ctx );
Read temperature in degrees Celsius function
float barometer_get_temperature_c ( barometer_t *ctx );
Read pressure in milibars function
float barometer_get_pressure( barometer_t *ctx );
Check sensor status function
uint8_t barometer_check_status ( barometer_t *ctx );
This application measures temperature and pressure data.
The demo application is composed of two sections :
Initialization driver enable's - I2C, set default configuration and start write log.
void application_init ( void )
{
log_cfg_t log_cfg;
barometer_cfg_t cfg;
/**
* 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.
barometer_cfg_setup( &cfg );
BAROMETER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
barometer_init( &barometer, &cfg );
barometer_default_cfg( &barometer );
// Check sensor id
if ( barometer_check_id( &barometer ) != BAROMETER_DEVICE_ID )
{
log_printf( &logger, " ERROR \r\n " );
}
else
{
log_printf( &logger, " Initialization \r\n" );
}
log_printf( &logger, "-------------------------------- \r\n" );
Delay_100ms( );
}
This is a example which demonstrates the use of Barometer Click board
void application_task ( void )
{
float temperature_c;
float pressure;
temperature_c = barometer_get_temperature_c( &barometer );
Delay_100ms( );
pressure = barometer_get_pressure( &barometer );
Delay_100ms( );
log_printf( &logger, " Temperature : %.2f\r\n", temperature_c );
log_printf( &logger, " Pressure : %.2f\r\n", pressure );
log_printf( &logger, "-------------------------------- \r\n" );
Delay_1sec( );
}