please choosego to mobile | Continue to access the PC version
Author: linga51

GPIO library - WiringPi

[Copy link]

1

threads

20

posts

122

credits

Registered member

Rank: 2

credits
122
Published in 2015-8-15 21:55:46 | Show all floors
@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

354

posts

2614

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
2614
Published in 2015-8-15 22:25:24 | Show all floors
@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
Published in 2015-8-16 17:40:07 | Show all floors
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)

1

threads

20

posts

122

credits

Registered member

Rank: 2

credits
122
Published in 2015-8-16 18:12:41 | Show all floors
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 ?

1

threads

20

posts

122

credits

Registered member

Rank: 2

credits
122
Published in 2015-8-16 21:47:26 | Show all floors
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 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 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 code
  1. echo 1 > /sys/class/gpio_sw/PA1/data
Copy code

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


Finally did it :-D

Have fun ;-)


1

threads

20

posts

122

credits

Registered member

Rank: 2

credits
122
Published in 2015-8-17 03:43:22 | Show all floors
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

1

threads

20

posts

122

credits

Registered member

Rank: 2

credits
122
Published in 2015-8-17 22:06:12 | Show all floors
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 code


Then to read just execute the command:

  1. cat /sys/class/gpio_sw/PA1/data
Copy 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.

1

threads

20

posts

122

credits

Registered member

Rank: 2

credits
122
Published in 2015-8-19 00:06:17 | Show all floors
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
Published in 2015-9-4 01:04:22 | Show all floors
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

1

threads

20

posts

122

credits

Registered member

Rank: 2

credits
122
Published in 2015-9-4 01:10:36 | Show all floors
@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 need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list