So, I'm trying to get my Due to connect to an LSM303DLHC.
Pin Assignment (LSM303DLHC : DUE)
SCL:SCL
SDA:SDA
VIN:3.3V
GND:GND
I'm using the library downloaded from: GitHub - pololu/lsm303-arduino: Arduino library for Pololu LSM303 boards
According to the read me / description. The Arduino Due's wire library does not allow the init() method to be called without specifying what breakout board you are using. So, I've done that and set sa0_high (I've tried all 3).
I have a friend who is using this same breakout board and it works well with the omega. I might check with him to see if our breakout board is damaged. But I feel like it may be an issue with the library / code? Anyone have any hints?
#include <Wire.h>
#include <LSM303.h>
LSM303 compass;
LSM303::vector<int16_t> running_min = {32767, 32767, 32767}, running_max = {-32768, -32768, -32768};
char report[80];
void setup() {
Serial.begin(9600);
Wire.begin();
compass.init(LSM303::device_DLHC, LSM303::sa0_high);
compass.enableDefault();
}
void loop() {
compass.read();
running_min.x = min(running_min.x, compass.m.x);
running_min.y = min(running_min.y, compass.m.y);
running_min.z = min(running_min.z, compass.m.z);
running_max.x = max(running_max.x, compass.m.x);
running_max.y = max(running_max.y, compass.m.y);
running_max.z = max(running_max.z, compass.m.z);
snprintf(report, sizeof(report), "min: {%+6d, %+6d, %+6d} max: {%+6d, %+6d, %+6d}",
running_min.x, running_min.y, running_min.z,
running_max.x, running_max.y, running_max.z);
Serial.println(report);
delay(100);
}
My output shows: min: { +0, +0, +0} max: { +0, +0, +0}
- infinity.