A simplified version of the mdb-alarm-service that only opens the BMA2 sensor device(s) and continuously reads out and displays their data.
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.
- 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
- Linux system with I2C support
- BMA2 accelerometer connected to I2C bus
- GCC or compatible cross-compiler
- Make
To build for the host system:
cd bma2-simple-reader
makeTo 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>Run the executable:
./bma2-simple-readerThe program will:
- Initialize the BMA2 sensor
- Configure it for normal operation
- Continuously read and display the accelerometer data
- Exit gracefully when Ctrl+C is pressed
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
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
This project is based on the Bosch BMA2 Sensor API, which is licensed under the BSD-3-Clause license.