inclinometer2 2.0.0.0
Main Page

Inclinometer 2 click

‍Inclinometer 2 Click is a compact add-on board that measures the orientation angle of an object with respect to the force of gravity. This board features the IIS2ICLX, high accuracy, and resolution two-axis inclinometer from STMicroelectronics. It allows selectable full-scale measurements in ranges of ±0.5/±1/±2/±3g in two axes with a configurable host interface that supports both SPI and I2C serial communication. The sensing element is manufactured using a dedicated micromachining process developed by STMicroelectronics to produce inertial sensors and actuators on silicon wafers.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Apr 2022.
  • Type : I2C/SPI type

Software Support

We provide a library for the Inclinometer 2 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 from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

‍This library contains API for Inclinometer 2 Click driver.

Standard key functions :

Example key functions :

Example Description

‍This example demonstrates the use of Inclinometer 2 click board by reading and displaying the Accel X and Y axis data (mg) and the temperature (degC) on the USB UART.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and performs the click default configuration which enables the accel data ready interrupt, sets output data rate to 12.5 Hz and accel full-scale range to +-2g.

void application_init ( void )
{
log_cfg_t log_cfg;
inclinometer2_cfg_t inclinometer2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
inclinometer2_cfg_setup( &inclinometer2_cfg );
INCLINOMETER2_MAP_MIKROBUS( inclinometer2_cfg, MIKROBUS_1 );
err_t init_flag = inclinometer2_init( &inclinometer2, &inclinometer2_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( INCLINOMETER2_ERROR == inclinometer2_default_cfg ( &inclinometer2 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define INCLINOMETER2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition inclinometer2.h:311
@ INCLINOMETER2_ERROR
Definition inclinometer2.h:426
void application_init(void)
Definition main.c:31

Application Task

‍Waits for the data ready interrupt, then reads the values of accel X and Y axis as well as the absolute temperature and displays the results on the USB UART. The data sample rate is

set to 12.5Hz by default, therefore the data is being read approximately every 80ms.

void application_task ( void )
{
// Wait for accel data ready indication
while ( !inclinometer2_get_int_pin ( &inclinometer2 ) );
float x_axis, y_axis;
if ( INCLINOMETER2_OK == inclinometer2_get_accel ( &inclinometer2, &x_axis, &y_axis ) )
{
log_printf( &logger, " X: %.2f mg\r\n", x_axis );
log_printf( &logger, " Y: %.2f mg\r\n", y_axis );
}
float temperature;
if ( INCLINOMETER2_OK == inclinometer2_get_temperature ( &inclinometer2, &temperature ) )
{
log_printf( &logger, " Temperature: %.2f C\r\n\n", temperature );
}
}
@ INCLINOMETER2_OK
Definition inclinometer2.h:425
void application_task(void)
Definition main.c:68

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Inclinometer2

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. UART terminal is available in all MikroElektronika compilers.