Interfacing of 3-Axis Gyroscope Sensor BMG160 With Arduino

Interfacing of 3-Axis Gyroscope Sensor BMG160 With Arduino

BMG160 is basically a 16-bit, digital, tri-axial, gyroscope sensor which can measure angular rates.

  • 1,565 views
  • 0 comments
  • 1 respect

Components and supplies

About this project

Introduction

In today's world, more than half of the youth and kids are fond of gaming and all those who are fond of it, fascinated by the technical aspects of gaming knows the importance of motion sensing in this domain. We were also amazed by the same thing and just to bring it on the boards, we thought of working on a gyroscope sensor which can measure the angular rate of any object. So, the sensor we took up to deal with the task is BMG160. BMG160 is a 16-bit, digital, triaxial, gyroscope sensor which can measure the angular rate in three perpendicular room dimensions.

In this tutorial, we are going to demonstrate the working of BMG160 with Arduino Nano.

Step 1: BMG160 Overview

First of all we would like to familiarize you with the basic features of the sensor module that is BMG160 and the communication protocol on which it works.

BMG160 is basically a 16-bit, digital, triaxial, gyroscope sensor which can measure angular rates. It is capable of computing angular rates in three perpendicular room dimensions, the x-, y- and z-axis, and providing the corresponding output signals. It can communicate with the Raspberry Pi board using the I2C communication protocol. This particular module is designed to meet requirements for consumer applications as well as industrial purposes.

The communication protocol on which the sensor works is I2C. I2C stands for the inter-integrated circuit. It is a communication protocol in which the communication takes place through SDA (serial data) and SCL (serial clock) lines. It allows connecting multiple devices at the same time. It is one of the simplest and most efficient communication protocol.

Step 2: What you need

The materials that we need for accomplishing our goal includes the following hardware components:

1. BMG160

2. Arduino Nano

3. I2C Cable

4. I2C Shield for Arduino Nano

Step 3: Hardware Hookup

The hardware hookup section basically explains the wiring connections required between the sensor and the Arduino. Ensuring correct connections is the basic necessity while working on any system for the desired output. So, the requisite connections are as follows:

  • The BMG160 will work over I2C. Here is the example wiring diagram, demonstrating how to wire up each interface of the sensor.
  • Out-of-the-box, the board is configured for an I2C interface, as such we recommend using this hookup if you’re otherwise agnostic.

All you need is four wires! Only four connections are required Vcc, Gnd, SCL and SDA pins and these are connected with the help of I2C cable.

These connections are demonstrated in the pictures above.

Step 4: 3-Axis Gyroscope Measurement Arduino Code

Lets start with the Arduino code now.

While using the sensor module with the arduino, we include Wire.h library. "Wire" library contains the functions which facilitate the I2C communication between the sensor and the Arduino board.

The entire Arduino code is given below for the convenience of the user.

Step 5: Applications

BMG160 has a varied number of applications in devices like cell phones, human machine interface devices. This sensor module has been designed to meet requirements for consumer applications such as image stabilization (DSC and camera-phone), gaming and pointing devices. It is also employed in systems which require gesture recognition and the systems used in indoor navigation.

Code

3-Axis Gyroscope Measurement Arduino CodeArduino
#include
// BMG160 I2C address is 0x68(104)
#define Addr 0x68
void setup() 
{
// Initialise I2C communication as MASTER   
Wire.begin();  
// Initialise Serial Communication, set baud rate = 9600  
Serial.begin(9600);
 // Start I2C Transmission  
Wire.beginTransmission(Addr);  
// Select Range register  
Wire.write(0x0F);  
// Configure full scale range 2000 dps  
Wire.write(0x80);  
// Stop I2C Transmission  
Wire.endTransmission();
 // Start I2C Transmission  
Wire.beginTransmission(Addr);  
// Select Bandwidth register  
Wire.write(0x10);  
// Set bandwidth = 200 Hz  
Wire.write(0x04);  
// Stop I2C Transmission  
Wire.endTransmission();  
delay(300);
}
void loop()
{  
unsigned int data[6];  
// Start I2C Transmission  
Wire.beginTransmission(Addr);  
// Select Gyrometer data register 
Wire.write(0x02);  
// Stop I2C Transmission  
Wire.endTransmission();
 // Request 6 bytes of data  
Wire.requestFrom(Addr, 6);  
// Read 6 bytes of data 
// xGyro lsb, xGyro msb, yGyro lsb, yGyro msb, zGyro lsb, zGyro msb  
if(Wire.available() == 6)  
{    
data[0] = Wire.read();    
data[1] = Wire.read();    
data[2] = Wire.read();    
data[3] = Wire.read();    
data[4] = Wire.read();    
data[5] = Wire.read();  
}  
delay(300);    
// Convert the data  
int xGyro = ((data[1] * 256) + data[0]);  
int yGyro = ((data[3] * 256) + data[2]);  
int zGyro = ((data[5] * 256) + data[4]);    
// Output data to the serial monitor  
Serial.print("X-Axis of Rotation:  ");  
Serial.println(xGyro);  Serial.print("Y-Axis of Rotation:  ");  
Serial.println(yGyro);  Serial.print("Z-Axis of Rotation:  ");  
Serial.println(zGyro);  
delay(500);
}

Schematics

BMG160 Schematic
Fizxo0cipmvdj19 mbkzwgnl22

Comments

Similar projects you might like

Touch Sensor and Sound Sensor Controlling AC/DC Lights

Project showcase by Anbumachi

  • 1,162 views
  • 2 comments
  • 5 respects

Interfacing Arduino with Raspberry Pi

by Sankar Cheppali

  • 86,899 views
  • 9 comments
  • 26 respects

Interfacing Arduino UNO with SURE Electronics LED Dot Matrix

Project tutorial by Arduino_Scuola

  • 3,430 views
  • 1 comment
  • 3 respects

Arduino Fingerprint Sensor Tutorial

Project tutorial by Nick Koumaris

  • 57,838 views
  • 4 comments
  • 81 respects
Add projectSign up / Login