Ask Your Question
1

I2C problem with remote Raspberry pi

asked 2017-03-05 20:41:00 -0600

dgoadby gravatar image

updated 2019-03-13 10:20:46 -0600

I am running WingIDE6.0 remotely connected to a Raspberry Pi. I can run a normal program no problem so I know it works. I have a program that imports smbus for I2C access. The program runs fine from the RPi console but,when I run it using Wing IDE I get an error which is:

IOError: [Errno 13] Permission denied.

Now, I can see that is it a permissions issue - but why? I have added the user to the i2c group but that didn't change things. The Wing IDE connection is SSH with keys (is no password) and it is the same user as the RPi login so there should not be a problem with permissions.The actual instruction that fails is:

 self._bus = smbus.SMBus(twi)

If this is a restriction for some reason then I'm stuck as I do a lot of native I/O on the RPi.

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
1

answered 2017-03-06 13:06:00 -0600

dgoadby gravatar image

updated 2019-03-07 07:03:56 -0600

Wingware Admin gravatar image

Ok, now were are sorted! And permissions is the problem. A quick fix is to change the permissions of /dev/i2c-1  or /dev/i2c-0  (depends on rpi model) with the command:

sudo chmod a+rw /dev/i2c-*

This is temporary and is lost at next boot so, to fix it permanently you need to do the following:

Edit the file /etc/udev/rules.d/99-com.rules

If this line exists:

SUBSYSTEM=="ic2-dev", GROUP="i2c", MODE="0660"

then change the MODE to "0666".

If it does not exist then add it with the MODE="0666" and also note the "==".

Reboot.

NOTE: My system is RPi3. For other variants the file in /etc/udev/rules.d may have a different name so check them all to find the one with the entry you need to change.  Also, the entry may say KERNEL instead of SUBSYSTEM depending on you Debian version. The important thing to find is the line with "i2c-dev" in it. After making the above changes you can use WingIDE on RPi with i2c devices actually working natively. For debugging it's worth every penny.

Following on from my experiences with i2c, the situation is much the same for GPIO, and the fix much the same.The "quick fix" is: sudo chmod a+rw /dev/gpiomemFor the permanent fix the entry will be something like SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660".  As before change the MODE to "0666".That's it, i2c and GPIO working with WingIDE.

If you happen to need the spi bus then, assuming you have enabled it using sudo raspi-config, you will need to make the same changes to the entry with "spidev" in it.

David

edit flag offensive delete link more

Comments

Thanks for posting this!  You may want to select this answer as the accepted answer for this question.

Wingware Support gravatar imageWingware Support ( 2017-03-07 14:35:00 -0600 )edit
0

answered 2017-03-05 22:05:00 -0600

dgoadby gravatar image

updated 2019-03-07 07:02:18 -0600

Wingware Admin gravatar image

Actually I'm not running as sudo. Earlier i2c implementations did require sudo or equivalent but I'm just running the program using: python test-prog.py as per normal. It's 3am in the UK so I'm off top bed now but, when I return to the problem later today I will just check the permissions. 

The article you referenced is dated 12/2015 and that referred to a 2012 article so it is probably before the later smbus implementation but I will check and report back.

Thanks for a speedy reply BTW.

David

edit flag offensive delete link more
0

answered 2017-03-05 21:03:00 -0600

My guess is when you're logged into the Raspberry Pi you are running the code with sudo and this is not being done by Wing's remote agent.  Probably the solution is setting access permissions so the user can access it without sudo.  The selected answer for http://stackoverflow.com/questions/34... and the document it links to may be what you need.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-03-05 20:41:00 -0600

Seen: 259 times

Last updated: Mar 07