Copyright (c) 2025 BitBank Software, Inc.
Written by Larry Bank
email: bitbank@pobox.com
This library aims to make it easier to work with IMUs (Inertial Measurement Units). There are a variety of vendors and products which all work in a very similar way. This library aims to simplify their use by providing a single API to work with the most popular products and auto-detect them. The end result is that you'll be able to write your project code and be able to freely change your component choices without having to change a single line of your code.
Getting Started
If your sensor is connected to the default I2C bus of your Arduino, this is the easiest scenario to use. Simply call init() with no parameters, then start() with the sensor mode you want to use:
rc = imu.init();
if (rc == IMU_SUCCESS) {
imu.start(100, MODE_ACCEL); // start the accelerometer at 100 samp/sec
}
Now you can start to receive accelerometer samples:
while (1) {
IMU_SAMPLE samp;
imu.getSample(&samp);
Serial.printf("X: %d, Y: %d, Z: %d\n", samp.accel[0], samp.accel[1], samp.accel[2]);
}
For more info about the full API, please consult the WiKi
If you find this code useful, please consider becoming a sponsor or sending a donation.
