barometer  2.0.0.0
Main Page

Barometer click

Barometer click carries the LPS25HB IC, which is a piezoresistive absolute pressure sensor with a measurement range from 260 to 1260 hPa.

click Product page


Click library

  • Author : MikroE Team
  • Date : Jan 2020.
  • Type : I2C/SPI type

Software Support

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.

Library Description

This library contains API for Barometer Click driver.

Standard key functions :

  • 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 );

Example key functions :

  • 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 );

Examples Description

This application measures temperature and pressure data.

The demo application is composed of two sections :

Application Init

Initialization driver enable's - I2C, set default configuration and start write log.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
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( );
}

Application Task

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( );
}

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Barometer

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


barometer_get_temperature_c
float barometer_get_temperature_c(barometer_t *ctx)
Read temperature in degrees Celsius function.
barometer_cfg_setup
void barometer_cfg_setup(barometer_cfg_t *cfg)
Config Object Initialization function.
application_task
void application_task(void)
Definition: main.c:75
BAROMETER_DEVICE_ID
#define BAROMETER_DEVICE_ID
Definition: barometer.h:149
barometer_cfg_t
Click configuration structure definition.
Definition: barometer.h:209
barometer_init
BAROMETER_RETVAL barometer_init(barometer_t *ctx, barometer_cfg_t *cfg)
Initialization function.
BAROMETER_MAP_MIKROBUS
#define BAROMETER_MAP_MIKROBUS(cfg, mikrobus)
Definition: barometer.h:68
barometer_get_pressure
float barometer_get_pressure(barometer_t *ctx)
Read pressure in milibars function.
application_init
void application_init(void)
Definition: main.c:35
barometer_check_id
uint8_t barometer_check_id(barometer_t *ctx)
Check sensor id - Who Am I function.
barometer_default_cfg
void barometer_default_cfg(barometer_t *ctx)
Click Default Configuration function.