Skip to main content

Quick Start

This board measures acceleration on three axes. Connect it over I2C, install the library for your environment, and run its basic readings example to see the X, Y and Z acceleration in g.

You program the controller connected to this breakout. The breakout itself is not flashed.

1. Connect the breakout board​

Connect the breakout to your controller's 3.3 V, GND and I2C pins. If the controller has a Qwiic connector, a Qwiic cable from it to either Qwiic connector on the breakout does this. Otherwise, solder the included header pins and wire them as this table shows for a NULA DeepSleep:

NULA DeepSleepSoldered Ultra-Low-Power Accelerometer BMA400 Breakout
GNDGND
3V33V3
IO8SDA
IO9SCL
Wiring diagram: the NULA DeepSleep connected to the Soldered Ultra-Low-Power Accelerometer BMA400 Breakout: GND to GND, 3V3 to 3V3, IO8 to SDA, IO9 to SCL

On the NULA DeepSleep, Wire.begin() without arguments uses IO8 as SDA and IO9 as SCL, the pins in this table. On another controller, use its default I2C pins.

The board has no regulator and no level shifter: 3V3 powers the BMA400 directly and sets its logic level. Supply 1.72 V to 3.6 V and use a controller with 3.3 V logic. Never connect 3V3 or a signal pin to 5 V.

2. Install the library​

Download the Soldered BMA400 Accelerometer library from its GitHub repository and add it to the Arduino IDE as a ZIP library.

🔗Soldered BMA400 Accelerometer

Verified Arduino library at commit 853ca67

→

Tip: downloading from GitHub. On the library's GitHub page, click the green Code button and choose Download ZIP, then add it in Arduino IDE with Sketch → Include Library → Add .ZIP Library....

3. Run the first example​

This is basicReadings.ino, the library's simplest example. It starts the sensor at the default address 0x14 and prints the acceleration on all three axes in g, about 50 times a second. Upload it, then open the Serial Monitor at 115200 baud.

Select Board
basicReadings.ino
/**
**************************************************
*
* @file basicReadings.ino
*
* @brief Example showing how to read X, Y, Z acceleration data
* from the Soldered BMA400 Accelerometer breakout over I2C
*
* @link solde.red/333419 : Soldered BMA400 Accelerometer breakout
*
* @authors SparkFun Electronics, modified by Soldered Electronics
***************************************************/
#include <BMA400-SOLDERED.h>

// Create an instance of the BMA400 sensor
Soldered_BMA400 accelerometer;

void setup()
{
// Initialize serial for output
Serial.begin(115200);
Serial.println("BMA400 Example - Basic Readings");

// Initialize I2C bus
Wire.begin();

// Check if sensor is connected and initialize it.
// Address is optional, defaults to 0x14
while (accelerometer.begin() != BMA400_OK)
{
Serial.println("Error: BMA400 not connected, check wiring and I2C address!");
delay(1000);
}

Serial.println("BMA400 connected!");
}

void loop()
{
// Get new measurements from the sensor. This must be called before
// accessing the acceleration data, otherwise it will never update
accelerometer.getSensorData();

// Print acceleration data in g's
Serial.print("Acceleration in g's");
Serial.print("\t");
Serial.print("X: ");
Serial.print(accelerometer.data.accelX, 3);
Serial.print("\t");
Serial.print("Y: ");
Serial.print(accelerometer.data.accelY, 3);
Serial.print("\t");
Serial.print("Z: ");
Serial.println(accelerometer.data.accelZ, 3);

// Print 50x per second
delay(20);
}

4. Check the result​

Once the sensor answers, the Serial Monitor shows two lines, then one line per reading, about 50 a second: Acceleration in g's, then X:, Y: and Z:, each axis in g with three decimals, separated by tabs. With the breakout wired to a NULA DeepSleep and lying flat, the start of the output looks like this:

Serial MonitorAutoscrollShow timestampNewline115200 baud
Message (Enter to send message to the board)
BMA400 Example - Basic Readings
BMA400 connected!
Acceleration in g's X: 0.007 Y: -0.022 Z: 0.996
Acceleration in g's X: 0.011 Y: -0.025 Z: 1.000
Acceleration in g's X: 0.014 Y: -0.026 Z: 1.004
Acceleration in g's X: 0.016 Y: -0.013 Z: 0.994
Acceleration in g's X: 0.012 Y: -0.015 Z: 1.001

If you see Error: BMA400 not connected, check wiring and I2C address! once a second instead, the sensor did not answer at 0x14.

5. If it does not work​

Continue with Troubleshooting and retry this smallest example after each change.