3/18/2019
Grove - 3-Axis Digitial Compass v2.0 - Seeed Wiki
http://wiki.seeedstudio.com/Grove-3-Axis_Digitial_Compass_v2.0/
8/15
Step 4. Upload the code. If you do not know how to upload the code, please check
[http://wiki.seeedstudio.com/Upload_Code/]
Step 5. Open the serial monitor to receive the sensor's data
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
}
void
loop
()
{
bmm150_mag_data value;
bmm.read_mag_data();
value.x = bmm.raw_mag_data.raw_datax;
value.y = bmm.raw_mag_data.raw_datay;
value.z = bmm.raw_mag_data.raw_dataz;
float
xyHeading = atan2(value.x, value.y);
float
zxHeading = atan2(value.z, value.x);
float
heading = xyHeading;
if
(heading <
0
)
h=
2
*PI;
if
(heading >
2
*PI)
heading -=
2
*PI;
float
headingDegrees = heading *
180
/M_PI;
float
xyHeadingDegrees = xyHeading *
180
/ M_PI;
float
zxHeadingDegrees = zxHeading *
180
/ M_PI;
Serial.print(
"Heading: "
);
Serial.println(headingDegrees);
delay(
100
);
}