Revision 8ac2d6f6

View differences:

examples/sensorapi/sensorapi.ino
5 5

  
6 6
/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
7 7
   which provides a common 'type' for sensor data and some helper functions.
8
   
8

  
9 9
   To use this driver you will also need to download the Adafruit_Sensor
10 10
   library and include it in your libraries folder.
11 11

  
......
14 14
   sensor in any data logs, etc.  To assign a unique ID, simply
15 15
   provide an appropriate value in the constructor below (12345
16 16
   is used by default in this example).
17
   
17

  
18 18
   Connections
19 19
   ===========
20 20
   Connect SCL to analog 5
21 21
   Connect SDA to analog 4
22 22
   Connect VDD to 3-5V DC
23 23
   Connect GROUND to common ground
24
    
24

  
25 25
   History
26 26
   =======
27 27
   2015/MAR/03  - First release (KTOWN)
......
29 29

  
30 30
/* Set the delay between fresh samples */
31 31
#define BNO055_SAMPLERATE_DELAY_MS (100)
32
   
32

  
33 33
Adafruit_BNO055 bno = Adafruit_BNO055(55);
34 34

  
35 35
/**************************************************************************/
......
48 48
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
49 49
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" xxx");
50 50
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" xxx");
51
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" xxx");  
51
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" xxx");
52 52
  Serial.println("------------------------------------");
53 53
  Serial.println("");
54 54
  delay(500);
......
56 56

  
57 57
/**************************************************************************/
58 58
/*
59
    Display some basic info about the sensor status
60
*/
61
/**************************************************************************/
62
void displaySensorStatus(void)
63
{
64
  /* Get the system status values (mostly for debugging purposes) */
65
  uint8_t system_status, self_test_results, system_error;
66
  system_status = self_test_results = system_error = 0;
67
  bno.getSystemStatus(&system_status, &self_test_results, &system_error);
68

  
69
  /* Display the results in the Serial Monitor */
70
  Serial.print("System Status: 0x");
71
  Serial.println(system_status, HEX);
72
  Serial.print("Self Test:     0x");
73
  Serial.println(self_test_results, HEX);
74
  Serial.print("System Error:  0x");
75
  Serial.println(system_error, HEX);
76
  Serial.println("");
77
  delay(500);
78
}
79

  
80
/**************************************************************************/
81
/*
59 82
    Arduino setup function (automatically called at startup)
60 83
*/
61 84
/**************************************************************************/
62
void setup(void) 
85
void setup(void)
63 86
{
64 87
  Serial.begin(9600);
65 88
  Serial.println("Orientation Sensor Test"); Serial.println("");
66
  
89

  
67 90
  /* Initialise the sensor */
68 91
  if(!bno.begin())
69 92
  {
......
71 94
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
72 95
    while(1);
73 96
  }
74
  
97

  
75 98
  delay(1000);
76
    
99

  
77 100
  /* Display some basic information on this sensor */
78 101
  displaySensorDetails();
79 102

  
103
  /* Optional: Display current status */
104
  // displaySensorStatus();
105

  
80 106
  bno.setExtCrystalUse(true);
81 107
}
82 108

  
......
86 112
    should go here)
87 113
*/
88 114
/**************************************************************************/
89
void loop(void) 
115
void loop(void)
90 116
{
91
  /* Get a new sensor event */ 
92
  sensors_event_t event; 
117
  /* Get a new sensor event */
118
  sensors_event_t event;
93 119
  bno.getEvent(&event);
94
  
120

  
95 121
  /* Display the floating point data */
96 122
  Serial.print("X: ");
97 123
  Serial.print(event.orientation.x, 4);
......
100 126
  Serial.print("\tZ: ");
101 127
  Serial.print(event.orientation.z, 4);
102 128
  Serial.println("");
103
  
129

  
104 130
  delay(BNO055_SAMPLERATE_DELAY_MS);
105 131
}

Also available in: Unified diff