simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

I2C Problems - Myth or Fact

Mon Jul 14, 2014 12:40 pm

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
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 12:44 pm

What issues are you seeing? I've not noticed any particular problems.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 12:47 pm

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.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 12:51 pm

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
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
Douglas6
Posts: 4783
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 12:54 pm

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

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 12:54 pm

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?

User avatar
Douglas6
Posts: 4783
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 12:59 pm

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.
Last edited by Douglas6 on Mon Jul 14, 2014 1:03 pm, edited 1 time in total.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24162
Joined: Sat Jul 30, 2011 7:41 pm

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 1:03 pm

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)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 1:29 pm

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
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 1:33 pm

@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
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24162
Joined: Sat Jul 30, 2011 7:41 pm

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 1:37 pm

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%
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 1:45 pm

True :)

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

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24162
Joined: Sat Jul 30, 2011 7:41 pm

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 1:47 pm

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!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 1:56 pm

Got any examples of ESD protected code :)
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24162
Joined: Sat Jul 30, 2011 7:41 pm

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 2:12 pm

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.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 3:10 pm

Thought not :)

We all know what "best practice" is but how many people go to that church every week :)
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: I2C Problems - Myth or Fact

Mon Jul 14, 2014 3:11 pm

FTAOD james - I'm just bantering - today is a happy day :)

Normal service will be resumed tomorrow :)
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: I2C Problems - Myth or Fact

Tue Jul 15, 2014 4:03 pm

IOError 5 in Python Smbus is device not found or bus locked up, any number of reasons from bad code, intermittent wiring to gremlins.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

Return to “Python”