Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GPIO access

Featured Replies

After reading several threads without success I need to ask again how I can get permission as a "normal" user to use the GPIO pins via my python script:

#!/usr/bin/python
import time

PIN_NUM = 200


print "GPIO %s" % PIN_NUM

try:
   # check to see if the pin is already exported
   open(''.join(['/sys/class/gpio/gpio',str(PIN_NUM),'/direction'])).read()
except:
   # it isn't, so export it   
   open('/sys/class/gpio/export', 'w').write(str(PIN_NUM))

# set gpiochip198 to output
open(''.join(['/sys/class/gpio/gpio',str(PIN_NUM),'/direction']), 'w').write('out')

for i in range(1000):
   open(''.join(['/sys/class/gpio/gpio',str(PIN_NUM),'/value']), 'w').write("1")
   time.sleep(0.5)
   open(''.join(['/sys/class/gpio/gpio',str(PIN_NUM),'/value']), 'w').write("0")
   time.sleep(0.5)

# remove GPIO87 folder from file system
open('/sys/class/gpio/unexport', 'w').write(str(PIN_NUM))

 

 

I get this error:

Traceback (most recent call last):
  File "testGPIO.py", line 17, in <module>
    open(''.join(['/sys/class/gpio/gpio',str(PIN_NUM),'/direction']), 'w').write('out')
IOError: [Errno 13] Permission denied: '/sys/class/gpio/gpio200/direction'

 

So I tried to add:

SUBSYSTEM=="gpio", ACTION=="add", RUN="/bin/sh -c '\
        chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
        chown -R root:gpio /sys$DEVPATH && chmod -R 770 /sys$DEVPATH\
'"

into /etc/udev/rules.d/90-gpiomem.rules

 

and yes my username is the GPIO group....

 

Can someone help me further...thx

 

Andy

 

 

 

 

 

  • Author

thx for the link but still I get the same error....

 

Andy

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.