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]

1

Threads

12

Posts

47

Credits

Novice

Rank: 1

Credits
47
Post time 2016-3-17 02:34:05 | Show all posts
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
Post time 2016-3-17 03:14:47 | Show all posts
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
Post time 2016-3-17 15:55:44 | Show all posts
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
Post time 2016-3-17 20:47:57 From the mobile phone | Show all posts
@werecatf: maybe now it is time for wiringX?

1

Threads

7

Posts

41

Credits

Novice

Rank: 1

Credits
41
Post time 2016-3-18 00:05:49 | Show all posts

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

221

Posts

2006

Credits

Gold member

Rank: 6Rank: 6

Credits
2006
Post time 2016-3-21 19:43:54 | Show all posts
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 the 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 the 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 the Code

You have to change the cord only a little.

1

Threads

7

Posts

41

Credits

Novice

Rank: 1

Credits
41
Post time 2016-3-22 17:32:52 | Show all posts
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

221

Posts

2006

Credits

Gold member

Rank: 6Rank: 6

Credits
2006
Post time 2016-3-22 19:56:34 | Show all posts
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
Post time 2016-3-27 18:39:47 | Show all posts
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
Post time 2016-3-28 22:16:05 | Show all posts
Ok wiringX is now on github for those who want to test it

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

Points Rules

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

2019-12-10 19:04 GMT+8 , Processed in 0.033411 second(s), 22 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list