Jump to content

Recommended Posts

Posted

Hi there,

 

I was wondering if there is a GPIO generic Python library somewhere for Armbian?
I think I remember that the pins are not always announced the same way on Armbian and on OrangePi distros.
I have seen this effort by @chwe, but is there anything else?
 

Thanks.

Posted

Within armbian you find following User-Supported options for GPIO and more:
ArmbianIO (sysFS) or
UserSpaceIO (libgpiod),
pyGPIO accesses 'pins' directly through /dev/mem


 ArmbianIO API - in C
https://forum.armbian.com/topic/5655-armbianio-api-proposal/

 

 User Space IO - is Python 3 and Java 8 bindings for user space GPIO, SPI, I2C, PWM and Serial interfaces
https://forum.armbian.com/topic/6523-user-space-io-is-python-3-and-java-8-bindings-for-user-space-gpio-spi-i2c-pwm-and-serial-interfaces/

 

 pyGPIO - A 'more general' python GPIO library based on pyA20
https://forum.armbian.com/topic/5662-pygpio-a-more-general-python-gpio-library/

 

 

Posted

Thanks a lot @Tido.

I'm about to connect I2C OLED screens to OrangePi Zeros running Armbian, and would like to get something like @Igor's setup:

P1040096.JPG
I can't find the name of this gizmo that would allow me to solder once all the GPIO pins, and then play with Dupont cables.
Is there a name for that?

Posted

I finally found what I was looking for: https://www.reichelt.de/2-x-13-pin-header-angled-pitch-2-54-sl-2x13w-2-54-p19491.html?&trstct=pol_10.
I attached the screen, and got everything working a few minutes later.
I still have questions though. When I search for the Zero's GPIO, I find different versions of the schema (OrangePi documentation, OSHLAB.com, ...). i2c is well detected:

sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I can find several i2c ports available:

poddingue@orangepizero:~$ ls /dev/i2c*
/dev/i2c-0  /dev/i2c-1  /dev/i2c-2

But I can't find any other i2c chip on the other ports:

 sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
poddingue@orangepizero:~$ sudo i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

 

The gpio utility gives me some information, but it looks like other i2c are available on ports (27, 28) that are not available on the board (as we only have 26, and not 40). Did I get it right? On the OSHLAB.COM schema, there are also i2c on the 16th and 18th pins...
Or is there a way to reconfigure some of the available pins so that they are i2c?

gpio -1 readall
 +-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |  12 |   8 |    SDA.0 | ALT5 | 0 |  3 || 4  |   |      | 5V       |     |     |
 |  11 |   9 |    SCL.0 | ALT5 | 0 |  5 || 6  |   |      | 0v       |     |     |
 |   6 |   7 |   GPIO.7 | ALT3 | 0 |  7 || 8  | 0 | ALT3 | TxD3     | 15  | 13  |
 |     |     |       0v |      |   |  9 || 10 | 0 | ALT3 | RxD3     | 16  | 14  |
 |   1 |   0 |     RxD2 | ALT3 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1   | 1   | 110 |
 |   0 |   2 |     TxD2 | ALT3 | 0 | 13 || 14 |   |      | 0v       |     |     |
 |   3 |   3 |     CTS2 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO.4   | 4   | 68  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO.5   | 5   | 71  |
 |  64 |  12 |     MOSI | ALT3 | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  65 |  13 |     MISO | ALT3 | 0 | 21 || 22 | 0 | ALT3 | RTS2     | 6   | 2   |
 |  66 |  14 |     SCLK | ALT3 | 0 | 23 || 24 | 0 | ALT3 | CE0      | 10  | 67  |
 |     |     |       0v |      |   | 25 || 26 | 0 | ALT3 | GPIO.11  | 11  | 21  |
 |  19 |  30 |    SDA.1 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.1    | 31  | 18  |
 |   7 |  21 |  GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v       |     |     |
 |   8 |  22 |  GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | RTS1     | 26  | 200 |
 |   9 |  23 |  GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v       |     |     |
 |  10 |  24 |  GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | ALT3 | CTS1     | 27  | 201 |
 |  20 |  25 |  GPIO.25 |  OUT | 1 | 37 || 38 | 0 | ALT5 | TxD1     | 28  | 198 |
 |     |     |       0v |      |   | 39 || 40 | 0 | ALT5 | RxD1     | 29  | 199 |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+

If you know a place where there is a definitive documentation about those pins, and the meaning of all these acronyms, I'm all ears.

Thanks.

  • gounthar changed the title to GPIO and Armbian for OrangePi Zero.
Posted
1 hour ago, gounthar said:

I find different versions of the schema

The offical place to look is on linux-sunxi site :

http://linux-sunxi.org/Orange_Pi_Zero#Expansion_Port

 

Schematic is here :

https://linux-sunxi.org/File:Orange-Pi-Zero-Schanetics-v1_11.pdf

 

So 2 I2C buses are available on the header, the third one is normally for CSI port, but OPiZero doesn't have such port ...

Posted

The second I2C bus worked for the screen.
Strangely, I had to remove CIR thanks to armbian-config to get the first I2C bus to work again.

Anyway, I'm still looking for good general documentation about GPIO and the meaning of all these acronyms, if you ever have some.
Thanks.

Posted

Well, there are several different names for the same pins, like PB21 / PA12 or PI3 / PA06 for example.
On some pins, it gets even more complicated with several functions possible like PI14 SPI0_CS1 / SIM_DET/PA_EINT10 / PA10 / GPIO10.
I'd like to know what is SIM_DET for example, and what is PA_EINT10, and how to switch functions.
That's very basic I guess, but I'd like to learn what's under the hood (because it looks like Armbian and/or libraries are taking care of everything).

Posted

Hi,

 

these PIN Names are possibly considered "general knowledge" once you worked with some microprocessors or similiar. Most are just abbreviations. And the different functions on a pin.

 

I'll try to explain some of them based on the linked OrangePi Extension header table (from their wiki):

image.png.a08154cd7b362a5459331b3eee69129f.png

3.3V -> obviously 3.3V output

TWI0_SDA / PA12 / GPIO12:

TWI0_SDA -> Two Wire Interface also known as I²C | SDA -> Serial Data

PA12 -> Pin from internal pin register a, number 12

GPIO -> General Purpose Input/Output Pin Number 12

the last two are essentially the same with the first one based on the internal registers and the other one just numerated over all pins.

 

TWI0_SCK / PA11 / GPIO11:

TWI0_SCK -> Two Wire Interface (i2c) | SCK -> Serial Clock

 

GND -> ground, minus, (-), return or whatever you're gonna call it.

 

UART2_RX -> Universial Asynchronous Receiver and Transmitter 2 -> also known as Serial Port (RS232 like) | RX -> Receiving or Receiver. This pin is read by software.

UART2_TX -> see above, TX -> Transmitter. This pin gets set by software (and sends the data)

UART2_CTS -> see above, CTS -> Clear to Send. Used for flow control, to tell the partner you are ready to receive. (or they are cleared to send) 

(Googling for UART, USART or RS232 will probably give good explanations on this)

 

SPI1_MOSI:

SPI -> Serial Peripheral Interface -> Another kind of serial port. -> google.

MOSI -> Master Out / Slave In -> this is the transmitting port for a master perspective

SPI1_MISO -> Master In / Slave Out -> receiving port

SPI1_CLK -> the clock signal. 

Just search for spi for more info.

 

SIM_CLK / PA_EINT7:

SIM_CLK -> can probably attach a SIM Card here (then this will be the clock line). I don't know stuff about sim cards though.

PA_EINT7 -> Internal Port Register A, External Interrupt 7. Read about Hardware Interrupts for microprocessors for more info. Essentially a software component can be instantly triggered on some predefined signal on this pin.

 

The rest has the same prefixes, so you can probably deduce the meaning by using the internet. If something remains unclear, just ask.

 

Kind regards,

count-doku

Posted

I now want to connect one or two PWM fans (a Delta BFB1012VH 46cfm and a Sunon pf40281bx-d060-s99 24.9cfm).
I guess I should use a resistor for the PWM wire, but I don't know about the RPM wire...
And should I connect the ground of the fan with the ground of the OrangePi Zero? They don't share the same voltage, so I'm kind of afraid to do so.
Any input?
Thanks.

Posted

Oh well, it's not as easy as I thought it would be.
I can't remember on which Zero I had managed to get the PWM to work for me.
And even if I could find it, I guess it would be difficult to understand why it works, as I installed so many libraries.

 

For the time being, on a fresh install, I can get the 7th pin to work as an output for GPIO, thus making a LED blink (with java-periphery or python-periphery).
But this very same pin can't (for me at last) work as PWM, even if it's labeled "PI3 PWM1 / PA06 / GPIO6" with the same libraries.
I also tried with the middle pin of the UART with no luck.
The OPI.GPIO PWM demo says nothing, but I can't see anything switching on.

 

 sudo python3 PWM_Demo.py
turn on pwm by pressing button

dimm pwm by pressing button

change pwm frequency by pressing button

stop pwm by reducing duty cycle to 0 by pressing button

change polarity by pressing button

increase duty cycle but inverted so light will dim. press button to contunue

duty cycle reduced press button to contunue

stop pwm (it was inverted so it shoudl be full brightness), press button to contunue

remove object and deactivate pwm pin, press button to contunue

poddingue@orangepizero:~/OPi.GPIO/Demo$

 

I've seen better Sundays when I don't feel that dumb. :(

DmCOgP8VUa.png

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines