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.

Accessing GPIO pins

Featured Replies

Hello,

 

I have installed ARMBIAN 5.60 stable Debian GNU/Linux 9 (stretch) 4.14.70-sunxi on a Banana Pi M2+ and I need to read and write to the GPIO pins from a bash script, does anyone have a workable solution?

 

I tried with an Orange Pi in the past and I compiled a binary to access the gpio values but it did not work and I cannot find that source any more.

 

Thanks in advance. 

 

  • Author
On 11/2/2018 at 11:43 PM, martinayotte said:

The simplest way is to use gpio sysfs ...


echo 20 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio20/direction
echo 1 > /sys/class/gpio/gpio20/value

Thank you Martinayotte, I have had limited success with this approach and it requires superuser privileges which makes it a bit risky for me to call from the web server, but then I may be able to work out a secure way to access that interface.  The "gpio" command from the WiringOP github repo seems to be very promising as well.

Thank you Martinayotte, that is very helpful.  The difficulty I found is that it required superuser permissions and I managed to get the gpio utility compiled and finally working late last night and it does not require superuser permissions 

On 11/2/2018 at 8:43 AM, martinayotte said:

The simplest way is to use gpio sysfs ...


echo 20 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio20/direction
echo 1 > /sys/class/gpio/gpio20/value

 

Hi,I am a developing a c++ application with OPI 0+2 (h5 + mainline kernel), controls a motor with an encoder and a driver. I did it , but it consume to much cpu power (%8) . I could access with using sysfs and character device. Both of them works like open->read->close .Actually it works very well with polling. Unfortunately consume to much cpu. Interrupt freq around 6600hz (150 us) . Is there anyway to control interrupt with dev mem? Or could anyone give me a startup point to access (c++) gpio interrupts efficiently. Btw i tyied libgpiod based on character device. Thank you.

1 hour ago, Levent Erenler said:

Or could anyone give me a startup point to access (c++) gpio interrupts efficiently.

 ArmbianIO API - in C
https://forum.armbian.com/topic/5655-armbianio-api-proposal/

 

 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/ and his improvement: https://github.com/sgjava/java-periphery

 


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

 

1 hour ago, Tido said:

 ArmbianIO API - in C
https://forum.armbian.com/topic/5655-armbianio-api-proposal/


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

 

Thanks for your answer, i checked ArmbianIO, it is based on sysfs.

pyGPIO is based on dev/mem, this is what i am looking unfortunatelly it does not support interrupts. I could not find a way to get gpio int from memory.

thank you.

  • Author

Hello Gabor,

 

Sorry, I do not have a valid Banana Pi platform to test this again as this project was done many years ago.  If I do get a chance to test the compilation once again I shall send you the details.

 

Best of luck,

 

Rick

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.