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

Working, tested with two i2c busses #3803

Merged
merged 1 commit into from Dec 9, 2020

Conversation

skieast
Copy link

@skieast skieast commented Dec 8, 2020

This draft PR demonstrates one fix for the hang with the ESP32S2 when using wifi and i2c. Hang occurs when interrupting a program and resuming. Appears to fix #3743

This code only creates the i2c driver once per i2c controller/bus, never deleting it.

There must be another underlying issue causing this, perhaps inside the ESP IDF.

@jepler
Copy link
Member

jepler commented Dec 8, 2020

Does this allow the pins associated with the I2C device to be used for other purposes?

@skieast
Copy link
Author

skieast commented Dec 8, 2020

Does this allow the pins associated with the I2C device to be used for other purposes?
By that do you mean in the same program? If so I haven't tried that. In a separate program yes as the pins are still setup in the constructor. I will try some more testing tomorrow on a better test setup. Currently everything is hanging from dupont wires and tape.
Following is a snippet of code setting up the I2C. IO17 and IO18 were just convenient pins to use.

i2c = I2C(board.SCL, board.SDA)
while not i2c.try_lock():
    pass
print("I2C board.SCL board.SDA addresses found:", [hex(device_address) for device_address in i2c.scan()])
i2c.unlock()

i2c2 = I2C(board.IO17, board.IO18)
while not i2c2.try_lock():
    pass
print("I2C IO17 IO18 addresses found:", [hex(device_address) for device_address in i2c2.scan()])
print("After scan")
i2c2.unlock()

@dhalbert
Copy link
Collaborator

dhalbert commented Dec 8, 2020

Maybe interesting: here is someone else who is doing install/delete/install, and having trouble: https://www.esp32.com/viewtopic.php?f=2&t=10995&p=44960

@skieast
Copy link
Author

skieast commented Dec 8, 2020

I've tested this with code that uses both i2c peripherals, one with two i2c devices on it. I can interrupt the code with CTRL-C, continue with CTRL-D with no apparent issues. At the same time wifi is pinging some internet address. Also editing code and saving works as expected. I do not know if leaving the wifi driver always installed has any power and deep sleep issues.

@skieast skieast marked this pull request as ready for review December 8, 2020 21:35
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

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

Successfully merging this pull request may close these issues.

ESP32S2 hangs when interrupting running code that includes I2C object
4 participants