Page 1 of 1

lsm303d problem connect to i2c adresses.

Posted: Tue Jul 21, 2020 12:26 pm
by prem111
Hi, im trying use this driver to connect lsm303d:

https://github.com/kamikaze/pyboard-exa ... /lsm303.py

im have error:

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 68, in <module>
  File "<stdin>", line 31, in __init__
OSError: [Errno 19] ENODEV


i2c scan:

Code: Select all

>>> i2c.scan()
[29]

Re: lsm303d problem connect to i2c adresses.

Posted: Wed Jul 22, 2020 9:09 am
by pythoncoder
Hopefully the author of the driver will respond because I can't square the driver's I2C addresses with the device datasheet.

Your scanned value of 29 is 0x1d which corresponds with the datasheet if the board has the SD0/SA0 pin set high. The driver's ADDRESS_MAG seems to assume that the pin is low. But the driver also has a different ADDRESS_ACCEL which doesn't seem to conform with the datasheet and isn't borne out by your scan. The datasheet and your scan both indicate that the chip has one I2C address only.

Re: lsm303d problem connect to i2c adresses.

Posted: Wed Jul 22, 2020 9:17 am
by pythoncoder
In the absence of a response from the author, you could try replacing lines 5 and 6 with

Code: Select all

    ADDRESS_ACCEL = 29
    ADDRESS_MAG = 29
and see what happens.

Re: lsm303d problem connect to i2c adresses.

Posted: Thu Jul 23, 2020 9:02 am
by prem111
Then it only sees the accelerometer data - the magnetometer does not.

Code: Select all

lsm303 = LSM303D(i2c)
print(lsm303.read())

((20, -204, 1069), (0, 0, 0))

Re: lsm303d problem connect to i2c adresses.

Posted: Thu Jul 23, 2020 3:50 pm
by pythoncoder
In which case there may be other bugs in the driver. Lacking an lsm303d I can't debug this. To get a response from the author you might try raising an issue on GitHub.

Failing a response from the author, your options are to figure it out yourself from the datasheet or to use an IMU with a supported driver. I have written drivers for MPU6050, MPU6150, MPU6250 and BNO055 available here where you will also find drivers for BMX055 and LSM9DS0 (written by Sebastian Plamauer and @xix-xeaon respectively).

Re: lsm303d problem connect to i2c adresses.

Posted: Thu Jul 23, 2020 5:48 pm
by prem111
Thanks for reply.