SparkFun Triple Axis Accelerometer Breakout - BMA400 (Qwiic) Hookup Guide
BMA400 Arduino Library
Note: This library assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.
The SparkFun BMA400 Arduino Library is based off the API for the sensor from Bosch to let users get started reading data from the sensor and using the various interrupt options. Install the library through the Arduino Library Manager tool by searching for "SparkFun BMA400". Users who prefer to manually install the library can download a copy of it from the GitHub repository by clicking the button below:
Library Functions
The list below outlines and describes the functions available in the SparkFun BMA400 Arduino Library. For detailed information on the available parameters and use of all functions, refer to the .cpp file in the library.
Sensor Initialization and Configuration
int8_t BMA400::beginI2C(uint8_t address, TwoWire& wirePort);
- Initialize the sensor over I2C at the specified address and port.int8_t BMA400::beginSPI(uint8_t csPin, uint32_t clockFrequency);
- Initialize the sensor over SPI with the specified Chip Select pin and clock frequency.int8_t setMode(uint8_t mode);
- Set the power mode.int8_t getMode(uint8_t* mode);
- Returns the setting for power mode.int8_t setAutoWakeup(bma400_auto_wakeup_conf* config);
- Enable Auto Wakeup.int8_t setAutoLowPower(bma400_auto_lp_conf* config);
- Enable Auto Low Powerint8_t setRange(uint8_t range);
- Set the measurement range.int8_t getRange(uint8_t* range);
- Returns the value stored for measurement range.int8_t setODR(uint8_t odr);
- Set the output data rate.int8_t getODR(uint8_t* odr);
- Returns the value stored for output data rate.int8_t setOSRLP(uint8_t osrLP);
- Set the output data rate for Low Power.int8_t getOSRLP(uint8_t* osrLP);
- Returns the value stored for output data rate for Low Power.int8_t setDataSource(uint8_t source);
- Set the data source filter. Options are Default with variable ODR, 100Hz ODR, and 100Hz with 1Hz bandwidth.int8_t getDataSource(uint8_t* source);
- Returns the value for data source.int8_t setFilter1Bandwidth(uint8_t bw);
- Set the low pass filter bandwidth.int8_t getFilter1Bandwidth(uint8_t* bw);
- Returns the value set for low pass filter bandwidth.int8_t getStepCount(uint32_t* count, uint8_t* activityType);
- Returns the number of steps measured along with activity type (Still, Walk, and Run).int8_t selfTest();
- Runs self test to determine if the sensor is behaving correctly.
Sensor Data
int8_t getSensorData(bool sensorTime = false);
- Requests acceleration data from the BMA400. This must be called to update the data structure.int8_t getTemperature(float* temp);
- Returns the temperature data recorded in °C.
Interrupt Control and Feature Selection
int8_t setInterruptPinMode(bma400_int_chan channel, uint8_t mode);
- Set the interrupt pin mode. Options are push/pull and active high/low.int8_t enableInterrupt(bma400_int_type intType, bool enable);
- Enable interrupt condition.int8_t getInterruptStatus(uint16_t* status);
- Returns interrupt status flags for the various interrupt conditions (wakeup, activity, step, etc.).int8_t setDRDYInterruptChannel(bma400_int_chan channel);
- Select the interrupt pin for the data ready interrupt condition.int8_t setGeneric1Interrupt(bma400_gen_int_conf* config);
- Set the generic 1 interrupt configuration.int8_t setGeneric2Interrupt(bma400_gen_int_conf* config);
- Set the generic 2 interrupt configuration.int8_t setOrientationChangeInterrupt(bma400_orient_int_conf* config);
- Set the orientation change interrupt configuration.int8_t setTapInterrupt(bma400_tap_conf* config);
- Set the tap interrupt configuration.int8_t setStepCounterInterrupt(bma400_step_int_conf* config);
- Set the step counter interrupt configuration.int8_t setActivityChangeInterrupt(bma400_act_ch_conf* config);
- Set the activity change interrupt configuration.int8_t setWakeupInterrupt(bma400_wakeup_conf* config);
- Set the device wakeup interrupt configuration.
FIFO Buffer Control
int8_t setFIFOConfig(bma400_fifo_conf* config);
- Enable and configure the FIFO buffer.int8_t getFIFOLength(uint16_t* numData);
- Set the number of samples to store in the FIFO buffer.int8_t getFIFOData(BMA400_SensorData* data, uint16_t* numData);
- Pull data stored in FIFO buffer.int8_t flushFIFO();
- Flush the FIFO buffer.