Page 1 of 1

I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 12:40 pm
by simplesi
I have a bit of trouble using I2C devices and Python.

Is it just me or is are there some issues?

Are they hardware/software issues

Can they be overcome at my level (Python programmer) or do they need better libraries e.g SMBus or changes in the kernel.

or is it just me :)

Simon

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 12:44 pm
by joan
What issues are you seeing? I've not noticed any particular problems.

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 12:47 pm
by Richard-TX
simplesi wrote:I have a bit of trouble using I2C devices and Python.

Is it just me or is are there some issues?

Are they hardware/software issues

Can they be overcome at my level (Python programmer) or do they need better libraries e.g SMBus or changes in the kernel.

or is it just me :)

Simon

It is just you.

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 12:51 pm
by simplesi
My main issue is getting Err 5 and having to restart my python scripts (or lots of try/excepts)

My most recent experience is with Nunchucks doing this but had problems with the likes of Adafruit matrixes

Simon

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 12:54 pm
by Douglas6
There seems to be a problem with I2C in the silicon, so no fixes but some workarounds. Dedicated I2C devices have fewer problems than microcontrollers. See this post with a link and some advice: http://www.raspberrypi.org/forums/viewt ... 27#p554127

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 12:54 pm
by joan
simplesi wrote:My main issue is getting Err 5 and having to restart my python scripts (or lots of try/excepts)

My most recent experience is with Nunchucks doing this but had problems with the likes of Adafruit matrixes

Simon
Is this why you wanted to restart Python scripts?

Is this an error from the Python smbus module? Do you know what Err 5 means?

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 12:59 pm
by Douglas6
simplesi wrote:problems with the likes of Adafruit matrixes
I haven't experienced any problems with basic I2C expander chips like those matrices. IO exception handling is always good practice.

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 1:03 pm
by jamesh
ISTR a problem with clock stretching, so turn that off if you can.

(I don't actually know what that is, just that there was a problem)

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 1:29 pm
by simplesi
This thread seems to have a lot of info on the issue

http://www.raspberrypi.org/forums/viewt ... p?p=146272

Bottom line seems to be - expect errors now and then and program around them

Ta

Simon

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 1:33 pm
by simplesi
@joan
Yep - that's why I was asking about restarting :)

I don't know whay error 5 is - just that when I get it - game is usually over :)

Simon

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 1:37 pm
by jamesh
simplesi wrote:This thread seems to have a lot of info on the issue

http://www.raspberrypi.org/forums/viewt ... p?p=146272

Bottom line seems to be - expect errors now and then and program around them

Ta

Simon
You should always be programming around communication HW errors anyway - no communication is 100%

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 1:45 pm
by simplesi
True :)

But I'm used to GPIO reliabity - I've had it too good for too long :)

Simon

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 1:47 pm
by jamesh
simplesi wrote:True :)

But I'm used to GPIO reliabity - I've had it too good for too long :)

Simon
GPIO are prone to ESD, so you should really be protecting the code there as well!

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 1:56 pm
by simplesi
Got any examples of ESD protected code :)

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 2:12 pm
by jamesh
simplesi wrote:Got any examples of ESD protected code :)
Standard hysteresis stuff - see how long the pins stay in a changed state before assuming that they have actually changed state. That will help eliminate ESD spikes.

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 3:10 pm
by simplesi
Thought not :)

We all know what "best practice" is but how many people go to that church every week :)

Re: I2C Problems - Myth or Fact

Posted: Mon Jul 14, 2014 3:11 pm
by simplesi
FTAOD james - I'm just bantering - today is a happy day :)

Normal service will be resumed tomorrow :)

Re: I2C Problems - Myth or Fact

Posted: Tue Jul 15, 2014 4:03 pm
by techpaul
IOError 5 in Python Smbus is device not found or bus locked up, any number of reasons from bad code, intermittent wiring to gremlins.