lorawan/sodaq_one/compass.ino

29 lines
549 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-10-24 19:43:59 +00:00
tmps = String("compass.a.x=" ) + compass.a.x +
String(" compass.a.y=" ) + compass.a.y +
String(" compass.a.z=" ) + compass.a.z +
String(" compass.m.x=" ) + compass.m.x +
String(" compass.m.y=" ) + compass.m.y +
2016-10-24 19:43:59 +00:00
String(" compass.m.z=" ) + compass.m.z;
debugSerial.println(tmps);
return tmps;
2016-10-22 20:38:24 +00:00
}