altitude2  2.0.0.0
Main Page

Altitude 2 click

Altitude 2 click is a high-resolution barometric pressure sensor Click boardâ„¢. It provides very accurate measurements of temperature and atmospheric pressure, which can be used to calculate the altitude with a very high resolution of 20cm per step. Besides that, the device also includes features such as the ultra-low noise delta-sigma 24bit ADC, low power consumption, fast conversion times, pre-programmed unique compensation values, and more.

click Product page


Click library

  • Author : MikroE Team
  • Date : Dec 2019.
  • Type : I2C/SPI type

Software Support

We provide a library for the Altitude2 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 Altitude2 Click driver.

Standard key functions :

  • Config Object Initialization function.

    void altitude2_cfg_setup ( altitude2_cfg_t *cfg );

  • Initialization function.

    ALTITUDE2_RETVAL altitude2_init ( altitude2_t *ctx, altitude2_cfg_t *cfg );

  • Click Default Configuration function.

    void altitude2_default_cfg ( altitude2_t *ctx );

Example key functions :

Examples Description

This example demonstrates the use of Altitude 2 Click to measure temperature, altitude and pressure.

The demo application is composed of two sections :

Application Init

Initializes I2C driver and performs the device reset, after which the calibration coefficients be read. Determines the ratio value for temperature and pressure measurements. Calibration coefficients are necessary to read after the device reset.

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.
ALTITUDE2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
altitude2_init( &altitude2, &cfg );
Delay_ms( 500 );
altitude2_reset( &altitude2 );
log_printf( &logger, "Altitude 2 is initialized\r\n" );
Delay_ms( 200 );
}

Application Task

Gets temperature data in celsius value and pressure data in mbar value. Gets the calculated altitude value in meters which depends on the temperature and pressure measurements. Logs results on USBUART and repeats operation each second.

void application_task ( void )
{
log_printf( &logger, "Temperature: %.2f Celsius\r\n", temperature );
log_printf( &logger, "Pressure: %.2f mbar\r\n", pressure );
log_printf( &logger, "Altitude: %.2f m\r\n", altitude );
log_printf( &logger, "---------------------------------------\r\n\r\n" );
Delay_ms( 1000 );
}

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.Altitude2

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.


altitude2_reset
void altitude2_reset(altitude2_t *ctx)
Reset function.
pressure
float pressure
Definition: main.c:38
altitude2_cfg_setup
void altitude2_cfg_setup(altitude2_cfg_t *cfg)
Config Object Initialization function.
ALTITUDE2_RATIO_2048
#define ALTITUDE2_RATIO_2048
Definition: altitude2.h:99
application_task
void application_task(void)
Definition: main.c:74
ALTITUDE2_MAP_MIKROBUS
#define ALTITUDE2_MAP_MIKROBUS(cfg, mikrobus)
Definition: altitude2.h:55
altitude2_init
ALTITUDE2_RETVAL altitude2_init(altitude2_t *ctx, altitude2_cfg_t *cfg)
Initialization function.
altitude2_cfg_t
Click configuration structure definition.
Definition: altitude2.h:168
temperature
float temperature
Definition: main.c:37
altitude
float altitude
Definition: main.c:39
altitude2_read_data
void altitude2_read_data(altitude2_t *ctx, float *temp_data, float *press_data, float *altitude_data)
Data read function.
application_init
void application_init(void)
Definition: main.c:43
altitude2_set_ratio
uint8_t altitude2_set_ratio(altitude2_t *ctx, uint8_t temp_ratio, uint8_t press_ratio)
Set ratio function.