I recently upgraded an old project and I'm running into problems with the following python script:
[code]import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BCM)
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(27)
if input_state == False:
print('Button Pressed')
subprocess.call(['sh', '/home/me/scripts/calibrate.sh'])
time.sleep(0.9)
[/code]
The script balks on the line:
[code]GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)[/code]
And shows the following error message:
[code]RuntimeError: No access to /dev/mem. Try running as root![/code]
I tired the following. It fixes the problem however the permissions get reset on reboot.
[code]
sudo chown root:gpio /dev/gpiomem
sudo chmod g+rw /dev/gpiomem[/code]
Any suggestions, please?