View: 18704|Reply: 26

GPIO ADDON & OPENELEC

[Copy link]

1

threads

6

posts

46

credits

Novice

Rank: 1

credits
46
Published in 2016-9-26 19:27:15 | Show all floors |Read mode
Hello OrangePi Community,

I've got actually an Orange PI PC+ and i was wondering if there's a way to install GPIO in OpenElec ?

Regards.

4

threads

1118

posts

9504

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9504
Published in 2016-9-27 01:31:50 | Show all floors
Pins are accessible trought sysfs. If you meant something like python libs, then you are right and there is no plugin yet. If you have time, you can help create one.

1

threads

6

posts

46

credits

Novice

Rank: 1

credits
46
 Author| Published in 2016-9-27 03:01:24 | Show all floors
jernej replied at 2016-9-27 01:31
Pins are accessible trought sysfs. If you meant something like python libs, then you are right and t ...

Can i use them to control my fan ? as i've got one.

If yes could you help me to do so ?

Thanks.

4

threads

1118

posts

9504

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9504
Published in 2016-9-27 04:03:38 | Show all floors
Boten replied at 2016-9-26 20:01
Can i use them to control my fan ? as i've got one.

If yes could you help me to do so ?

I misconfigured GPIO module, so for now, you have to load driver first (it will be fixed soon):
  1. modprobe gpio_sunxi
Copy code

then check sysfs for all available pins (depends on script.bin):
  1. ls /sys/class/gpio_sw
Copy code

Choose one, for example PA0. Set it either to input (0) or output (1). This will set it as an output:
  1. echo "1">/sys/class/gpio_sw/PA0/cfg
Copy code

If you set it as an output, you can set state of the pin with writing 1 or 0:
  1. echo "1">/sys/class/gpio_sw/PA0/data
Copy code

Otherwise, you can read it:
  1. cat /sys/class/gpio_sw/PA0/data
Copy code


Please know that all these informations are based on a driver, so please tell if it works or not.

1

threads

6

posts

46

credits

Novice

Rank: 1

credits
46
 Author| Published in 2016-9-27 06:34:50 | Show all floors
Hello jerneg and thanks for your fast answer!

I followed your steps but i haven't been successful turning the fan on.i even activated all the pins via the two commands:

> echo "1">/sys/class/gpio_sw/PA0/cfg
> echo "1">/sys/class/gpio_sw/PA0/data

The FAN still off, is there schema of the pins and their numbers ?

4

threads

1118

posts

9504

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9504
Published in 2016-9-28 03:38:17 | Show all floors
Boten replied at 2016-9-26 23:34
Hello jerneg and thanks for your fast answer!

I followed your steps but i haven't been successful t ...

Yes, search the forum or check schematic, which you can find on official site in download section.

4

threads

1118

posts

9504

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9504
Published in 2016-9-28 07:46:33 | Show all floors
I quickly created WiringOP GPIO plugin from https://github.com/WereCatf/WiringOP Install appended zip as a plugin from Kodi and reboot. Then you should have familiar gpio command.

Please report result. If it works, I will add it to repository.

This thread contains more resources

You need to Log in to download or view,No account?    Register

x

1

threads

6

posts

46

credits

Novice

Rank: 1

credits
46
 Author| Published in 2016-10-15 23:14:06 | Show all floors
Hola jernej and sorry for the delay of my answer.

The installation was successful in OpenElec but i haven't been able to control it and when i put the fan on the first pins it's on by default and you can't put it off...

OpenELEC:~ # gpio readall
+-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
| BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
|     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
|     |     |    SDA.0 |      |   |  3 || 4  |   |      | 5V       |     |     |
|     |     |    SCL.0 |      |   |  5 || 6  |   |      | 0v       |     |     |
|   6 |   6 | IO6 PA06 |   IN | 0 |  7 || 8  |   |      | TxD3     |     |     |
|     |     |       0v |      |   |  9 || 10 |   |      | RxD3     |     |     |
|     |     |     RxD2 |      |   | 11 || 12 | 0 | IN   | IO1 PD14 | 1   | 110 |
|     |     |     TxD2 |      |   | 13 || 14 |   |      | 0v       |     |     |
|     |     |     CTS2 |      |   | 15 || 16 | 0 | IN   | IO4 PC04 | 4   | 68  |
|     |     |     3.3v |      |   | 17 || 18 | 0 | IN   | IO5 PC07 | 5   | 71  |
|     |     |     MOSI |      |   | 19 || 20 |   |      | 0v       |     |     |
|     |     |     MISO |      |   | 21 || 22 |   |      | RTS2     |     |     |
|     |     |     SCLK |      |   | 23 || 24 |   |      | SPI-CE0  |     |     |
|     |     |       0v |      |   | 25 || 26 |   |      | CE1      |     |     |
|     |     |    SDA.1 |      |   | 27 || 28 |   |      | SCL.1    |     |     |
|   7 |   7 |  IO7 PA7 |   IN | 0 | 29 || 30 |   |      | 0v       |     |     |
|   8 |   8 |  IO8 PA8 |   IN | 0 | 31 || 32 | 0 | IN   | IO9 PG08 | 9   | 200 |
|   9 |  10 | IO10 PA9 |   IN | 0 | 33 || 34 |   |      | 0v       |     |     |
|  10 |  12 | IO12PA10 |   IN | 0 | 35 || 36 | 0 | IN   | IO13PG09 | 13  | 201 |
|  20 |  14 | IO14PA20 |   IN | 0 | 37 || 38 | 0 | IN   | IO15PG06 | 15  | 198 |
|     |     |       0v |      |   | 39 || 40 | 0 | IN   | IO16PG07 | 16  | 199 |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
+-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----

4

threads

1118

posts

9504

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9504
Published in 2016-10-16 20:58:31 | Show all floors
Weird, I can't make sensible readings with my multimeter. I must take a deeper look.

4

threads

1118

posts

9504

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9504
Published in 2016-10-17 02:47:14 | Show all floors
Boten replied at 2016-10-15 16:14
Hola jernej and sorry for the delay of my answer.

The installation was successful in OpenElec but  ...

I manage to make it work. If you issue readall command, you will get something like that:
  1. +-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
  2. | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
  3. +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
  4. |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
  5. |     |     |    SDA.0 |      |   |  3 || 4  |   |      | 5V       |     |     |
  6. |     |     |    SCL.0 |      |   |  5 || 6  |   |      | 0v       |     |     |
  7. |   6 |   6 | IO6 PA06 | ALT3 | 0 |  7 || 8  |   |      | TxD3     |     |     |
  8. |     |     |       0v |      |   |  9 || 10 |   |      | RxD3     |     |     |
  9. |     |     |     RxD2 |      |   | 11 || 12 | 0 | ALT3 | IO1 PD14 | 1   | 110 |
  10. |     |     |     TxD2 |      |   | 13 || 14 |   |      | 0v       |     |     |
  11. |     |     |     CTS2 |      |   | 15 || 16 | 0 | ALT3 | IO4 PC04 | 4   | 68  |
  12. |     |     |     3.3v |      |   | 17 || 18 | 0 | ALT3 | IO5 PC07 | 5   | 71  |
  13. |     |     |     MOSI |      |   | 19 || 20 |   |      | 0v       |     |     |
  14. |     |     |     MISO |      |   | 21 || 22 |   |      | RTS2     |     |     |
  15. |     |     |     SCLK |      |   | 23 || 24 |   |      | SPI-CE0  |     |     |
  16. |     |     |       0v |      |   | 25 || 26 |   |      | CE1      |     |     |
  17. |     |     |    SDA.1 |      |   | 27 || 28 |   |      | SCL.1    |     |     |
  18. |   7 |   7 |  IO7 PA7 | ALT3 | 0 | 29 || 30 |   |      | 0v       |     |     |
  19. |   8 |   8 |  IO8 PA8 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | IO9 PG08 | 9   | 200 |
  20. |   9 |  10 | IO10 PA9 | ALT3 | 0 | 33 || 34 |   |      | 0v       |     |     |
  21. |  10 |  12 | IO12PA10 | ALT3 | 0 | 35 || 36 | 0 | ALT3 | IO13PG09 | 13  | 201 |
  22. |  20 |  14 | IO14PA20 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | IO15PG06 | 15  | 198 |
  23. |     |     |       0v |      |   | 39 || 40 | 0 | ALT3 | IO16PG07 | 16  | 199 |
  24. +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
  25. | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
  26. +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+
Copy code

Now, you must select pin appropriatelly. For ordinary gpio functionality, you can only use pins under "wPi" column on both side. For example, lets use physical pin 40, which coresponds to wPi 16. First we have to set direction. This is easily done by:
  1. gpio mode 16 out
Copy code
After that you can switch between 3.3V and 0V by using command
  1. gpio write 16 1
Copy code
or
  1. gpio write 16 0
Copy code
, respectively.

Is this all you wanted or do you want to use PWM for precision fan regulation?

You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list