Skip to content

rescoot/bma2-simple-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BMA2 Simple Reader

A simplified version of the mdb-alarm-service that only opens the BMA2 sensor device(s) and continuously reads out and displays their data.

Overview

This program initializes the Bosch BMA2 accelerometer sensor, configures it for basic operation, and continuously reads and displays the accelerometer data in both raw format and converted to m/s² (acceleration).

This is a self-contained project that includes all necessary files in the src directory, including the Bosch Sensortec BMA2 driver files.

Features

  • Simple, standalone application with minimal dependencies
  • Configurable sensor parameters (range, bandwidth, etc.)
  • Real-time display of accelerometer data
  • Supports cross-compilation for different target platforms
  • Graceful exit with Ctrl+C

Requirements

  • Linux system with I2C support
  • BMA2 accelerometer connected to I2C bus
  • GCC or compatible cross-compiler
  • Make

Building

Native Build

To build for the host system:

cd bma2-simple-reader
make

Cross-Compilation

To build for a different target architecture, specify the cross-compiler prefix:

# For ARM (e.g., Raspberry Pi)
make CROSS_COMPILE=arm-linux-gnueabihf-

# For MIPS
make CROSS_COMPILE=mips-linux-gnu-

# For other architectures
make CROSS_COMPILE=<your-cross-compiler-prefix>

Usage

Run the executable:

./bma2-simple-reader

The program will:

  1. Initialize the BMA2 sensor
  2. Configure it for normal operation
  3. Continuously read and display the accelerometer data
  4. Exit gracefully when Ctrl+C is pressed

Output Example

BMA2 Simple Reader
------------------
BMA2 sensor initialized successfully
Chip ID: 0xFA
Power mode: Normal

Reading accelerometer data...
Press Ctrl+C to exit

Raw: X=   123, Y=  -456, Z=  1024 | m/s²: X=   1.234, Y=  -4.567, Z=  10.240

Customization

You can modify the sensor configuration in src/main.c to change:

  • Measurement range (2G, 4G, 8G, 16G)
  • Bandwidth (7.81Hz to 1000Hz)
  • Power mode (Normal, Low Power, etc.)
  • Sampling rate

License

This project is based on the Bosch BMA2 Sensor API, which is licensed under the BSD-3-Clause license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors