adafruit / Adafruit_Python_Extended_Bus

Helper Library for Blinka to allow creating I2C and SPI busio objects by passing in the Bus ID
MIT License
33 stars 3 forks source link

i2c.scan() find less devices than i2cdetect #6

Closed MkLHX closed 2 years ago

MkLHX commented 3 years ago

Hello, i'm using i2c on many projects and during a test i'm facing an issue.

Un ran the code on raspberry pi 3 A+ python 3.7

with this code example:

from adafruit_extended_bus import ExtendedI2C as I2C

scan_list = list()
with I2C(3) as i2c:
   scan_list = i2c.scan()
print(scan_list)

i found only 4 devices:

[35, 72, 100, 101]

But on my device i know there is 5 devices on the i2c bus number 3.

i2cdetect -y 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- 64 65 -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

i2c.scan() return decimal addresses and i2cdetect hexa hex 23 => dec 35 => bh1750 hex 48 => dec 72 => ads1015 hex 64 => dec 100 => atlas OEM Conductivity hex 65 => dec 101 => atlas OEM pH

missing hex 44 => dec 68 => sht40

how to do more tests to pointing where the issue from?

I'm trying to find an other way to test i2c scan on python with bus number instead of board.pin

MkLHX commented 3 years ago

please @makermelissa @mcauser can you take a look at this

makermelissa commented 3 years ago

How is your I2C port 3 configured? The only thing this library does is bypass the pin scanning code for initialization and the scanning is all handled in Blinka.

MkLHX commented 3 years ago

Hi @makermelissa thx for your reply.

this how i set my i2c busses on raspberry pi.

dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=22,i2c_gpio_scl=16
dtoverlay=i2c-gpio,bus=1,i2c_gpio_delay_us=1,i2c_gpio_sda=2,i2c_gpio_scl=3

but i think the problem isn't that because i'm facing this issue only on unit test about scan i2c bus and in prod i have this issue.

Yeah i know what the goal of this library and that why i use it on many i2c drivers.

just i wondering why i'm getting this strange behavior on scan() call

Tuxliri commented 2 months ago

Hi @MkLHX I am getting the same behavior when using a tca9548 multiplexer, how did you manage to solve it?