lorawan/sodaq_one/compass.ino

29 lines
509 B
Arduino
Raw Normal View History

2016-10-22 20:38:24 +00:00
#include <Wire.h>
#include <LSM303.h>
LSM303 compass;
void setupCompass()
{
Wire.begin();
compass.init();
compass.enableDefault();
}
2016-10-24 19:43:59 +00:00
String getCompass()
2016-10-22 20:38:24 +00:00
{
2016-10-24 19:43:59 +00:00
String tmps;
compass.read();
2016-10-22 20:38:24 +00:00
2016-11-02 16:38:56 +00:00
tmps = String("compass a.x=" ) + compass.a.x +
String(" a.y=" ) + compass.a.y +
String(" a.z=" ) + compass.a.z +
String(" m.x=" ) + compass.m.x +
String(" m.y=" ) + compass.m.y +
String(" m.z=" ) + compass.m.z;
2016-10-24 19:43:59 +00:00
debugSerial.println(tmps);
return tmps;
2016-10-22 20:38:24 +00:00
}