Micro:bit and BMA400 acceleration sensor example with the Arduino IDE

In this article we look at another acceleration sensor – this time its the BMA400

Lets look at the sensor before we explore how to connect it to a micro:bit

The BMA400 is the first real ultra-low power acceleration sensor without compromising on performance. Featuring 12-bit digital resolution, continuous measurement and a defined selectable bandwidth combined with ultra-low power the BMA400 allows low-noise measurement of accelerations in three perpendicular axes. The BMA400 thus senses tilt, orientation, tab/double tab, and enables plug ’n’ play step counting with activity recognition especially suited for wearable devices, which need a long-lasting battery lifetime.

Thanks to the continuous measurement principle and always-defined bandwidth, the BMA400 is the ideal solution for smart home applications such as smart indoor climate systems and smart home security systems. In the latter, the BMA400 can distinguish between real alarm situations like broken glass and false signals coming from random vibrations. Thereby, the new acceleration sensor avoids false alarms.

Features

Parameter Technical data
Measurement range ±2 g, ±4 g, ±8 g, ±16 g
Digital resolution 12 bit
Output Data Rate (ODR) 12.5 Hz to 800 Hz
Low path filter bandwidth Selectable 0.48xODR or 0.24xODR
Current consumption (independent from ODR due to continuous measurement) Max. performance: 14.5 μA
Typical use case: 5.8 μA
Low power use case: 3.5μA
Noise density Max. performance: 180 μg/√Hz (Z: x 1.45)
Typical use case: 300 μg/√Hz (Z: x 1.45)
Low power: 415 μg/√Hz (Z: x 1.45)
Ultra low power / Auto-wake-up mode 800 nA @ 25 Hz ODR
Embedded features
  • Step counter (< 4 μA overall)
  • Activity recognition (walking, running, standing still)
  • Activity change
  • Orientation
  • Tab/Double tab (< 8 μA overall)
  • General interrupt 1 and 2 (programmable via thresholds, timer, logical AND/OR operations)
  • 1 kB FIFO
Offset ±80 mg
TCO ±1 mg/K
Interface SPI & I²C & 2 Interrupt pins
Supply voltage 1.71 V up to 3.6 V

Parts Required

 

Name Link
Micro:bit Micro Bit Development Board
BMA400 BMA400 Acceleration Sensor
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire
expansion board GPIO Expansion Board For micro:bit

Schematic/Connection

microbit and bma400
microbit and bma400

 

Code Example

This uses the library from https://github.com/Seeed-Studio/Grove_3Axis_Digital_Accelerometer_BMA400

[codesyntax lang=”cpp”]

#include “BMA400.h”

float x = 0, y = 0, z = 0;
int16_t temp = 0;

void setup(void)
{
Wire.begin();

Serial.begin(115200);
while(!Serial);
Serial.println(“BMA400 Raw Data”);

while(1)
{
if(bma400.isConnection())
{
bma400.initialize();
Serial.println(“BMA400 is connected”);
break;
}
else Serial.println(“BMA400 is not connected”);

delay(2000);
}
}

void loop(void)
{
bma400.getAcceleration(&x, &y, &z);
temp = bma400.getTemperature();

Serial.print(x);
Serial.print(“,”);
Serial.print(y);
Serial.print(“,”);
Serial.print(z);
Serial.print(“,”);

Serial.print(temp);

Serial.println();

delay(500);
}

[/codesyntax]

 

Output

Open the serial monitor and you should see something like this

BMA400 is connected
-320.31,812.50,410.16,29
-486.33,861.33,291.02,23
-765.62,1039.06,310.55,30
0.00,0.00,0.00,23
0.00,0.00,0.00,23
-353.52,878.91,201.17,29
0.00,0.00,0.00,23
-261.72,933.59,156.25,29
-160.16,921.87,400.39,30

 

Links

https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMA400-DS000.pdf

https://github.com/BoschSensortec/BMA400-API

https://www.bosch-sensortec.com/bst/products/all_products/bma400_1

 

 

Leave a Comment

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :