adafruit_bno055 / examples / rawdata / rawdata.ino @ 23cf3c90
History | View | Annotate | Download (2.841 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 | fcd68623 | Kevin Townsend | Adafruit_BNO055 bno = Adafruit_BNO055(); |
24 | |||
25 | /**************************************************************************/ |
||
26 | /* |
||
27 | Arduino setup function (automatically called at startup) |
||
28 | */ |
||
29 | /**************************************************************************/ |
||
30 | f12bf4b5 | Tony DiCola | void setup(void) |
31 | fcd68623 | Kevin Townsend | { |
32 | Serial.begin(9600); |
||
33 | Serial.println("Orientation Sensor Raw Data Test"); Serial.println(""); |
||
34 | f12bf4b5 | Tony DiCola | |
35 | fcd68623 | Kevin Townsend | /* 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 | f12bf4b5 | Tony DiCola | |
43 | fcd68623 | Kevin Townsend | delay(1000); |
44 | f12bf4b5 | Tony DiCola | |
45 | 0e2e2723 | Kevin Townsend | /* Display the current temperature */ |
46 | int8_t temp = bno.getTemp(); |
||
47 | Serial.print("Current Temperature: "); |
||
48 | Serial.print(temp); |
||
49 | Serial.println(" C"); |
||
50 | Serial.println(""); |
||
51 | f12bf4b5 | Tony DiCola | |
52 | c4f272e1 | ladyada | bno.setExtCrystalUse(true); |
53 | f12bf4b5 | Tony DiCola | |
54 | Serial.println("Calibration status values: 0=uncalibrated, 3=fully calibrated"); |
||
55 | fcd68623 | Kevin Townsend | } |
56 | |||
57 | /**************************************************************************/ |
||
58 | /* |
||
59 | Arduino loop function, called once 'setup' is complete (your own code |
||
60 | should go here) |
||
61 | */ |
||
62 | /**************************************************************************/ |
||
63 | f12bf4b5 | Tony DiCola | void loop(void) |
64 | fcd68623 | Kevin Townsend | { |
65 | // Possible vector values can be: |
||
66 | // - VECTOR_ACCELEROMETER - m/s^2 |
||
67 | // - VECTOR_MAGNETOMETER - uT |
||
68 | // - VECTOR_GYROSCOPE - rad/s |
||
69 | // - VECTOR_EULER - degrees |
||
70 | // - VECTOR_LINEARACCEL - m/s^2 |
||
71 | // - VECTOR_GRAVITY - m/s^2 |
||
72 | imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER); |
||
73 | f12bf4b5 | Tony DiCola | |
74 | fcd68623 | Kevin Townsend | /* Display the floating point data */ |
75 | Serial.print("X: "); |
||
76 | c4f272e1 | ladyada | Serial.print(euler.x()); |
77 | Serial.print(" Y: "); |
||
78 | Serial.print(euler.y()); |
||
79 | Serial.print(" Z: "); |
||
80 | Serial.print(euler.z()); |
||
81 | f12bf4b5 | Tony DiCola | Serial.print("\t\t"); |
82 | fcd68623 | Kevin Townsend | |
83 | /* |
||
84 | // Quaternion data |
||
85 | imu::Quaternion quat = bno.getQuat(); |
||
86 | Serial.print("qW: "); |
||
87 | c4f272e1 | ladyada | Serial.print(quat.w(), 4); |
88 | Serial.print(" qX: "); |
||
89 | Serial.print(quat.y(), 4); |
||
90 | Serial.print(" qY: "); |
||
91 | Serial.print(quat.x(), 4); |
||
92 | Serial.print(" qZ: "); |
||
93 | Serial.print(quat.z(), 4); |
||
94 | f12bf4b5 | Tony DiCola | Serial.print("\t\t"); |
95 | fcd68623 | Kevin Townsend | */ |
96 | f12bf4b5 | Tony DiCola | |
97 | /* Display calibration status for each sensor. */ |
||
98 | uint8_t system, gyro, accel, mag = 0; |
||
99 | bno.getCalibration(&system, &gyro, &accel, &mag); |
||
100 | Serial.print("CALIBRATION: Sys="); |
||
101 | Serial.print(system, DEC); |
||
102 | Serial.print(" Gyro="); |
||
103 | Serial.print(gyro, DEC); |
||
104 | Serial.print(" Accel="); |
||
105 | Serial.print(accel, DEC); |
||
106 | Serial.print(" Mag="); |
||
107 | Serial.println(mag, DEC); |
||
108 | |||
109 | fcd68623 | Kevin Townsend | delay(BNO055_SAMPLERATE_DELAY_MS); |
110 | f12bf4b5 | Tony DiCola | } |