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.

Hardware Required

The Circuit

genuino101fzz

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
3 * Copyright (c) 2016 Intel Corporation. All rights reserved.
4
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 the
12
13 Intel(R) Curie(TM) module can be used to read gyroscope data
14
15*/
16
17#include "CurieIMU.h"
18
19void setup() {
20
21 Serial.begin(9600); // initialize Serial communication
22
23 while (!Serial); // wait for the serial port to open
24
25 // initialize device
26
27 Serial.println("Initializing IMU device...");
28
29 CurieIMU.begin();
30
31 // Set the accelerometer range to 250 degrees/second
32
33 CurieIMU.setGyroRange(250);
34}
35
36void loop() {
37
38 float gx, gy, gz; //scaled Gyro values
39
40 // read gyro measurements from device, scaled to the configured range
41
42 CurieIMU.readGyroScaled(gx, gy, gz);
43
44 // display tab-separated gyro x/y/z values
45
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
63 Copyright (c) 2016 Intel Corporation. All rights reserved.
64
65 This library is free software; you can redistribute it and/or
66
67 modify it under the terms of the GNU Lesser General Public
68
69 License as published by the Free Software Foundation; either
70
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 of
76
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
78
79 Lesser General Public License for more details.
80
81 You should have received a copy of the GNU Lesser General Public
82
83 License along with this library; if not, write to the Free Software
84
85 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
86
87*/

Contribute to Arduino

Join the community and suggest improvements to this article via GitHub. Make sure to read out contribution policy before making your pull request.

Missing something?

Check out our store and get what you need to follow this tutorial.

Suggest Changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.