LSM303DLH stops responding after moving it

Hello, whenever I attempt to read or write to this LSM303DLH[1] compass, my program hangs. I'm using pololu library[2] like so:

compass.init(LSM303::device_DLH, LSM303::sa0_low); // using '*_auto' constants causes hang
compass.enableDefault(); // write (causes hang)
...; // read (causes hang)

My wiring is as such: SCL->SCL, SDA->SDA, +5V->VCC, GND->GND. I've ensured good connectivity.

I'm beginning to wonder if it's the right library. The surface mount components on the breakout board says HM55 on it, leading me to believe it might be a HM55B actually? Not sure. I got the chip on ebay (two of them actually) and they didn't come with a datasheet.

Any tips on how to debug? Thank you.

EDIT: I get a little further with a pullup resistor as suggested below but it still stops responding after it changes physical location. Any tips on how to proceed?

[1] Mine look exactly like this one
[2] GitHub - pololu/lsm303-arduino: Arduino library for Pololu LSM303 boards

Try running the I2C address scanner, to see if the chip responds to the correct address.

I tried using the I2C scanner, but the scanner itself hangs on Wire.endTransmission();

I tried the scanner with another I2C chip I have, and although it didn't find it, it didn't hang. Any tips?

You need pullup resistors on SCL and SDA for I2C to work. Which Arduino are you using?

I'll try that tonight. I was under the impression they were built in on the 328p. I'm using an Atmega328p dip chip on a breadboard.

EDIT: I've previously used I2c with a realtime clock chip without pull-up resistors using the same chip. Hmm...

There are optional weak pullups on most if not all of the input pins on the ATmega328, but they are too weak for most I2C devices, and are not turned on unless you explicitly do so. Use external resistors, 10K minimum.

Some I2C breakout boards have pullups on them, and some I2C devices do work with the optional input pullups, but you should never rely on those.

Thanks jremington. 10k pullup resistors on SDA and SCL indeed helped. I can get some readings out of the device now, but after a few seconds the read call freezes the program again. This is my main challenge with electronics projects: I have no idea how to debug anything! =( Any tips?

I've used the LSM303DLH with no problems so far. Post all your code (using "#") and the program output, up to the point where it hangs. Maybe something will jump out at me.

I'm just running the Calibrate program that comes with the library. Here's the program.

EDIT: One thing I'll note is that I'm using the 8mhz internal clock to reduce footprint. Could this be related?

Looking at this again, I notice that the read hangs when I move the lsm303. If I leave it in the same position it reads continuously. As soon as I change the position, it hangs after a few seconds.

My first suspicious was bad jumper wires or bad breadboard connections, so I ripped out all the jumpers, tested them for continuity, and tested the breadboard itself. Looked ok. I also tried deliberately rustling the jumper wires while the program was running to see if I could tease out any flaky connections I missed. Nothing.

So the program hangs when it changes physical location. Weird right?

I have two of these breakout boards and both behave the exact same way.

Bump. Still stumped on this.

The only think I can think of is a bad connection. I almost never use breadboards and do not trust them at all. I use male headers and make my own jumper cables, similar to the technique described by Emily at Pololu: Pololu Cables and Wires - YouTube