LSM303 hangs on example code


I just received my new LSM303 however I can get any of the Example sketchs to work when uploaded, but they all compile ok.

I tried the board connected to a Uno and mega with the same results.
On the uno I have a cable connected like this
Vin -> Uno 5v
GND -> Uno Gnd
SCL -> A5
SDA -> A4
All other pins are unconnected on both the Uno and the lsm303 board.

If I run the Serial example from the library the setup() method runs ok, but the whole sketch seems to hang when; is called in the loop.

I have added some serial text output before and after this line. The before text is output ok but the serial text after the; never seems to run.

Am I being daft somewhere?



Hello, Johnathan.

I am sorry to hear you are having trouble with your compass. Could you try inspecting the solder joints on the board for any bad connections, both on the through-hole header pins and on the surface mount components? Do you have access to an oscilloscope you could use to check whether the expected signals are being sent on the SCL and SDA lines?

If you post a photo of your setup, we can check your connections and look for other potential problems for you.

- Kevin

Thanks for you quick reply.

I have inspected the hole pins and can seen nothing out of order. I ahve also tested the continuity of the cable and all seems fine. I also can not see anything with the SMD mounted components.

I have put an oscilloscope on both lines and they both show a stead +5v with no variation.

Attached is a pic, hopefully it is something obvious.

I modified the sketch with some debug

void setup() {

void loop() {
Serial.println("Reading Complete");

“Reading” is output but not “reading complete”

Thanks for your help


You have SCL and SDA connected to digital pins 4 and 5, not analog pins 4 and 5 (A4 and A5 on the other side of the Arduino). Can you see if fixing those connections solves your problem?

- Kevin

Sorry Kevin. The award for being a dumb ass goes to me. Swapped it to the analog ports and it worked perfectly.

Sorry I have wasted your time.

Thanks for the super quick response.


I’m glad to hear that fixed it. Thanks for the update.

- Kevin