Page 1 of 1

[Solved] NanoPi Neo Air shutdown button

Posted: Tue May 02, 2017 1:50 pm
by BigChris
I want to use a shutdown button to make a secure shutdown with the nanopi neo air. But i am completly lost how it works. I don't find out, which GPIO's i can use for a script.  And if i need a puuldown or not.
Can somebody help me?


Re: NanoPi Neo Air shutdown button

Posted: Thu May 04, 2017 9:14 am
by chensy
Air does not have a shutdown button.


Re: NanoPi Neo Air shutdown button

Posted: Fri May 05, 2017 4:37 am
by BigChris
I am to stupid to do it like i want, with python that i see for other pi's. But, shell scripts work everywhere an i understand it in most cases. So, here is an solution for my Problem.

I use PIN 18, which Linux GPIO is 201. I pot a pullup resistor (10kOhm) to PIN 17 - 3,3V.
After this, i configure the PIN18.

Code: Select all

echo 201 > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio201/direction

Now i can check the value

Code: Select all

cat /sys/class/gpio/gpio201/value

The answer should be 1.
If now the PIN18 is shorted to PIN 20 (GND), the answer is 0.

A little script does it for me:

Code: Select all

BUTTON=201 # shutdown button

echo "$BUTTON" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$BUTTON/direction

while true ; do
  data=`cat /sys/class/gpio/gpio$BUTTON/value`
  if [ "$data" -eq "0" ] ; then
    shutdown -h now