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

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
View: 6823|Reply: 2

Switching states of OPiPC GPIO pins

[Copy link]

1

Threads

3

Posts

22

Credits

Novice

Rank: 1

Credits
22
Post time 2016-4-26 21:45:15 | Show all posts |Read mode
Edited by Sk1ppeR at 2016-4-26 22:45

Hello there.

I have a quite difficult problem with my OPi PC and it's to the point i've become frustrated. I'm basically running Armbian Jessy on my OPi PC. Now first of all the kernel module for the GPIO control wasn't loaded by default so I ran
  1. modprobe gpio_sunxi
Copy the Code
Once I did that as ROOT I had the following export in my sysfs
  1. /sys/class/gpio_sw/
Copy the Code

Which basically is the list of my GPIO pins. Now, here's the issue. I see absolutely no way of controlling those pins with this kernel driver (gpio-sunxi). I've read these forums top to bottom and I see people sharing various Python/C/C++ libraries but they are all for the A20 CPU, not the AllWinner H3 and are coded against the more sane kernel driver that exports the gpio pins to the sysfs through /sys/class/gpio and allows you to export them the way you want.

Only one of the aforementioned libraries worked and it could only "read the state" of the pins (and I'm not sure it works properly because when I try to export a pin it tries to find them in /sys/class/gpio and i do not have such folder at all)

With a lot of tinkering I figured how to switch the pin data from 1 to 0 and vice versa
  1. echo 1 >> /sys/class/gpio_sw/PD14/data
Copy the Code

However, here's my question. How do I switch states of the GPIO pins from low to high and from in to out with this bad driver?
Another problem I have (probably due to this) is that I can't read my serial console because all my GPIO pins are set in "OUT" mode by default and I can't read the UART_RX1 pin.

I have a HC-06 serial bluetooth module and I can't read the data I'm sending it from my android phone even though I connect successfully to it.

Also I have a 4-channel power relay but the 5V pins on the OPi PC don't push out nearly enough power to turn on/off the relays so I had to attach external power source too.

If I fail to resolve this matter I'll never buy another Orange anything. The compatibility makes things way too difficult in a time where you can order a 5$ RPi Zero and have things "just work".

Thanks for any help in this matter.

P.S: I try to read the console this way
  1. cat << /dev/ttyS0
Copy the Code
And I'm sure the baud rate is set to 9600, I personally changed it in /etc/inttab.
And I've also tried connecting to the serial console using "minicom" but it doesn't receive anything on the serial port.

1

Threads

14

Posts

143

Credits

Registered member

Rank: 2

Credits
143
Post time 2016-4-27 19:19:41 | Show all posts
Edited by The_Loko at 2016-4-27 19:23

The easiest way to use GPIO is with Wiring OP (a WiringPI port for OrangePi) and this python library
Both include a example folder.

You can't use 5V relays without transistors or anything on OPI as pins work with 3.3V like most arm boards.

After downloading and installing WiringOP from here (https://github.com/zhaolei/WiringOP) you can use gpio command to manage ports, for example gpio mode X out to set port X as out, gpio write X 1 to set X port on HIGH.

1

Threads

3

Posts

22

Credits

Novice

Rank: 1

Credits
22
 Author| Post time 2016-4-27 20:06:37 | Show all posts
Edited by Sk1ppeR at 2016-4-27 20:29

EDIT: Testing, I think im on the right track, will talk later
You have to log in before you can reply Login | Register

Points Rules

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

2022-5-20 00:03 GMT+8 , Processed in 0.029536 second(s), 22 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list