lsm303d.Unable to find lsm303d on 0x1e


#1

I use Raspberry Pi Zero W.
I followed the instruktion at github to install Python library.
I try to run example ./accelerometer.py and ./magnetometer.py and get the following error:
pi@Constantius:~/lsm303d-python/examples ./accelerometer.py Traceback (most recent call last): File "./accelerometer.py", line 9, in <module> xyz = lsm.accelerometer() File "/usr/local/lib/python2.7/dist-packages/lsm303d/__init__.py", line 433, in accelerometer self.setup() File "/usr/local/lib/python2.7/dist-packages/lsm303d/__init__.py", line 371, in setup raise RuntimeError("Unable to find lsm303d on 0x{:02x}, IOError".format(self._i2c_addr)) RuntimeError: Unable to find lsm303d on 0x1e, IOError pi@Constantius:~/lsm303d-python/examples ./magnetometer.py
Traceback (most recent call last):
File “./magnetometer.py”, line 9, in
xyz = lsm.magnetometer()
File “/usr/local/lib/python2.7/dist-packages/lsm303d/init.py”, line 421, in magnetometer
self.setup()
File “/usr/local/lib/python2.7/dist-packages/lsm303d/init.py”, line 371, in setup
raise RuntimeError(“Unable to find lsm303d on 0x{:02x}, IOError”.format(self._i2c_addr))
RuntimeError: Unable to find lsm303d on 0x1e, IOError
pi@Constantius:~/lsm303d-python/examples $

I also run i2cdetcct -y 1 and get:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – -- – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – 1d – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --
Why does the program do not find lsm303d?


#2

How do you have it connected to the Pi?
Male or female header on the lsm303d?
Header soldered on the lsm303d?


#3

I solder the female conector to lms303d.
Mounted it to pin 1,3,5,7,9. 1 - 3V, 3 - SDA, 5 - SCL, 7 - INT, 9 - GND


#4

Have to ask the obvious question, header on the correct way/side and lsm303d not maybe plugged in backwards / reversed?


#5

IO error means i2c is not communicating wit it. i2c detect not finding its address backs that up. Its usually a wiring hookup error. It could be a bad module, have verify its plugged in properly first though.


#6

It wont find the sensor on 0x1e because it’s set to addr 0x1d which is fine, it just means you need to change the example code to supply the right address.

The line:

Should read: lsm = LSM303D(0x1d) and since the default is clearly 0x1d not 0x1e I should probably change the examples to match!

Edit: Fix for this inbound at: https://github.com/pimoroni/lsm303d-python/pull/1


#7

I never would have figured that out, thanks Phil, thumbs up.
I saw the 1d in the i2c detect, I just figured it was something else hooked up to i2c.
That should fix her up and get her going.


#8

:) Thanks gadgetoid ! :)
Your suggestion solved the problem.
Now I’m happy again!// janpih