Author: linga51

GPIO library - WiringPi

[Copy link]

1

threads

12

posts

47

credits

Novice

Rank: 1

credits
47
Published in 2016-3-17 02:34:05 | Show all floors
WereCatf replied at 2016-3-17 01:20
Are you running the application as root?

yes im root but i wanna try like this $ sudo ./test



1

threads

12

posts

47

credits

Novice

Rank: 1

credits
47
Published in 2016-3-17 03:14:47 | Show all floors
Edited by volkancc at 2016-3-17 04:19
volkancc replied at 2016-3-17 02:34
yes im root but i wanna try like this $ sudo ./test

interrupt work with sudo ! ,

I'm trying to read a signal coming from a wiegand RFID card reader with my orangepione, but can't get it to work..
The wiegand format is supposed to feed me small bursts of 32 or 26 bits (depending the format) at ~50Hz on two Data+/Data- wires, but the board only manages to detect 6-7 bits of unreadable garbage.

With the same wiring and same code I was able to get it done with a Raspberry Pi.

You can find the related code here:


https://gist.github.com/hsiboy/9598741

1

threads

7

posts

41

credits

Novice

Rank: 1

credits
41
Published in 2016-3-17 15:55:44 | Show all floors
Edited by osator at 2016-3-18 00:05

Hello alll,
Can someone tell me how use GPIO in python ? I can't find any library to use it. "RPi.GPIO" return: This module can only be run on a Raspberry Pi!. Help!!!
Regards

2

threads

19

posts

110

credits

Registered member

Rank: 2

credits
110
Published in 2016-3-17 20:47:57 from mobile | Show all floors
@werecatf: maybe now it is time for wiringX?

1

threads

7

posts

41

credits

Novice

Rank: 1

credits
41
Published in 2016-3-18 00:05:49 | Show all floors

Small update:
I've managed to install wiringpi 1.0 but then "gpio readall" didn't work so I've changed wiringpi to wiringOP by git command. Now when I use "gpio readall" command in console I can see table with pinout descriptions. I use some example and wrote a small code in C to blink the LED on port and its work. Now the issue: when I trying to run the same blinking LED in python script on the same port it doesn't work. At the beggining of script I was import wiringpi (no faults and I can choose option from this module). How can I check if this module worked correctly? Is there some example/description how to write this script in python?

I'm trying it on OrangePi Plus2, OS:Ubuntu15.04 with Mate desktop. My code in python:

import wiringpi

wiringpi.waringPiSetup
wiringpi.pinMode (X,1)
wiringpi.digitalWrite(X,1)

X- pin number 16 in 40-pin connector (this pin is also named like PC04, IN04, 4 and 23). Which of these names is correct in my egzample?
If I'm not wrong this should work. Anyone can help me in this?
Thanks in advise.

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-3-21 19:43:54 | Show all floors
Edited by nopnop2002 at 2016-3-26 10:47
osator replied at 2016-3-17 15:55
Hello alll,
Can someone tell me how use GPIO in python ? I can't find any library to use it. "RPi.GP ...

Try orangepi_PC_gpio_pyH3.

  1. $ sudo apt-get install python-dev git make gcc
  2. $ git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3.git
  3. $ cd orangepi_PC_gpio_pyH3
  4. $ sudo python setup.py install
Copy code

The example which turns on/off GPIO4.
Raspberry pi.
  1. # -*- coding: utf-8 -*-
  2. import RPi.GPIO as GPIO
  3. import time

  4. COUNT = 3
  5. PIN = 4
  6. #GPIO.setmode(GPIO.BOARD)
  7. GPIO.setmode(GPIO.BCM)
  8. GPIO.setup(PIN,GPIO.OUT)

  9. for _ in xrange(COUNT):
  10.     GPIO.output(PIN,True)
  11.     time.sleep(1.0)
  12.     GPIO.output(PIN,False)
  13.     time.sleep(1.0)

  14. GPIO.cleanup()
Copy code
OrangePi
  1. # -*- coding: utf-8 -*-
  2. from pyA20.gpio import gpio
  3. from pyA20.gpio import port
  4. import time

  5. COUNT = 3
  6. PIN = port.PA6
  7. gpio.init()
  8. gpio.setcfg(PIN, gpio.OUTPUT)

  9. for _ in xrange(COUNT):
  10.     gpio.output(PIN,True)
  11.     time.sleep(1.0)
  12.     gpio.output(PIN,False)
  13.     time.sleep(1.0)

  14. #gpio.cleanup()
Copy code

You have to change the cord only a little.

1

threads

7

posts

41

credits

Novice

Rank: 1

credits
41
Published in 2016-3-22 17:32:52 | Show all floors
Edited by osator at 2016-3-22 17:49

I tried your way and its working, thanks. But now am I able to use hardware PWM on pin 7? How to use it?

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-3-22 19:56:34 | Show all floors
Edited by nopnop2002 at 2016-3-28 06:27
osator replied at 2016-3-22 17:32
I tried your way and its working, thanks. But now am I able to use hardware PWM on pin 7? How to use ...

There is Information about hardware PWM.

http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=1153&highlight=PWM


orangepi_PC_gpio_pyH3 has not supported software PWM yet.

https://pypi.python.org/pypi/pyA20




2

threads

19

posts

110

credits

Registered member

Rank: 2

credits
110
Published in 2016-3-27 18:39:47 | Show all floors
Edited by apocalyps at 2016-3-27 18:54

Ok i have made a dirty version for wiringX. I used Werecatf's WiringOP and the bananapi src from wiringX and merged them together. This is what i came up with so far: http://fpaste.org/345699/

I used codesend on my 433mhz transmitter and used a simple read program with the wiringX library to see if i get some input on my 433mhz receiver. It worked in this simple setup. Maybe there are some people here who can test more ? Later on i will put up my version on github

Interrupt is not working yet. I see i have to do some adjustments there

2

threads

19

posts

110

credits

Registered member

Rank: 2

credits
110
Published in 2016-3-28 22:16:05 | Show all floors
Ok wiringX is now on github for those who want to test it

https://github.com/apocalypsss/wiringX
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list