Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Seeking advice on using LSM303D w/any Software I2C Library

My Arduino’s I2C Pins are already in non-I2C use.

Is there a library available for the LSM303D that can access the LSM303D via its I2C interface, using one of the “SoftI2C” libraries, so I can access it via my Arduino’s non-I2C Pins?

I’m working through the existing library here:

 [github.com/pololu/lsm303-arduin ... ter/LSM303](https://github.com/pololu/lsm303-arduino/tree/master/LSM303)

to divorce it from its dependency on Wire.cpp and twi.c, and it’s tougher going than I’d like.

Please let me know if you have any suggestions.



There are several collections of software I2C routines for AVR processors. Google will be happy to show you where they are. Try including “bit bang” in the search terms.

More to the point, is there a LSM303D-capable Arduino library, which is not wedded-at-the-hip to the Wire library?

Alas, I did google exhaustively for that, with not much found.


You don’t need a library. It just takes a few lines of code, calling the I2C routines, to read and write the registers. Your time is much better spent understanding the data sheet and writing those few lines, than modifying someone else’s code.

Here is an example of what I mean, kindly provided by the Pololu engineers for an earlier version of the sensor: pololu.com/file/0J436/LSM30 … e-code.zip

Finally, it might be easier to use the I2C hardware pins for this, and change whatever else needs to be changed to free them up, than incorporate bit-bang code.