lucidfaya Posted August 16, 2017 Posted August 16, 2017 Hello :D! Im new customer of Orangepi board. My board: ORANGE PI PC. I have a question, some one have a guide or have try to create a script for make a button ON - OFF on GPIO on this board? I have try with ETA PRIME GUIDE FOR RASPBERRY PI 3 (u can find on youtube) but this guide is for raspberry pi 3, and dont work on orange pi. I have install this GPIO for orange pi from this guide : http://www.instructables.com/id/Orange-Pi-One-Python-GPIO-basic/?fref=gc I need really to put button on gpio and make on off board from here, very tnx at all!
StuxNet Posted August 16, 2017 Posted August 16, 2017 For personal simplicity I would git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 Setup whatever pin you're connecting the switch to using the PYA20 library's (above) example code as seen here: https://pypi.python.org/pypi/pyA20 Use that library read the switch. For example: If pin high/low or on/off, use python subprocess or os.system functions to run linux shutdown, reboot command. I might be able to give you a sample script or more concise instructions but don't hold your breath. For now I'll give you this, which is a pretty damn good start for having not really started This is a script I was using on a NanoPiNeoAir using a reed (magnetic) switch attached to a door but could be easily changed to suit your needs. I've commented out the stuff that you won't need but much of the variable names are the same soo.... pretend the door is your switch! Or you can change the prompts/names yourself.https://gist.github.com/BiTinerary/2734ac46e80af2b1a2158c9f0ba79e25 P.s. You'll need to specify the pin you're using for your button but if you use my script in tandem with the tutorial you link to (replace LED with switch) it should 'technically' work. Hack away at it, see what you can come up with and report back. Also..... you have heatsinks on your RAM dies but not your CPU? Sup with that? 1
lucidfaya Posted August 22, 2017 Author Posted August 22, 2017 Hello man! very tnx for your help! i use pin 5 and 6 for the button, i have try to look your script but is too complicate for me :'(
StuxNet Posted August 22, 2017 Posted August 22, 2017 I made it simpler by renaming some stuff and omitting extra crap from previous project so check the link again. That's about as simple as it gets. You really only need to read lines 27-38.https://gist.github.com/BiTinerary/2734ac46e80af2b1a2158c9f0ba79e25#file-shutdownswitch-py-L27-L38 The script simply put, checks every second to see if the GPIO (that you still have to change on line 8) pin is pulled high or low, up or down. If pulled high, send shutdown command. If low, do nothing. Continue the loop. If those ten lines of code are too complicated then I can't help you. Read up on programming. I can suggest some pretty good books. Keep in mind that I can't remember if my reed switch defaulted to open or closed so the high/low might be switched around for you. This simply means that when you run the script if the button isn't pressed it might print "Shut Down Computer!" instead of doing nothing. If this is the case for you, simply swap lines 33 and 36. Debug with print statements so that you're not unintentionally shutting down your OPi PC. Lemme know how it goes.
Schmurtz Posted April 25, 2018 Posted April 25, 2018 An easy alternative using the button on the motherboard of the Orange PI PC : http://forum.lemaker.org/thread-2982-1-1.html
Igor Posted April 25, 2018 Posted April 25, 2018 1 hour ago, Schmurtz said: An easy alternative using the button on the motherboard of the Orange PI PC : http://forum.lemaker.org/thread-2982-1-1.html ... which of course doesn't work.
Schmurtz Posted April 25, 2018 Posted April 25, 2018 4 hours ago, Igor said: ... which of course doesn't work. ... but can "easily" work I add a link to my topic here (I use pyA10 library but may be pyA20 is better ?)
Igor Posted April 25, 2018 Posted April 25, 2018 No. This board lack hw part which is present on A10-A20-A64 ... a proper PMU (AXP chip) which can power on/off ... here this is done via special close sourced part of the H3 chip which can do some hybrid deep sleep/wakeup.Wrote on mobile
Recommended Posts