# Arduino 101 CurieIMU Gyro

With this tutorial you learn to read the gyroscope raw values and convert them into an angular velocity around each of the three axes.

With this tutorial you learn to read the gyroscope raw values and convert them into an angular velocity around each of the three axes. This information is useful to measure rotational movement around the three axes, something that acceleration can't measure if the movement is continuous.

## The Circuit

image developed using Fritzing. No additional hardware is needed to use this tutorial.

## Software Essentials

### Libraries

CurieIMU.h is the library that gives access to all the parameters, features and readings of the IMU chip of the 101 board. This unit contains a three axes accelerometer and a three axes gyroscope. This library is part of the 101 board core and it is loaded together with the core files for Arduino 101. In this tutorial we read the raw gyro values.

### Functions

float convertRawGyro(int gRaw) - transforms the raw data read from the gyroscope (gRaw) into a value expressed in degrees per second (°/s). The formula of the function must be adjusted to match the gyroscope range set with setGyroRange.

## Code

``````1/*2
5 * See the bottom of this file for the license terms.6
7 */8
9/*10
11   This sketch example demonstrates how the BMI160 on the12
13   Intel(R) Curie(TM) module can be used to read gyroscope data14
15*/16
17#include "CurieIMU.h"18
19void setup() {20
21  Serial.begin(9600); // initialize Serial communication22
23  while (!Serial);    // wait for the serial port to open24
25  // initialize device26
27  Serial.println("Initializing IMU device...");28
29  CurieIMU.begin();30
31  // Set the accelerometer range to 250 degrees/second32
33  CurieIMU.setGyroRange(250);34}35
36void loop() {37
38  float gx, gy, gz; //scaled Gyro values39
40  // read gyro measurements from device, scaled to the configured range41
44  // display tab-separated gyro x/y/z values45
46  Serial.print("g:\t");47
48  Serial.print(gx);49
50  Serial.print("\t");51
52  Serial.print(gy);53
54  Serial.print("\t");55
56  Serial.print(gz);57
58  Serial.println();59}60
61/*62
65   This library is free software; you can redistribute it and/or66
67   modify it under the terms of the GNU Lesser General Public68
71   version 2.1 of the License, or (at your option) any later version.72
73   This library is distributed in the hope that it will be useful,74
75   but WITHOUT ANY WARRANTY; without even the implied warranty of76
77   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU78
79   Lesser General Public License for more details.80
81   You should have received a copy of the GNU Lesser General Public82
83   License along with this library; if not, write to the Free Software84
85   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA86
87*/``````