Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
Author: linga51

GPIO library - WiringPi

[Copy link]

0

Threads

19

Posts

111

Credits

Registered member

Rank: 2

Credits
111
Post time 2015-8-15 21:55:46 | Show all posts
@fritz I just tried out this WiringBP on Orange Pi2 with Rasbian OS and I still didnt manage to do anything.

Do we have absolutely to use this wiringPi lib, is there not other ways to use GPIO?

Anyhow, what ever way to play with the GPIO interface, we would be very happy to know how to I hope someone will find out how to deal with it...

5

Threads

355

Posts

2102

Credits

Moderator

Rank: 7Rank: 7Rank: 7

Credits
2102
Post time 2015-8-15 22:25:24 | Show all posts
@alexparadise
As I said this library is for the banana pi.
You need to adapt it tho the H3 boards.
Never tried Rasbian OS Sorry.
I don't make promises but i will look if .....
Boards:
orangepi plus, olinuxino A20, cubieboard A10, mele A2000 .....

11

Threads

75

Posts

376

Credits

Intermediate member

Rank: 3Rank: 3

Credits
376
Post time 2015-8-16 17:40:07 | Show all posts
Edited by bhgv at 2015-8-16 17:41
alexparadise replied at 2015-8-15 21:55
@fritz I just tried out this WiringBP on Orange Pi2 with Rasbian OS and I still didnt manage to do a ...

> Do we have absolutely to use this wiringPi lib, is there not other ways to use GPIO?
> Anyhow, what ever way to play with the GPIO interface, we would be very happy to know how to I hope someone will find out how to deal with it...

if you look inside the code of wiringpi you will see it is just reading/writing from/to  /dev/... unix devices. you can use the code of wiringpi as tutorial for yourself. it is not so hard.
(and you can do this without wiringpi lib)

0

Threads

19

Posts

111

Credits

Registered member

Rank: 2

Credits
111
Post time 2015-8-16 18:12:41 | Show all posts
Edited by alexparadise at 2015-8-16 18:25

Actually, I think (but I am not sure), wiringPi is not the main issue. But /sys/class/gpio/ , until now I was not able to see this folder. I tried many different OS, Rasbian, UbuntuMate... None of them  has this folder. Apparently it would be because the Kernel was not configure to support GPIO. Therefor we would have to recompile the Kernel to enable GPIO.
Does anyone manage to have /sys/class/gpio/ ??

EDIT: @bhgv didn't seen your post, I just saw it and it fit with my remark ;-) or ?

0

Threads

19

Posts

111

Credits

Registered member

Rank: 2

Credits
111
Post time 2015-8-16 21:47:26 | Show all posts
Edited by alexparadise at 2015-8-16 22:58

So apprently no need to re-compile the Kernel, you just have to activate the module gpio-sunxi.

On Lubuntu & Raspbian, if I run the commands

  1. modprobe gpio-sunxi
Copy the Code


I can see the folders: /sys/class/gpio_sw/

Then I can switch on/off the led of the board with:

  1. echo 1 > /sys/class/gpio_sw/normal_led/data
  2. echo 0 > /sys/class/gpio_sw/normal_led/data
  3. echo 1 > /sys/class/gpio_sw/standby_led/data
  4. echo 0 > /sys/class/gpio_sw/standby_led/data
Copy the Code


Edit:
If you connect a led+transitor between the connector 6 (GND) and 11 (GPIO17??), you can switch on/off the LED with the command:

  1. echo 0 > /sys/class/gpio_sw/PA1/data
Copy the Code
  1. echo 1 > /sys/class/gpio_sw/PA1/data
Copy the Code

Edit:
And I just manage to move a servo motor with a little php script...


Finally did it :-D

Have fun ;-)


0

Threads

19

Posts

111

Credits

Registered member

Rank: 2

Credits
111
Post time 2015-8-17 03:43:22 | Show all posts
Now my problem is to find out how to read from GPIO. There is no direction file...
I try as well to read from UART but no way to find /dev/ttyAMA0...

I am a bit lost.

So if someone know how to read data from GPIO, I would love to hear how to do it

0

Threads

19

Posts

111

Credits

Registered member

Rank: 2

Credits
111
Post time 2015-8-17 22:06:12 | Show all posts
After reading the code source from gpio_sunxi, I found out that the input file for the direction is the file cfg with 0 = "in" and 1 = "out".

Therefor, in order to put the pin 11 (GPIO 17) in mode read, execute the following command:


  1. echo 0 > /sys/class/gpio_sw/PA1/cfg
Copy the Code


Then to read just execute the command:

  1. cat /sys/class/gpio_sw/PA1/data
Copy the Code


If pin 11 (GPIO 17) is connected to GND (eg. pin 6) is will return 0, if it's not connected it will return 1.

0

Threads

19

Posts

111

Credits

Registered member

Rank: 2

Credits
111
Post time 2015-8-19 00:06:17 | Show all posts
I just wrote a program to reproduce a RF signal from a remote, for example for a RF plug.

https://github.com/apiel/GpioRF

2

Threads

9

Posts

133

Credits

Registered member

Rank: 2

Credits
133
Post time 2015-9-4 01:04:22 | Show all posts
Hi guys,

I have some problem on Orange Pi Plus

like this:
import RPi.GPIO as GPIO
RuntimeError: This module can only be run on a Raspberry Pi!

please, need help

0

Threads

19

Posts

111

Credits

Registered member

Rank: 2

Credits
111
Post time 2015-9-4 01:10:36 | Show all posts
@chirik

RPi.GPIO is build for RPI :p and use the library WiringPi. Until now nobody has ported this library... I guess it would not be so much work to port, just few lines. What do you want to do??
You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2019-11-22 10:19 GMT+8 , Processed in 0.039682 second(s), 20 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list