I2C Read returns incorrect data while Physical Bus has correct Data.

Ravenholem
Posts: 20
Joined: Wed Nov 10, 2021 7:13 pm

I2C Read returns incorrect data while Physical Bus has correct Data.

Postby Ravenholem » Tue Feb 06, 2024 9:35 pm

I am experiencing a situation very similar to
https://esp32.com/viewtopic.php?t=35508
https://esp32.com/viewtopic.php?t=30427

I am reading data from a DPS310 sensor. I read from it every 1 second.
On average the device runs for 2+ to 3+ hours and then I get an Assert thrown because the value read from the DPS310 does not match what it should be.
I have probed the I2C bus with a MSO scope and I can see the I2C data decoded and it is exactly what I expect, yet the value returned from the I2C read function is wrong.
Physically everything looks good.
I'm running at 100khz using 4k7 resistors.
The I2C SDA/SCL pulses have pretty good edges.
The two issue I have linked to had the same solution in opposite directions. Both changed the clock speed but one from 10k to 100k and the other from 100k to 10k.

I wanted to see if there has been anymore light shed on this issue and what is causing it. Because Physically I can't understand why the I2C peripheral would be clocking wrong data in while everything physically looks perfect on the bus.

Ravenholem
Posts: 20
Joined: Wed Nov 10, 2021 7:13 pm

Re: I2C Read returns incorrect data while Physical Bus has correct Data.

Postby Ravenholem » Wed Feb 07, 2024 2:12 pm

I have tried lowering the i2c clock to 50khz and 25khz and still getting incorrect values returned from the i2c. On the physical Bus the data is correct.

MicroController
Posts: 1725
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: I2C Read returns incorrect data while Physical Bus has correct Data.

Postby MicroController » Fri Feb 09, 2024 12:37 pm

On the physical Bus the data is correct.
Then the problem is likely in your code...

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: I2C Read returns incorrect data while Physical Bus has correct Data.

Postby mbratch » Sat Feb 10, 2024 2:39 pm

I think some details would help.

What ESP32 processor are you using?
What version of ESP-IDF are you using?
What are your I2C port assignments?
Can you show your code that configures the I2C?
Can you show your code that reads the I2C?

Who is online

Users browsing this forum: markkuk and 299 guests