Interfacing BMI160 Accelerometer & Gyroscope with Arduino
Interfacing BMI160 Accelerometer & Gyroscope with Arduino C++ Code to measure raw values, gyroscope pitch roll & acceleration in x, y, z axis
- Suitable forB.Tech/Diploma Arduino students
- Build time1-2 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
Overview
In this tutorial, we will be Interfacing the
BMI160
Accelerometer
&
Gyroscope
with
Arduino
Board. You can also use
BMI160 with ESP32
microcontroller and
Raspberry Pi Pico with BMI160
. The BMI160 is a small, low-power, low-noise
16-bit inertial measurement unit
that integrates a
3-axis accelerometer
and
3-axis gyroscope
. It provides precise motion sensing for applications like augmented reality, fitness tracking, and indoor navigation.
This tutorial provides detailed information about the B
MI160 Accelerometer Gyroscope Module
, including its specifications and technical details. First, we will interface the BMI160 with an Arduino Nano board to read the
raw acceleration
and gyroscope values. Next, we will write an
auto-calibration
code to use with the acceleration measurement code to measure
acceleration
across all three axes. Finally, in the third example, we will use the gyroscope data to measure
tilt angles
such as pitch and roll.
Bill of Materials
We will need the following components for this tutorial. You can purchase all the components from the given links.
S.N.
Components Name
Quantity
Purchase Link
Arduino Nano Board
Amazon
AliExpress
BMI160 Accelerometer Gyroscope
Amazon
AliExpress
Connecting Wires
Amazon
AliExpress
Breadboard
Amazon
AliExpress
BMI160 3 Axis Accelerometer & Gyroscope
The
BMI160
is a high-performance, small, and ultra-low-power 16-bit Inertial Measurement Unit (IMU) that combines a 3-axis accelerometer and a 3-axis gyroscope in a single package.
Fig: Front & Back of BMI160
It is designed to deliver accurate and reliable motion sensing for a wide range of applications, such as augmented reality, indoor navigation, wearable devices, and gaming. The sensor offers advanced features like motion detection, step counting, and gesture recognition, making it versatile for modern technology needs.
The
BMI160
supports both
I2C
and
SPI
interfaces for communication, making it compatible with a variety of microcontrollers and processors. It has a compact footprint of just
2.5 x 3.0 x 0.8 mm³
, which is smaller than many competing IMUs, such as the MPU6050, and is well-suited for space-constrained devices like wearables. Refer to Bosch
BMI160 Datasheet
for more information.
Technical Specifications of BMI160
Operating Voltage: 1.71 – 3.6 V (Breakout Board operates between 3.2V~6V)
Power Consumption
:
Gyroscope: 900 µA (full operation)
Gyroscope + Accelerometer: 950 µA (full operation)
Accelerometer: 180 µA (full operation)
Suspend Mode: 3 µA
Motion Detection: 200 µA
Acceleration Range: ±2g/±4g/±8g/±16g
Gyroscopes Range: ±125°/s,±250°/s,±500°/s,±1000°/s,±2000°/s
Acceleration Zero-g Offset: ±40mg
Gyroscopes Zero-g Offset: ±10°/s
Interfaces
:
Primary
: I2C or SPI
Secondary
: High-speed SPI for optical image stabilization
Noise Density
:
Accelerometer: 180 µg/√Hz
Gyroscope: 0.008 °/s/√Hz
Programmable Frequency: 25/32Hz~1600Hz
6D Detection and Location
16-bit Data Output
Shock Resistance: 1000gx 200us
2 Independent Programmable Interrupt Generators
In-built 1024 Byte FIFO
Applications of BMI160
Augmented Reality
: Tracks motion for virtual environments.
Indoor Navigation
: Supports step counting and positioning.
Mobile Devices
: For smartphones and smartwatches.
Wearables
: Powers fitness and health devices.
Gaming
: Tracks motion in controllers.
Cameras
: Stabilizes images.
Drones & Toys
: Enables motion sensing.
Pinout of BMI160
Fig: Pinout of BMI160 Gyroscope Accelerometer Module
Pin
Description
VIN
VIN
Power input pin. Accepts
3.3V to 5V
and steps it down for the BMI160 using an onboard regulator.
3.3V
3.3V
Regulated 3.3V output pin.
GND
GND
Ground pin. Connect to the ground of your system.
OCS
OCS
Optional Chip Select for secondary SPI interface (used in optical image stabilization).
INT1
INT1
Interrupt pin 1. Used for motion events or data-ready notifications.
INT2
INT2
Interrupt pin 2. An additional interrupt pin for more advanced use cases.
SCL/SCX
SCL
or
SCX
I2C clock line
when using I2C communication. Acts as
SPI clock (SCX)
in SPI mode.
SDA/SDX
SDA
or
SDX
I2C data line
when using I2C communication. Acts as
SPI data (SDX)
in SPI mode.
CS
CS
Chip Select pin for SPI communication. Used to select the BMI160 during SPI transactions.
SA0
SA0
I2C address selection pin. Connect to
GND
for address
0x68
or to
3.3V
for
0x69
Comparison Between MPU6050 and BMI160
The
BMI160
is more advanced and power-efficient compared to the
MPU6050
It also includes enhanced features like gesture recognition and step counting, which are absent in the MPU6050.
While the MPU6050 is still useful for basic motion sensing, the BMI160 outperforms it in terms of precision, power efficiency, and advanced capabilities. Here is the detailed comparison table:
Feature
MPU6050
BMI160
Power Consumption
Higher: ~3.6 mA in full operation
Lower: ~950 µA (gyro + accel)
FIFO Buffer Size
512 bytes
1024 bytes
Accelerometer Resolution
14-bit
16-bit
Gyroscope Resolution
16-bit
16-bit
Integrated Features
Basic motion sensing
Advanced features like gesture recognition, step counting, and motion interrupts
Noise Characteristics
Higher noise in accelerometer and gyro
Lower noise, better signal clarity
Communication Speed
Standard I2C
I2C and High-speed SPI for demanding applications
Package Size
Larger (4 x 4 x 1 mm)
Smaller (2.5 x 3.0 x 0.8 mm)
Power Modes
Limited low-power options
Multiple ultra-low-power modes (3 µA suspend)
Operating Voltage Range
2.375V – 3.46V
1.71V – 3.6V
Sensor Integration
Separate accelerometer and gyroscope data streams
Seamless integration with synchronization
Target Applications
General-purpose motion sensing
Optimized for mobile, wearables, AR, and IoT
Interfacing BMI160 Accelerometer & Gyroscope with Arduino
Let us interface the BMI160 Gyroscope Accelerometer module with Arduino Nano Board. We can either use the module in SPI Mode or in I2C Mode. For this tutorial, we are using the I2C Mode as it is very easy to configure and requires less wiring as well.
Here is an interfacing circuit diagram for the connection between BMI160 and Arduino Nano Board.
Fig: Circuit for interfacing BMI160 Accelerometer & Gyroscope with Arduino
BMI160 Pin
Arduino Nano Pin
Description
VIN
5V
Power input for the BMI160.
GND
GND
Ground connection.
SCL
A5
I2C Clock line.
SDA
A4
I2C Data line.
SA0
GND
Sets I2C address to
0x68
The BMI160 module is powered via the 5V pin from the Arduino Nano. The onboard voltage regulator steps it down to 3.3V for the sensor. Here we have connected the
SA0
Pin to the
GND
. Connecting
SA0
to
GND
sets the I2C address to
0x68
. If connected to 3.3V, the I2C address would change to
0x69
Fig: BMI160 Arduino Breadboard Assembly
Use a simple breadboard and connect as shown in the circuit diagram above.
Code: Reading the Raw Acceleration and Gyroscope Data
After hardware connection is done, now lets write an
Arduino C++ Code
to read the Raw Acceleration and Gyroscope Data from BMI160 Module.
To get the BMI160 readings, a very well-written library is available. Download the
BMI160 Library
maintained by
Hanyazou
and add it to Arduino IDE via library manager.
The following code initializes the BMI160 sensor over I2C, reads raw accelerometer and gyroscope data and prints them to the Serial Monitor for real-time monitoring.
#include <BMI160Gen.h> //https://github.com/hanyazou/BMI160-Arduino
#include <Wire.h>
// I2C Configuration for ESP32
const
int
i2c_addr
=
0x68
;
// Default I2C address for BMI160
void
setup
(
)
{
// Initialize Serial communication at 115200 baud rate
Serial
begin
(
9600
)
;
while
(
!
Serial
)
;
// Wait for Serial Monitor to connect (not required on ESP32)
// Initialize I2C with custom SDA and SCL pins
Wire
begin
(
)
;
// Initialize the BMI160 device in I2C mode
if
(
!
In this tutorial, we will be Interfacing the
BMI160
Accelerometer
&
Gyroscope
with
Arduino
Board. You can also use
BMI160 with ESP32
microcontroller and
Raspberry Pi Pico with BMI160
. The BMI160 is a small, low-power, low-noise
16-bit inertial measurement unit
that integrates a
3-axis accelerometer
and
3-axis gyroscope
. It provides precise motion sensing for applications like augmented reality, fitness tracking, and indoor navigation.
This tutorial provides detailed information about the B
MI160 Accelerometer Gyroscope Module
, including its specifications and technical details. First, we will interface the BMI160 with an Arduino Nano board to read the
raw acceleration
and gyroscope values. Next, we will write an
auto-calibration
code to use with the acceleration measurement code to measure
acceleration
across all three axes. Finally, in the third example, we will use the gyroscope data to measure
tilt angles
such as pitch and roll.
Bill of Materials
We will need the following components for this tutorial. You can purchase all the components from the given links.
S.N.
Components Name
Quantity
Purchase Link
Arduino Nano Board
Amazon
AliExpress
BMI160 Accelerometer Gyroscope
Amazon
AliExpress
Connecting Wires
Amazon
AliExpress
Breadboard
Amazon
AliExpress
BMI160 3 Axis Accelerometer & Gyroscope
The
BMI160
is a high-performance, small, and ultra-low-power 16-bit Inertial Measurement Unit (IMU) that combines a 3-axis accelerometer and a 3-axis gyroscope in a single package.
Fig: Front & Back of BMI160
It is designed to deliver accurate and reliable motion sensing for a wide range of applications, such as augmented reality, indoor navigation, wearable devices, and gaming. The sensor offers advanced features like motion detection, step counting, and gesture recognition, making it versatile for modern technology needs.
The
BMI160
supports both
I2C
and
SPI
interfaces for communication, making it compatible with a variety of microcontrollers and processors. It has a compact footprint of just
2.5 x 3.0 x 0.8 mm³
, which is smaller than many competing IMUs, such as the MPU6050, and is well-suited for space-constrained devices like wearables. Refer to Bosch
BMI160 Datasheet
for more information.
Technical Specifications of BMI160
Operating Voltage: 1.71 – 3.6 V (Breakout Board operates between 3.2V~6V)
Power Consumption
:
Gyroscope: 900 µA (full operation)
Gyroscope + Accelerometer: 950 µA (full operation)
Accelerometer: 180 µA (full operation)
Suspend Mode: 3 µA
Motion Detection: 200 µA
Acceleration Range: ±2g/±4g/±8g/±16g
Gyroscopes Range: ±125°/s,±250°/s,±500°/s,±1000°/s,±2000°/s
Acceleration Zero-g Offset: ±40mg
Gyroscopes Zero-g Offset: ±10°/s
Interfaces
:
Primary
: I2C or SPI
Secondary
: High-speed SPI for optical image stabilization
Noise Density
:
Accelerometer: 180 µg/√Hz
Gyroscope: 0.008 °/s/√Hz
Programmable Frequency: 25/32Hz~1600Hz
6D Detection and Location
16-bit Data Output
Shock Resistance: 1000gx 200us
2 Independent Programmable Interrupt Generators
In-built 1024 Byte FIFO
Applications of BMI160
Augmented Reality
: Tracks motion for virtual environments.
Indoor Navigation
: Supports step counting and positioning.
Mobile Devices
: For smartphones and smartwatches.
Wearables
: Powers fitness and health devices.
Gaming
: Tracks motion in controllers.
Cameras
: Stabilizes images.
Drones & Toys
: Enables motion sensing.
Pinout of BMI160
Fig: Pinout of BMI160 Gyroscope Accelerometer Module
Pin
Description
VIN
VIN
Power input pin. Accepts
3.3V to 5V
and steps it down for the BMI160 using an onboard regulator.
3.3V
3.3V
Regulated 3.3V output pin.
GND
GND
Ground pin. Connect to the ground of your system.
OCS
OCS
Optional Chip Select for secondary SPI interface (used in optical image stabilization).
INT1
INT1
Interrupt pin 1. Used for motion events or data-ready notifications.
INT2
INT2
Interrupt pin 2. An additional interrupt pin for more advanced use cases.
SCL/SCX
SCL
or
SCX
I2C clock line
when using I2C communication. Acts as
SPI clock (SCX)
in SPI mode.
SDA/SDX
SDA
or
SDX
I2C data line
when using I2C communication. Acts as
SPI data (SDX)
in SPI mode.
CS
CS
Chip Select pin for SPI communication. Used to select the BMI160 during SPI transactions.
SA0
SA0
I2C address selection pin. Connect to
GND
for address
0x68
or to
3.3V
for
0x69
Comparison Between MPU6050 and BMI160
The
BMI160
is more advanced and power-efficient compared to the
MPU6050
It also includes enhanced features like gesture recognition and step counting, which are absent in the MPU6050.
While the MPU6050 is still useful for basic motion sensing, the BMI160 outperforms it in terms of precision, power efficiency, and advanced capabilities. Here is the detailed comparison table:
Feature
MPU6050
BMI160
Power Consumption
Higher: ~3.6 mA in full operation
Lower: ~950 µA (gyro + accel)
FIFO Buffer Size
512 bytes
1024 bytes
Accelerometer Resolution
14-bit
16-bit
Gyroscope Resolution
16-bit
16-bit
Integrated Features
Basic motion sensing
Advanced features like gesture recognition, step counting, and motion interrupts
Noise Characteristics
Higher noise in accelerometer and gyro
Lower noise, better signal clarity
Communication Speed
Standard I2C
I2C and High-speed SPI for demanding applications
Package Size
Larger (4 x 4 x 1 mm)
Smaller (2.5 x 3.0 x 0.8 mm)
Power Modes
Limited low-power options
Multiple ultra-low-power modes (3 µA suspend)
Operating Voltage Range
2.375V – 3.46V
1.71V – 3.6V
Sensor Integration
Separate accelerometer and gyroscope data streams
Seamless integration with synchronization
Target Applications
General-purpose motion sensing
Optimized for mobile, wearables, AR, and IoT
Interfacing BMI160 Accelerometer & Gyroscope with Arduino
Let us interface the BMI160 Gyroscope Accelerometer module with Arduino Nano Board. We can either use the module in SPI Mode or in I2C Mode. For this tutorial, we are using the I2C Mode as it is very easy to configure and requires less wiring as well.
Here is an interfacing circuit diagram for the connection between BMI160 and Arduino Nano Board.
Fig: Circuit for interfacing BMI160 Accelerometer & Gyroscope with Arduino
BMI160 Pin
Arduino Nano Pin
Description
VIN
5V
Power input for the BMI160.
GND
GND
Ground connection.
SCL
A5
I2C Clock line.
SDA
A4
I2C Data line.
SA0
GND
Sets I2C address to
0x68
The BMI160 module is powered via the 5V pin from the Arduino Nano. The onboard voltage regulator steps it down to 3.3V for the sensor. Here we have connected the
SA0
Pin to the
GND
. Connecting
SA0
to
GND
sets the I2C address to
0x68
. If connected to 3.3V, the I2C address would change to
0x69
Fig: BMI160 Arduino Breadboard Assembly
Use a simple breadboard and connect as shown in the circuit diagram above.
Code: Reading the Raw Acceleration and Gyroscope Data
After hardware connection is done, now lets write an
Arduino C++ Code
to read the Raw Acceleration and Gyroscope Data from BMI160 Module.
To get the BMI160 readings, a very well-written library is available. Download the
BMI160 Library
maintained by
Hanyazou
and add it to Arduino IDE via library manager.
The following code initializes the BMI160 sensor over I2C, reads raw accelerometer and gyroscope data and prints them to the Serial Monitor for real-time monitoring.
#include <BMI160Gen.h> //https://github.com/hanyazou/BMI160-Arduino
#include <Wire.h>
// I2C Configuration for ESP32
const
int
i2c_addr
=
0x68
;
// Default I2C address for BMI160
void
setup
(
)
{
// Initialize Serial communication at 115200 baud rate
Serial
begin
(
9600
)
;
while
(
!
Serial
)
;
// Wait for Serial Monitor to connect (not required on ESP32)
// Initialize I2C with custom SDA and SCL pins
Wire
begin
(
)
;
// Initialize the BMI160 device in I2C mode
if
(
!
Technologies used
Hardware components
- ESP32
- Arduino
- Raspberry Pi
- MPU6050
Software & tools
- Arduino IDE
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.