Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan does, driver doesn't find chip #18

Closed
muranyia opened this issue Mar 14, 2022 · 15 comments
Closed

Scan does, driver doesn't find chip #18

muranyia opened this issue Mar 14, 2022 · 15 comments

Comments

@muranyia
Copy link
Contributor

muranyia commented Mar 14, 2022

I have a custom build Adafruit CircuitPython 7.3.0-alpha.0-38-g862210b3f-dirty on 2022-03-13; Adafruit Trinket M0 with samd21e18 with 24lc32 frozen.

I can find the chip via I2C scan at the address 0x50 but the driver doesn't find it there.

import board
import time
import adafruit_24lc32
import supervisor

supervisor.disable_autoreload()

i2c = board.I2C()

#  scan I2C
while not i2c.try_lock():
    pass
try:
    while True:
        print(
            "I2C addresses found:",
            [hex(device_address) for device_address in i2c.scan()],
        )
        time.sleep(1)
finally:  # unlock the i2c bus when ctrl-c'ing out of the loop
    i2c.unlock()

#  setup for EEPROM
eeprom = adafruit_24lc32.EEPROM_I2C(i2c_bus=i2c)

I2C addresses found: ['0x50']


Traceback (most recent call last):
  File "code.py", line 24, in <module>
  File "adafruit_24lc32.py", line 240, in __init__
ValueError: No I2C device at address: 0x50

@tekktrik
Copy link
Member

Does that code work if it's not baked into the UF2?

@muranyia
Copy link
Contributor Author

After adding adafruit_bus_device too, I get:


Traceback (most recent call last):
  File "code.py", line 49, in <module>
  File "adafruit_24lc32.py", line 240, in __init__
  File "/lib/adafruit_bus_device/i2c_device.py", line 61, in __init__
  File "/lib/adafruit_bus_device/i2c_device.py", line 183, in __probe_for_device
ValueError: No I2C device at address: 0x50

Latest firmware and bundle.

@muranyia
Copy link
Contributor Author

I noticed that i2c.scan() picks up the chip only on a fraction of the tries. I'm new to i2c so I thought it was normal but an mcp23017 is picked up on every try so I suspect this is not the right behavior. I think the pulls are OK: addresses and WP are pulled down directly, SCL and SCK are pulled up through 5k resistors.
Could it be a faulty chip, or is my circuit wrong, or...?

@FoamyGuy
Copy link
Collaborator

@muranyia if your up for it I would recomend to join our discord https://adafruit.it/discord there is a help-with-circuitpython channel where you can get help troubleshooting things.

can you post a picture of your wiring? also let us know what specific device you are connecting to, is it this? https://www.adafruit.com/product/5146

@muranyia
Copy link
Contributor Author

The device is a bare DIL 24lc32a and the wiring is like this.
Never used discord but I'll try to figure it out.

@muranyia
Copy link
Contributor Author

No reply on discord...
I figured out that once I connect an ssd1306 device to the bus, the 24lc32 gets picked up too.
When I disconnect the clock pin of the ssd1306 the board loses the 24lc32 too.
Tried with a Trinket M0 and a Feather M4 Express, same behavior.

@muranyia
Copy link
Contributor Author

muranyia commented Apr 6, 2022

Tried with different pullups, no dice. The question is, what does the ssd1306 do to the bus that makes it work?

@tekktrik
Copy link
Member

tekktrik commented Apr 6, 2022

Wait, SCK? Did you mean SDA?

@tekktrik
Copy link
Member

tekktrik commented Apr 6, 2022

You could also try 10k resistors. Also try another 24LC32 as well just to rule out something wrong with that unit.

@muranyia
Copy link
Contributor Author

muranyia commented Apr 6, 2022

Yes I meant SDA... sry. Will try with 10k. 5k and 2k didn't work.

@tekktrik
Copy link
Member

tekktrik commented Apr 6, 2022

You could also try changing the frequency using the frequency argument:

i2c = busio.I2C(board.SCL, board.SDA, frequency=50000) # Set frequency to 50 kHz

Not sure if that will work, but it's something to try.

@muranyia
Copy link
Contributor Author

muranyia commented Apr 6, 2022

frequency=50000 throws Unsupported baudrate. N.B. with the ssd1306 connected I had no problems going up to 400kHz. I only have an issue when the ssd1306 is not on the bus.
But! The 10k pullups seem to work. I test a few things (my display is not working right now) and if everything is fine I will come back to close the issue.

@tekktrik
Copy link
Member

tekktrik commented Apr 6, 2022

Sounds great! Glad it's working out so far!

@tekktrik
Copy link
Member

Did your tests end up working out?

@muranyia
Copy link
Contributor Author

Couldn't test extensively but len() gives the right length so I assume everything is fine. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants