Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid GPIO pin specified for upboard with ubuntu16.04 and python #685

Open
Sterben1111 opened this issue Aug 24, 2019 · 1 comment
Open
Labels

Comments

@Sterben1111
Copy link

when i tried to run a test program in up wiki to test the board, it told me that " ValueError: Invalid GPIO pin specified"

I don't know what happened, so i think i need some help

error:
Traceback (most recent call last):
  File "light.py", line 11, in <module>
    pin = mraa.Gpio(pin_no,owner=False,raw=True)
  File "/usr/lib/python2.7/dist-packages/mraa.py", line 1122, in __init__
    this = _mraa.new_Gpio(pin, owner, raw)
ValueError: Invalid GPIO pin specified

and the code:

#!/usr/bin/python

import sys
import mraa
import time

# Use pin 7 by default
pin_no = 13

# Export the GPIO pin for use
pin = mraa.Gpio(pin_no,owner=False,raw=True)

# Small delay to allow udev rules to execute (necessary only on up)
time.sleep(0.1)

# Configure the pin direction
pin.dir(mraa.DIR_OUT)

# Loop
while True:
    # Turn the LED on and wait for 0.5 seconds
    pin.write(1)
    time.sleep(0.5)
    # Turn the LED off and wait for 0.5 seconds
    pin.write(0)
    time.sleep(0.5)

Besides, there is the GPIO list:

ls /sys/class/gpio/
export       gpiochip228  gpiochip341  unexport
gpiochip225  gpiochip314  gpiochip414

And I also can not export more new pin in the folder, which confused me a lot and i think it may relate to my question.

Thanks!

@Propanu
Copy link
Contributor

Propanu commented Aug 26, 2019

Hi @Sterben1111, when using raw=True you need to specify the Linux sysfs number for the pin. Set it to False if you want to use the board pin number. You can also use the short form pin = mraa.Gpio(pin_no).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants