1 1
RickR

Accessing GPIO pins

Recommended Posts

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. 

 

Share this post


Link to post
Share on other sites
12 hours ago, RickR said:

I need to read and write to the GPIO pins from a bash script

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

 

Share this post


Link to post
Share on other sites
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 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
1 1