Zumo Robot compass.read() hanging

I am having an issue where the zumo robot hangs in compass.read(). I am using the calibrate example and it won’t print anything after compass.read(); I am using the leonardo any advice?

#include <Wire.h>
#include <LSM303.h>

LSM303 compass;
LSM303::vector running_min = {2047, 2047, 2047}, running_max = {-2048, -2048, -2048};

void setup() {
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only

void loop() {  
  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);
  Serial.print("M min ");
  Serial.print("X: ");
  Serial.print(" Y: ");
  Serial.print(" Z: ");

  Serial.print(" M max ");  
  Serial.print("X: ");
  Serial.print(" Y: ");
  Serial.print(" Z: ");


I am sorry you are having trouble reading the compass on the Zumo. It should work with the Leonardo as long as the I2C connections are made correctly. Can you post pictures of your setup that show how everything is connected?


Arent the I2c connections already made or do they need a jumper?


Yes, the SCL and SDA connections are already set on the Zumo and connected to the compass. So, if the Leonardo and its headers are mounted correctly, you should be able to interface with the compass. I could have been more clear in my last post; I am sorry about that!

I was able to successfully run your code on a Leonardo with a Zumo; do you have access to another Arduino that works with the Zumo (e.g. Uno, Leonardo, etc.)? If not, could you post pictures of how you have your Leonardo connected? Also, have you cut the SCL and SDA jumpers in the middle of the board? (Cutting them will disconnect the compass from those lines.)


Was there any resolution on this?

I’m seeing the same problem with the calibrate example where I can log to serial up until my first compass.read() using the calibrate example. I’m using an Uno R1, example of hookups below, and no I have not cut the trace between SDA and SCL.

Image of connections here (sorry for non-optimal phone picture) : i.imgur.com/Xs9Ua68.jpg


The SCL and SDA pins do not exist on Arduino hardware versions prior to the Uno R3, so you will have to manually connect SCL to analog pin 5 and SDA to analog pin 4 on the Zumo Shield in order to use the compass. The most convenient place to do this is in the front expansion area, where these pins are all located together, as indicated by the light blue boxes in the picture below:

(This is mentioned inside the “Jumper settings” section of the Zumo user’s guide.)



I just tried to use the compass on my Zumo and I also experiencing the sketch hang up at the first compass.read() call.

I am using an older Arduino, I have set up the jumpers for A4-SDA and A5-SCL per the diagram in the last post. I’ve tried to run the calibrate and heading example sketches from the latest LSM303 release.

On one try I was able to get intermittent readouts from the compass in the serial monitor, but since then, I get nothing after the Arduino reaches the first compass.read() call.

I have a Pololu minIMU v1 which I believe also has an LSM303, and I’ve gotten that to work before with this Arduino.

Everything else with this Zumo/Arduino appears to work fine.



Specifically, which Arduino are you using? Can you post a picture of your Zumo board without the Arduino? Do you have another Arduino to try it with?


I’m using an Arduino Uno. Tried to attach a photo (.jpg) but I’m getting “The image file you tried to attach is invalid.”

Haven’t tried it with another Arduino yet, that’s on my to-do list.


You mentioned you are using an older Arduino, which version of Arduino Uno are you using? If you are having trouble attaching an image, you could try uploading it to a third party site and linking to it.