TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (392 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (123 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (140541 times)
  2. FAT32 Library (73026 times)
  3. Network Ethernet Library (58041 times)
  4. USB Device Library (48214 times)
  5. Network WiFi Library (43826 times)
  6. FT800 Library (43295 times)
  7. GSM click (30359 times)
  8. mikroSDK (28987 times)
  9. PID Library (27116 times)
  10. microSD click (26721 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

Inclinometer 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.10

mikroSDK Library: 2.0.0.0

Category: Motion

Downloaded: 167 times

Not followed.

License: MIT license  

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.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Inclinometer 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Inclinometer 2 Click" changes.

Do you want to report abuse regarding "Inclinometer 2 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


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.

inclinometer2_click.png

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 :

  • inclinometer2_cfg_setup Config Object Initialization function.

    void inclinometer2_cfg_setup ( inclinometer2_cfg_t *cfg );
  • inclinometer2_init Initialization function.

    err_t inclinometer2_init ( inclinometer2_t *ctx, inclinometer2_cfg_t *cfg );
  • inclinometer2_default_cfg Click Default Configuration function.

    err_t inclinometer2_default_cfg ( inclinometer2_t *ctx );

Example key functions :

  • inclinometer2_get_int_pin This function returns the INT pin logic state.

    uint8_t inclinometer2_get_int_pin ( inclinometer2_t *ctx );
  • inclinometer2_get_accel This function checks if the accel data is ready and than reads the accel X and Y axis in mg.

    err_t inclinometer2_get_accel ( inclinometer2_t *ctx, float *x_axis, float *y_axis );
  • inclinometer2_get_temperature This function checks if the temperature data is ready and than reads the temperature in Celsius.

    err_t inclinometer2_get_temperature ( inclinometer2_t *ctx, float *temperature );

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;  /**< Logger config object. */
    inclinometer2_cfg_t inclinometer2_cfg;  /**< Click config object. */

    /** 
     * 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.
    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 " );
}

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

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.


ALSO FROM THIS AUTHOR

UNI Hall click

5

The unipolar Hall effect sensor on UNI HALL click™ is sensitive to north pole magnetic fields—when exposed to such a field, it outputs a LOW logic level. Othewise the output is a HIGH logic level. In its simplest application, UNI HALL click™ can be employed as part of a long lasting contactless proximity switch.

[Learn More]

SPIRIT click

6

SPIRIT click carries the SP1ML 868MHz ultra low-power RF module. The click is designed to run on a 3.3V or 5V power supply. It communicates with the target MCU over UART interface, with additional functionality provided by the following pins on the mikroBUS line: PWM, RST, CS.

[Learn More]

BLE 7 Click

0

The BLE 7 Click is a Click board™ witch provide BT/BLE connectivity for any embedded application. BLE 7 Click based on the BGX13S22GA-V31, a SiP module from Silicon Labs with a buit-in antenna. Click board™ an ultra-small, high-performing, Bluetooth low energy module for easy integration of Bluetooth low energy connectivity (BLE) into various electronic devices. Given its features, this Click can be used for health, sports, and wellness devices as well as Industrial, home, and building automation; and smart phone, tablet, and PC accessories.

[Learn More]