Hello,
I am trying to use a LSM303DLM digital compass with my robot to get its direction.
Some background
- I am connecting it to an Arduino Mega. I am using the code provided on github (github.com/pololu/LSM303).
- I have the compass mounted on a breadboard, which is placed on the robot close to the Arduino.
- I have the LSM303DLM oriented on the breadboard like so: imgur.com/tvInAJb
- A picture of the robot is here: imgur.com/2fzOn95
- To calibrate the sensor, I run the “Calibrate” Arduino code. While it is running, I keep the robot stationary and then rotate the compass in a bunch of orientations while it is “inside” the robot. After this I place the values in the “Heading” Arduino code.
Problem
- When I run the “Heading” Arduino code, I get confusing results. When moving the robot in a straight line, the heading value increases. When I rotate the robot in place, the angle’s aren’t correct either. For example, if I rotate the robot 180 degrees then the compass changes 160 degrees, or 200 degrees.
- I have tried placing my Nexus 4 phone on the robot while running its compass app, and the app seems to give reasonable results.
Any pointers or help would be greatly appreciated.