`accelerometer` logo

`accelerometer`

Free

Generic accelerometer support, including traits and types for taking readings from 2 or 3-axis accelerometers and tracking device orientations - [![crates.io](https://img.shields.io/crates/v/accelerometer.svg)](https://crates.io/crates/accelerometer)

FreeFree tier
Type
Open Source

About `accelerometer`

Accelerometer.rs is a Rust library providing generic support for accelerometers, including traits and types for taking readings from 2 or 3-axis accelerometers. It is designed for platform-agnostic accelerometer drivers built on embedded-hal and uses no_std-oriented 2D and 3D vector types from the micromath.rs crate. A key feature is device orientation tracking for 3-axis accelerometers, which returns smartphone-like position sensing as an Orientation enum. The library is dual-licensed under Apache-2.0 and MIT, and is maintained by the rust-embedded-community organization.

Key Features

Generic traits and types for 2 or 3-axis accelerometers
Platform-agnostic design using embedded-hal
no_std compatible with 2D/3D vector types from micromath.rs
Device orientation tracking for 3-axis accelerometers (smartphone-like position sensing)
Supports multiple specific accelerometer driver crates (ADXL313, ADXL343, LIS2DH12, LIS3DH, MMA7660FC, STK8BA58, KXTJ31057)
Dual licensed under Apache-2.0 and MIT

Pros & Cons

Pros
  • Generic and reusable traits allow easy integration with multiple accelerometer models
  • Orientation tracking provides high-level position information without complex math
  • Designed for embedded systems with no_std support and minimal dependencies
  • Community-maintained with a code of conduct and clear licensing
Cons
  • Requires Rust 1.47+ and familiarity with embedded-hal ecosystem
  • Orientation tracking only supported for 3-axis accelerometers
  • Limited to accelerometer data; does not include gyroscope or magnetometer fusion

Best For

Developing embedded Rust drivers for accelerometer sensorsBuilding platform-agnostic sensor reading librariesImplementing device orientation detection (e.g., portrait/landscape) using accelerometer dataCreating no_std Rust applications for microcontrollers with accelerometer input

FAQ

What is accelerometer.rs?
A Rust library that provides generic traits and types for reading data from 2 or 3-axis accelerometers, intended for use with platform-agnostic drivers built on embedded-hal.
Does it support orientation tracking?
Yes, orientation tracking is available for 3-axis accelerometers via the 'orientation' cargo feature, returning smartphone-like device position as an Orientation enum.
What Rust version is required?
Rust 1.47 or later is required.
Is it compatible with no_std environments?
Yes, it uses no_std-oriented 2D and 3D vector types from the micromath.rs crate, making it suitable for embedded systems.
Which accelerometer drivers are supported?
Several platform-agnostic drivers implement the Accelerometer and RawAccelerometer traits, including ADXL313, ADXL343, ADXL355, LIS2DH12, LIS3DH, MMA7660FC, STK8BA58, and KXTJ31057.
What is the license?
It is dual-licensed under Apache License 2.0 and MIT.