GPIOs in Rasplex?

Hello everybody,

 

I`m trying to add a shutdownbutton to the pi with this howto: http://www.gtkdb.de/index_18_2237.html

 

But I have the problem that the script stopps with the following error:

File "./shutdownbutton.py", line 7, in 
    import RPi.GPIO as GPIO
ImportError: No module named RPi.GPIO

It seems that python is not able to load the GPIO librarys.

 

Does anybody know how i can access the GPIOs with python running rasplex. 

 

At the moment I`m running Rasplex 0.3.1

I don't think openlec has the GPIO module installed... it is a minimalist build... 

I use a the RemotePi board to power on/off the raspberry with a remote or locally with a button.

It is connected to the GPIO's.

The shutdown script i use is the following:

#!/bin/bash
# prevent restarting XBMC at shutdown
LOCKDIR="/var/lock/"
LOCKFILE="xbmc.disabled"
# this is the GPIO pin receiving the shut-down signal
GPIOpin1=22
# functions
  add_omit_pids() {
    omit_pids="$omit_pids -o $1"  
  }
  safe_shutdown () {
    touch "$LOCKDIR/$LOCKFILE"
    add_omit_pids $(pidof connmand)
    add_omit_pids $(pidof dbus-daemon)
    killall5 -15 $omit_pids
    for seq in `seq 1 10` ; do
      usleep 500000
      clear > /dev/tty1
      killall5 -18 $omit_pids || break
    done
    sync
    umount -a >/dev/null 2>&1
    poweroff -f
  }

echo “$GPIOpin1” > /sys/class/gpio/export
echo “in” > /sys/class/gpio/gpio$GPIOpin1/direction
while [ 1 = 1 ]; do
sleep 1
power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
if [ $power != 0 ]; then
sleep 5
safe_shutdown
fi
done

Got it from here

so it should work for you as well.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.