BBB GPIO Python Library Issue

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
thiro
 
Posts: 3
Joined: Mon Nov 11, 2013 7:34 am

BBB GPIO Python Library Issue

Post by thiro »

Hello,

I am having issues getting the GPIO library to work using the python. I have followed all the tutorials and double checked my code, so I decided to come here for help.

I have installed Ubuntu 12.04 Precise, and booting from the microsd card. I believe Adafruit_BBIO library itself has been installed correctly because my teammates have been able to successfully use UART and I2C (although, to get UART working my teammate has to run "echo ADAFRUIT-UART1 | sudo tee /sys/devices/bone_capemgr*/slots" at every bootup). I have made sure to run all install steps and all code as a super user, and have updated/upgraded the Adafruit library and the OS in general. At this point I'm sure it is something silly that I am forgetting.

Here is my tutorial-esque code that I cannot get working.

Code: Select all

import Adafruit_BBIO.GPIO as GPIO
import time

GPIO.setup("GPIO1_6", GPIO.OUT)

while True:
    GPIO.output("GPIO1_6", GPIO.LOW)
    time.sleep(1)
I am using a multimeter to monitor the voltage. By default, it appears the output voltage is 3.3V. However, nothing changes after running the code (I am running it as a super user). To make sure that I wasn't accidentally using the wrong pin, I tested every single pin while keeping the set up pin (above GPIO1_6) constant. After that, I tried using different pins all over the BBB.

Other quirks I noticed. If I set it up as an input it will always read "0" no matter what voltage I put in.

I have worked on this all weekend and I am at a loss. It seems as if, so I'm assuming there is an important step I have forgotten. Any help will be appreciated.

Thank you

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: BBB GPIO Python Library Issue

Post by adafruit_support_rick »

I'm no BBB expert, but I see that the tutorial for blinking an LED is using a different notation for GPIO pins than you are:
http://learn.adafruit.com/blinking-an-l ... -a-program

perhaps you could try P8_3 instead, which I believe represents the same pin as GPIO1_6.

thiro
 
Posts: 3
Joined: Mon Nov 11, 2013 7:34 am

Re: BBB GPIO Python Library Issue

Post by thiro »

I believe either form of pin notation should work, but I have tried both forms. I got the same result.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: BBB GPIO Python Library Issue

Post by adafruit_support_rick »

Try a different pin, like P8_10?
Try a different jumper wire?

thiro
 
Posts: 3
Joined: Mon Nov 11, 2013 7:34 am

Re: BBB GPIO Python Library Issue

Post by thiro »

adafruit_support_rick wrote:Try a different pin, like P8_10?
Try a different jumper wire?
I was about to say I tried that pin and the different jumper wire, but then realized I never tried the combination of a different pin with the other pin form. P8_10 worked! Thank you very much!

I don't know why the other pin form didn't work, but it said here http://learn.adafruit.com/setting-up-io ... black/gpio that referring to the alternative names should work. I don't know if that is a mistake or an issue with my specific set up, but I figured you should be aware.

Again, thank you very much for all your help. I figured it was something silly.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: BBB GPIO Python Library Issue

Post by adafruit_support_rick »

Can you please post an issue on the github repository, including the code that doesn't work?

nimrodx
 
Posts: 1
Joined: Fri Nov 15, 2013 11:15 pm

Re: BBB GPIO Python Library Issue

Post by nimrodx »

Hi All

I'm running a BBB with ubuntu.

I've got pin 14 on header 8 running as a GPIo output
sudo -s
echo 26 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio26/direction

This works great.

However, when I try to do the equivalent with the Adafruit lib, it fails:
import Adafruit_BBIO.GPIO as GPIO
GPIO.setup("GPIO0_26", GPIO.OUT)
GPIO.output("GPIO0_26", GPIO.HIGH)
GPIO.output("GPIO0_26", GPIO.LOW)

it does nothing -- it does not even give an error.
The adafruit lib is working well for ADC.

Any ideas?
Is there soemthing missing from these instructions:
http://learn.adafruit.com/setting-up-io ... io-library

Thanks for your help.

Matt

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: BBB GPIO Python Library Issue

Post by jwcooper »

Hey Matt and thiro,

Could you try running the test suite that is part of the library? That might better explain what's failing, and where.

You can find instructions on how to run the test suite at the bottom of this file:
https://github.com/adafruit/adafruit-be ... README.rst

Also, generally Angstrom has been better supported by this library (and the BeagleBone team). There have been issues that continually pop up with each new Ubuntu release that take some time to fix. GPIO has usually been unaffected though, so this is a bit odd.

Also, where did you download your version of Ubuntu, and which kernel version are you using?

Justin

Shaolin
 
Posts: 1
Joined: Sat Nov 23, 2013 2:55 pm

Re: BBB GPIO Python Library Issue

Post by Shaolin »

Having the same issue, but it works fine when I'm running 'sudo python' instead of just 'python'. Maybe that's the case?

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: BBB GPIO Python Library Issue

Post by jwcooper »

Yup, 'sudo python' is required when using this library. Thanks for bringing that up!

Justin

User avatar
charlesh-nyc
 
Posts: 7
Joined: Wed Jul 17, 2013 11:20 pm

Re: BBB GPIO Python Library Issue

Post by charlesh-nyc »

Re. using "sudo python" with the AdaFruit library... May I suggest adding that instruction to this tutorial, at least:

http://learn.adafruit.com/connecting-a- ... k?view=all

There are probably other tutorials where this is relevant, too. But this is one where I was banging my head for hours trying to make it work. It seems that some flavors of Ubuntu -- 12.04, for example -- don't require sudoer privileges to run the script. So, I could get the tutorial to work in 12.04, but not in Ubuntu 13.10, which is my target environment. Since I kept duplicating the exact steps on 12.04 -- where the AdaFruit tutorial worked -- onto 13.10 -- where it didn't work, I was flummoxed until I saw this forum thread. Now all's good.

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: BBB GPIO Python Library Issue

Post by jwcooper »

I've added an alert to the page to make it clear that Ubuntu and Debian may need to run Python as 'sudo' to access GPIO. Thanks for the link to the guide that caused the confusion!

http://learn.adafruit.com/connecting-a- ... on-console

Justin

User avatar
chuckiev
 
Posts: 6
Joined: Mon Jan 06, 2014 11:29 pm

BBB GPIO Python Library Issue Import command does not exist

Post by chuckiev »

Hello,

I am working through the BBB Python Library installation tutorial and when it tells me:


To start, you'll want to import the libary. There are two different options at this time to import. The first one is for GPIO:
Copy Code

import Adafruit_BBIO.GPIO as GPIO

ubuntu says:

ubuntu@arm:~$ import Adafruit_BBIO.GPIO as GPIO
-bash: import: command not found

I've tried this as sudo as well, same error:

ubuntu@arm:~$ sudo import Adafruit_BBIO.GPIO as GPIO
[sudo] password for ubuntu:

sudo: import: command not found

Is there another command for import or did I miss something in the instructions?

Thank you,

Chuck

sudo: import: command not found
ubuntu@arm:~$

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: BBB GPIO Python Library Issue

Post by jwcooper »

Hey,

You'll want to run those commands from within a python interpreter or from within a python file.

To run the python interpreter, type at the command line:

Code: Select all

python
Then, you can copy and paste those commands to test them out.

User avatar
chuckiev
 
Posts: 6
Joined: Mon Jan 06, 2014 11:29 pm

Re: BBB GPIO Python Library Issue

Post by chuckiev »

Disregard my last post. I found the python editor. Fredo Corleone again, I''m smart not like other people say!

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”