Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to run python script include GPIO config ?

Featured Replies

Hi,guys!

when I build a pthon3 script with gui and GPIO contorl.I can run it when I use terminal with sudo command.

But when I used "settings->session and startup" to config this script,It can't run when my device reboot (Orange Pi PC).

I try to config command like:

"echo 'password'|sudo -S python3 /home/kwan/OPi_PC/u_main.py"

still the same.

And then I tried to edit "/etc/rc.local" file and add:

"echo 'password'|sudo -S python3 /home/kwan/OPi_PC/u_main.py &"

still the same.

 

The problem is when I run the other script without GPIO config and sudo command.

It can run when device reboot.

 

So,It's there anybody can tell me why & how to make it run with sudo.

I really have no idea about it.

Thx!

 

tried:

@reboot sudo python3 /home/kwan/OPI_PCPLUS/Linux_gate.py > /home/kwan/log.log

Error: no display name and no $DISPLAY environment variable
 

 

 

Hi Kwan Xian,  I don't know which software you use, you might want to checkout this one:

 

Within armbian you find following User-Supported options for GPIO and more:
UserSpaceIO (libgpiod),
pyGPIO accesses 'pins' directly through /dev/mem


 User Space IO is Python 3 and Java 8 bindings for user space GPIO, SPI, I2C, PWM and Serial interfaces
https://forum.armbian.com/topic/6523-user-space-io-is-python-3-and-java-8-bindings-for-user-space-gpio-spi-i2c-pwm-and-serial-interfaces/

 

 pyGPIO - A 'more general' python GPIO library based on pyA20
https://forum.armbian.com/topic/5662-pygpio-a-more-general-python-gpio-library/

 

  • Author
On 1/14/2019 at 5:00 AM, martinayotte said:

It can be workarounded also using setuid on python itself :

 

 

Yes,You'r right.

cp /usr/bin/python3 to /usr/bin/my-python and chmod 4775 /usr/bin/my-python.

config "my-python {script-path}" for startup command.

Now,my py script can run when device reboot.

Thank You!

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.