Statistics
| Branch: | Revision:

adafruit_bno055 / examples / rawdata / rawdata.ino @ fcd68623

History | View | Annotate | Download (2.344 KB)

1
#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
    
15
   History
16
   =======
17
   2015/MAR/03  - First release (KTOWN)
18
*/
19

    
20
/* Set the delay between fresh samples */
21
#define BNO055_SAMPLERATE_DELAY_MS (500)
22
   
23
Adafruit_BNO055 bno = Adafruit_BNO055();
24

    
25
/**************************************************************************/
26
/*
27
    Arduino setup function (automatically called at startup)
28
*/
29
/**************************************************************************/
30
void setup(void) 
31
{
32
  Serial.begin(9600);
33
  Serial.println("Orientation Sensor Raw Data Test"); Serial.println("");
34
  
35
  /* Initialise the sensor */
36
  if(!bno.begin())
37
  {
38
    /* There was a problem detecting the BNO055 ... check your connections */
39
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
40
    while(1);
41
  }
42
  
43
  delay(1000);
44
    
45
  /* Display chip revision details (optional) */
46
  bno.displayRevInfo();
47
  Serial.println("");
48
}
49

    
50
/**************************************************************************/
51
/*
52
    Arduino loop function, called once 'setup' is complete (your own code
53
    should go here)
54
*/
55
/**************************************************************************/
56
void loop(void) 
57
{
58
  // Possible vector values can be:
59
  // - VECTOR_ACCELEROMETER - m/s^2
60
  // - VECTOR_MAGNETOMETER  - uT
61
  // - VECTOR_GYROSCOPE     - rad/s
62
  // - VECTOR_EULER         - degrees
63
  // - VECTOR_LINEARACCEL   - m/s^2
64
  // - VECTOR_GRAVITY       - m/s^2
65
  imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
66
  
67
  /* Display the floating point data */
68
  Serial.print("X: ");
69
  bno.printDouble(euler.x(), 1000);
70
  Serial.print("Y: ");
71
  bno.printDouble(euler.y(), 1000);
72
  Serial.print("Z: ");
73
  bno.printDouble(euler.z(), 1000);
74
  Serial.println("");
75

    
76
  /*
77
  // Quaternion data
78
  imu::Quaternion quat = bno.getQuat();
79
  Serial.print("qW: ");
80
  bno.printDouble(quat.w(), 1000);
81
  Serial.print("qX: ");
82
  bno.printDouble(quat.y(), 1000);
83
  Serial.print("qY: ");
84
  bno.printDouble(quat.x(), 1000);
85
  Serial.print("qZ: ");
86
  bno.printDouble(quat.z(), 1000);
87
  Serial.println("");
88
  */
89
  
90
  delay(BNO055_SAMPLERATE_DELAY_MS);
91
}