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?
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.
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.
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