I2c problem, error 5 - (also I think new workaround)

Posts: 2
Joined: Wed Oct 11, 2017 2:16 am

I2c problem, error 5 - (also I think new workaround)

Postby sirkotkies » Thu Dec 07, 2017 1:18 pm

Hi Guys,

Hava a problem with I2C bus:


From August to October I was prototyping my device in Arduino IDE. Simply I was using FreeRTOS, Wifi functionality, reading I2C four sensors VL6180. There was a problem wiht I2c which stuck and did not get up (for exampple short SDA to GND or some EMI couse it). Only HW reset could help, SW did not help to solve this - I2C bus was stucked. Then you add Wire.reset() functionality to solve this and this of course help - i simple handle error by reseting I2C bus. It was ok for me beacuse this error occour very rarely (hours or days). Losing data from sensors wasnt a problem couse I'm sampling with 40 times per second (4 xi2c device ). I left it like this - works fine with wifi and I2c. I was using 21/22 pinns fo SDA/SCL

Then i moved to ESP-IDF with arduino as component. Code was pretty much the same, same library. And here started a problem with randomly ERROR 5 I2C every 3 to 10 second. When I did not use WIFI stack there was no such problem. Wire.Reset of course helps but i lost a lot of readings now witch are critical for my device and sampling time as well.

I know a lot of issue on forum with I2C (stickbreaker lib- didnt try, changing I/O pins, Wifi storage change, changing core pined to etc etc) but any could help. I found a workaround for me - is to set 25 priority for task which use I2C bus and this solve my problem - works the same as in Arduino Ide - no error 5. Wifi also works ok with this setting. I suppose it is a problem with sharing some resoureces with wifi stack (maybe ADC2 or smth else). I did not see this workaround with higher priority on forum.

I wrote this maybe it could be a clue

So my question is:

1) Is it ok and safe to set higher priority for task using i2C phi?
2) What is a difference between I2c driver on Arduino IDE and ESP-IDF? I'm sure that there was no problem with error 5 in Arduino ide using Wire lib
3) Are there any more option to solve that?
4) What pins i could use for SDA/SCL and configure to use ADC1 for I2C comunication?

And aslo want to say Hello to everyone- good job here realy appreciate

Thanks in advance

Who is online

Users browsing this forum: llewellyn, WiFive, zcg127 and 7 guests