accel31  2.1.0.0
Main Page

Accel 31 Click

Accel 31 Click is a compact add-on board designed for precise motion and orientation detection in space-constrained devices. This board features the BMA580, a triaxial low-g accelerometer from Bosch Sensortec, which offers a 16-bit digital resolution with measurement ranges of ±2, ±4, ±8, and ±16 g, along with flexible output data rates from 1.56Hz to 6.4kHz, enabling high adaptability and accuracy. The BMA580 supports advanced power modes, including high-performance and low-power, self-wake-up functionality, and bone conduction-based voice activity detection.

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Sep 2024.
  • Type : I2C/SPI type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of Accel 31 Click board by reading and displaying

the accelerometer data (X, Y, and Z axis) and a temperature measurement in degrees Celsius.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
accel31_cfg_t accel31_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
accel31_cfg_setup( &accel31_cfg );
ACCEL31_MAP_MIKROBUS( accel31_cfg, MIKROBUS_1 );
err_t init_flag = accel31_init( &accel31, &accel31_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ACCEL31_ERROR == accel31_default_cfg ( &accel31 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Checks for a new data ready indication and then reads the accelerometer and temperature

measurements. The results are displayed on the USB UART at 12.5 Hz output data rate.

void application_task ( void )
{
accel31_data_t meas_data;
if ( ACCEL31_OK == accel31_get_data ( &accel31, &meas_data ) )
{
log_printf( &logger, " Accel X: %.3f g\r\n", meas_data.accel.x );
log_printf( &logger, " Accel Y: %.3f g\r\n", meas_data.accel.y );
log_printf( &logger, " Accel Z: %.3f g\r\n", meas_data.accel.z );
log_printf( &logger, " Temperature: %d degC\r\n\n", ( int16_t ) meas_data.temperature );
Delay_ms ( 80 );
}
}

Note

The Click board determines the communication protocol at the first communication check

after power-up. In the case of I2C, the IC responds with NACK on the first check, which blocks the I2C bus on some MCUs. Re-running the program (without power cycling the Click board power supply) should unlock the communication and solve this issue.

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

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.


accel31_set_accel_odr
err_t accel31_set_accel_odr(accel31_t *ctx, uint8_t odr)
Accel 31 set accel odr function.
accel31_data_t::accel
accel31_axes_t accel
Definition: accel31.h:402
accel31_get_data
err_t accel31_get_data(accel31_t *ctx, accel31_data_t *data_out)
Accel 31 get data function.
accel31_axes_t::y
float y
Definition: accel31.h:391
accel31_default_cfg
err_t accel31_default_cfg(accel31_t *ctx)
Accel 31 default configuration function.
accel31_data_t::temperature
int8_t temperature
Definition: accel31.h:403
accel31_s
Accel 31 Click context object.
Definition: accel31.h:340
application_task
void application_task(void)
Definition: main.c:72
accel31_init
err_t accel31_init(accel31_t *ctx, accel31_cfg_t *cfg)
Accel 31 initialization function.
accel31_axes_t::x
float x
Definition: accel31.h:390
accel31_cfg_t
Accel 31 Click configuration object.
Definition: accel31.h:363
accel31_set_accel_fsr
err_t accel31_set_accel_fsr(accel31_t *ctx, uint8_t fsr)
Accel 31 set accel fsr function.
ACCEL31_ERROR
@ ACCEL31_ERROR
Definition: accel31.h:414
application_init
void application_init(void)
Definition: main.c:35
ACCEL31_MAP_MIKROBUS
#define ACCEL31_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: accel31.h:304
ACCEL31_OK
@ ACCEL31_OK
Definition: accel31.h:413
accel31_axes_t::z
float z
Definition: accel31.h:392
accel31_data_t
Accel 31 Click data structure.
Definition: accel31.h:401
accel31_cfg_setup
void accel31_cfg_setup(accel31_cfg_t *cfg)
Accel 31 configuration object setup function.