Problem: Argon One case with 'power' button - config script fails to install
|
5th Nov, 2020, 12:57 AM
Post: #9
|
|||
|
|||
RE: Argon One case with 'power' button - config script fails to install
Hello,
I am trying to install a power switch on a RP4 device and here is the list of the steps I took manually, if you wish to have a go. It is based on various instructions, mainly here to setup the switch and here to install the library. I have the switch detected and I can access it by the python console but I am still looking at an efficient way to start the script during the boot sequence, as systemd does not seem to work. Anyway, to install the tool you need to access GPIO from python scripts you can do the following. Start by the packages: Terminal sudo apt-get install python-dev python3-dev sudo apt-get install mercurial sudo apt-get install python-pip python3-pip sudo apt-get install python3-setuptools sudo apt-get install gcc-arm-linux-gnueabihf Then you should be able to install the GPIO library. The version in the repository does not work for the raspberry pi versions higher than 1 so you need to install from the source repo: Terminal python3 -m pip install wheel python3 -m pip install hg+http://hg.code.sf.net/p/raspberry-gpio-python/code#egg=RPi.GPIO Apparently there is a kernel bug that prevents accessing the GPIO library without being root (see here and here), so you need to create a rule.d config: Quote:Create /etc/udev/rules.d/90-gpio.rules with: Then add a new group to manage the GPIO port and add the user to it: Terminal sudo groupadd -f --system gpio sudo usermod -a -G gpio $USER Note that this worked to some extent for me but I still encountered some issues when not using root, so I still use sudo for all the rest. Once you have these done you can write your python script to switch off the device, I got mine from there with some modifications to make it operate on the correct GPIO pin (pin 5, or equivalently GPIO3): Code: #!/usr/bin/env python3 When running this code from the terminal, the power switch operated correctly and switched off the device. Using pin 5 also makes it possible to use the same switch to power up the RP4. I only need to put this script in the boot sequence now, I will try init.r (there are some instructions here). I hope this helps. Just to update, init.d seems to be working, the steps are here (method 3). Add a header to the file: Code: #!/usr/bin/env python3 then save it at /etc/init.d/, make it accessible and update the system: Terminal sudo cp ./shutdown_interrupt.py /etc/init.d/ sudo chmod +x sample.py sudo update-rc.d sample.py defaults It is now working for me, I have a start/stop switch on my RP4 happy times.... |
|||
« Next Oldest | Next Newest »
|
Possibly Related Threads... | |||||
Thread: | Author | Replies | Views: | Last Post | |
[PROBLEM] Argon One M.2 Case Gpio Script | Thundersun | 3 | 3,273 |
21st Feb, 2024 03:33 AM Last Post: barbarajameson |