-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ESP32-S2 I2C getting stuck in write loop after first ACK #5470
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
Comments
I'm using a SSD1306 OLED display on a ESP32S2-Saola-1 board, with the same 2.0.0-rc1 core version, and the I2C works fine, using the Adafruit SSD1306 library. |
After checking this board schematics and Wire library i would say it is expected it wont work. What is interesting is that you are getting anything with logic analyzer. My suggestion is to:
|
Wouldn't it end up using the pins defined in the variants file: arduino-esp32/variants/adafruit_funhouse_esp32s2/pins_arduino.h Lines 42 to 43 in a4118ea
when it gets here for SDA: arduino-esp32/libraries/Wire/src/Wire.cpp Line 77 in a4118ea
and here for SCL: arduino-esp32/libraries/Wire/src/Wire.cpp Line 94 in a4118ea
|
@caternuson Yes, as long as you pick the correct board variant. |
The Arduino IDE was set to Tools -> Board -> ESP32 Arduino -> Adafruit FunHouse. Is there an additional step? |
That should be enough, but just in case i would test i2c_scanner with explicit pins in PS never trust code that you didnt write and test personally, including all libraries and arduino-esp32 |
@caternuson I dont have this board, so my question:
I did some test with custom board that is using native USB and I2C on pins 16/17 works fine, then i changed I2C pins to 33/34 and code stuck. Next test i performed with saola and both tests passed. @me-no-dev I am suspecting some conflict between I2C on particular pins and native USB. @caternuson Could you perform one more test (it may be not easy):
|
@chegewara Thanks for looking at this. Yep, it's native USB. Here's what the Arduino IDE looks like with RC1: Sorry, not sure I follow your suggested next test. Tried switching to the UART0 option, but seeing the same results in the logic analyzer. Were you suggesting something else? Happy to test whatever. Also, FWIW, the only other ESP32-S2 board I currently have access to is an Unexpected Maker FeatherS2. |
Actually i want to correct myself. Previous test was without any I2C device connected.
To make sure my tests are full i also tested with esp-idf example on master branch and all works fine. |
@caternuson It is bug in arduino-esp32 and has to be fixed |
@chegewara Thanks. Need any more info or tests from me? |
@me-no-dev I think this is breaking PR, but didnt confirmed yet: |
@caternuson There is simple temporary fix for the issue that allows to run scan and probably I2C too.
|
@chegewara That seems to work. I tweaked the scanner sketch slightly to have the begin call just be: Wire.begin(); just to test that the variant info is working as expected as well. With your BSP changes above, now get this (expected) output in Serial Monitor: |
|
yes, but i am not sure if this is complete fix, tested only with i2c_scanner |
at least it fixes scan :) I would have thought that IDF would handle this situation... |
@chegewara want to add this fix as PR? |
Thats possible. I tested IDF with this example just to perform scan: Since the fail is when IDF function is performing write with 0 length buffer it may be issue with IDF.
no, thanks but no. i feel offended by espressif, so no more PRs |
@caternuson |
@caternuson This PR will be merged to main line soon, replacing #5528 |
@SuGlider Tested #5664 and it works with an I2C scanner and the DPS310 test sketch if original post above. Just to make sure I tested correctly, here are the general steps taken:
|
Yes, perfect. Thanks for taking time to test it and report back here! |
Hi could you please re-test with this new PR: #5683 |
@me-no-dev Tested #5683 on Funhouse with I2C scanner sketch and DP310 test sketch. Same basic tests as above. Both sketches ran as expected. |
Thanks @caternuson ! |
Hardware:
Board: Adafruit FunHouse
Core Installation version: 2.0.0-rc1
IDE name: Arduino IDE 1.8.13
Flash Frequency: 80Mhz
PSRAM enabled: yes
Upload Speed: 921600
Computer OS: Ubuntu
Description:
Can not initialize the included I2C sensors (DPS310 and AHT20). Attempting an I2C scan results in board reset cycling.
Sketch:
You can probably see this by using any ESP32-S2 board, wiring up something to I2C, and running the I2C scanner sketch.
Example shown here is for attempting to directly use the DPS310 sensor, which is at
0x77
. Library here.Debug Messages:
This is a run time issue. Code compiles and uploads fine. Serial monitor output FWIW:

Here is what is happening on the I2C bus. A write is initiated and the sensor ACKs:

Then it goes into an infinite loop writing out

0x00
.Those
0x00
writes only stop when the board finally resets at some point.The text was updated successfully, but these errors were encountered: