Statistics
| Branch: | Revision:

adafruit_bno055 / examples / rawdata / rawdata.ino @ e5a77cdb

History | View | Annotate | Download (2.984 KB)

1 fcd68623 Kevin Townsend
#include <Wire.h>
2
#include <Adafruit_Sensor.h>
3
#include <Adafruit_BNO055.h>
4
#include <utility/imumaths.h>
5
6
/* This driver reads raw data from the BNO055
7
8
   Connections
9
   ===========
10
   Connect SCL to analog 5
11
   Connect SDA to analog 4
12
   Connect VDD to 3.3V DC
13
   Connect GROUND to common ground
14 f12bf4b5 Tony DiCola
15 fcd68623 Kevin Townsend
   History
16
   =======
17
   2015/MAR/03  - First release (KTOWN)
18
*/
19
20
/* Set the delay between fresh samples */
21 c4f272e1 ladyada
#define BNO055_SAMPLERATE_DELAY_MS (100)
22 f12bf4b5 Tony DiCola
23 e5a77cdb Gintaras
// Check I2C device address and correct line below (by default address is 0x29 or 0x28)
24
//                                   id, address
25
Adafruit_BNO055 bno = Adafruit_BNO055(-1, 0x28);
26 fcd68623 Kevin Townsend
27
/**************************************************************************/
28
/*
29
    Arduino setup function (automatically called at startup)
30
*/
31
/**************************************************************************/
32 f12bf4b5 Tony DiCola
void setup(void)
33 fcd68623 Kevin Townsend
{
34 e5a77cdb Gintaras
  Serial.begin(115200);
35 fcd68623 Kevin Townsend
  Serial.println("Orientation Sensor Raw Data Test"); Serial.println("");
36 f12bf4b5 Tony DiCola
37 fcd68623 Kevin Townsend
  /* Initialise the sensor */
38
  if(!bno.begin())
39
  {
40
    /* There was a problem detecting the BNO055 ... check your connections */
41
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
42
    while(1);
43
  }
44 f12bf4b5 Tony DiCola
45 fcd68623 Kevin Townsend
  delay(1000);
46 f12bf4b5 Tony DiCola
47 0e2e2723 Kevin Townsend
  /* Display the current temperature */
48
  int8_t temp = bno.getTemp();
49
  Serial.print("Current Temperature: ");
50
  Serial.print(temp);
51
  Serial.println(" C");
52
  Serial.println("");
53 f12bf4b5 Tony DiCola
54 c4f272e1 ladyada
  bno.setExtCrystalUse(true);
55 f12bf4b5 Tony DiCola
56
  Serial.println("Calibration status values: 0=uncalibrated, 3=fully calibrated");
57 fcd68623 Kevin Townsend
}
58
59
/**************************************************************************/
60
/*
61
    Arduino loop function, called once 'setup' is complete (your own code
62
    should go here)
63
*/
64
/**************************************************************************/
65 f12bf4b5 Tony DiCola
void loop(void)
66 fcd68623 Kevin Townsend
{
67
  // Possible vector values can be:
68
  // - VECTOR_ACCELEROMETER - m/s^2
69
  // - VECTOR_MAGNETOMETER  - uT
70
  // - VECTOR_GYROSCOPE     - rad/s
71
  // - VECTOR_EULER         - degrees
72
  // - VECTOR_LINEARACCEL   - m/s^2
73
  // - VECTOR_GRAVITY       - m/s^2
74
  imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
75 f12bf4b5 Tony DiCola
76 fcd68623 Kevin Townsend
  /* Display the floating point data */
77
  Serial.print("X: ");
78 c4f272e1 ladyada
  Serial.print(euler.x());
79
  Serial.print(" Y: ");
80
  Serial.print(euler.y());
81
  Serial.print(" Z: ");
82
  Serial.print(euler.z());
83 f12bf4b5 Tony DiCola
  Serial.print("\t\t");
84 fcd68623 Kevin Townsend
85
  /*
86
  // Quaternion data
87
  imu::Quaternion quat = bno.getQuat();
88
  Serial.print("qW: ");
89 c4f272e1 ladyada
  Serial.print(quat.w(), 4);
90
  Serial.print(" qX: ");
91
  Serial.print(quat.x(), 4);
92 27c81822 Andreas Wachaja
  Serial.print(" qY: ");
93
  Serial.print(quat.y(), 4);
94 c4f272e1 ladyada
  Serial.print(" qZ: ");
95
  Serial.print(quat.z(), 4);
96 f12bf4b5 Tony DiCola
  Serial.print("\t\t");
97 fcd68623 Kevin Townsend
  */
98 f12bf4b5 Tony DiCola
99
  /* Display calibration status for each sensor. */
100
  uint8_t system, gyro, accel, mag = 0;
101
  bno.getCalibration(&system, &gyro, &accel, &mag);
102
  Serial.print("CALIBRATION: Sys=");
103
  Serial.print(system, DEC);
104
  Serial.print(" Gyro=");
105
  Serial.print(gyro, DEC);
106
  Serial.print(" Accel=");
107
  Serial.print(accel, DEC);
108
  Serial.print(" Mag=");
109
  Serial.println(mag, DEC);
110
111 fcd68623 Kevin Townsend
  delay(BNO055_SAMPLERATE_DELAY_MS);
112 f12bf4b5 Tony DiCola
}