Skip to content

telit/arduino-BMA400-API

Repository files navigation

Arduino Library wrapper of BMA400 Sensor API

Bosch Sensortec's BMA400 accelerometer sensor API

This is a wrapper Arduino library of original Bosch Sensortec C library for BMA400 sensor. It provides a common I2C interface to communicate with the sensor. SPI interface is not available.

For more information on Bosch Sensortec source code and material, please refer to:


Arduino Library usage

To use the library in a sketch, include the telit_bma400.h header file

#include <telit_bma400.h>

Then initialize the interface, the sensor and the library

  struct bma400_dev bma;
  int8_t rslt;
  
  rslt = bma400_interface_init(&bma, BMA400_I2C_INTF);
  bma400_check_rslt("bma400_interface_init", rslt);
  
  rslt = bma400_soft_reset(&bma);
  bma400_check_rslt("bma400_soft_reset", rslt);

  rslt = bma400_init(&bma);
  bma400_check_rslt("bma400_init", rslt);
  

The sensor can then be configured with the required options depending on the application scenario, for example:

  struct bma400_sensor_conf conf;
  conf.type = BMA400_ACCEL;
    
  /* Get the accelerometer configurations which are set in the sensor */
  rslt = bma400_get_sensor_conf(&conf, 1, &bma);
  
  /* Modify the desired configurations as per macros
  * available in bma400_defs.h file */
  conf.param.accel.odr = BMA400_ODR_100HZ;
  conf.param.accel.range = BMA400_RANGE_2G;
  conf.param.accel.data_src = BMA400_DATA_SRC_ACCEL_FILT_1;

  /* Set the desired configurations to the sensor */
  rslt = bma400_set_sensor_conf(&conf, 1, &bma);
  bma400_check_rslt("bma400_set_sensor_conf", rslt);

The sensor operating mode can then be set with

  rslt = bma400_set_power_mode(BMA400_MODE_NORMAL, &bma);
  bma400_check_rslt("bma400_set_power_mode", rslt);

Please refer to the provided examples for additional details.

Releases

No releases published

Packages

No packages published