View: 9543|Reply: 2

Switching states of OPiPC GPIO pins

[Copy link]

1

threads

3

posts

22

credits

Novice

Rank: 1

credits
22
Published in 2016-4-26 21:45:15 | Show all floors |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 code
Once I did that as ROOT I had the following export in my sysfs
  1. /sys/class/gpio_sw/
Copy 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 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 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
Published in 2016-4-27 19:19:41 | Show all floors
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| Published in 2016-4-27 20:06:37 | Show all floors
Edited by Sk1ppeR at 2016-4-27 20:29

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

Points Rule

Quick reply Top Return list