Jump to content

Orange PI Zero - GPIO does not work?


scaevola

Recommended Posts

Hi there.

I use Orange Pi zero as home print server. It works for few months for now and I am very pleased with that. Although, my printer falls into deep sleep after printing (it's Brother HL-1110EW) and cannot be woken up by the server. I have to start printer manually to print next printouts. Thus I wanted to install tea4cups to drive a relay turning the printer on and off when needed. 

I installed the WiringOP-zero (from here: https://github.com/xpertsavenue/WiringOP-Zero) but then strange things become to happen. I connected temporarily a LED diode to indicate the changes of the GPIO. (GPIO-7 and GND). The LED is on all the time, no matter what command I send.

Even if "gpio readall" shows "0" state on GPIO-7 the led still is on.

Quote




qbunjo@printserver:~$ gpio readall
+-----+-----+----------+------+--Orange Pi Zero--+------+----------+-----+-----+
| H2+ | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | H2+ |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
|     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
|  12 |   8 |    SDA.0 | ALT3 | 0 |  3 || 4  |   |      | 5V       |     |     |
|  11 |   9 |    SCL.0 | ALT3 | 0 |  5 || 6  |   |      | 0v       |     |     |
|   6 |   7 |   GPIO.7 |  OUT | 0 |  7 || 8  | 0 | ALT3 | TxD3     | 15  | 198 |
|     |     |       0v |      |   |  9 || 10 | 0 | ALT3 | RxD3     | 16  | 199 |
|   1 |   0 |     RxD2 | ALT3 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1   | 1   | 7   |
|   0 |   2 |     TxD2 | ALT3 | 0 | 13 || 14 |   |      | 0v       |     |     |
|   3 |   3 |     CTS2 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO.4   | 4   | 19  |
|     |     |     3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO.5   | 5   | 18  |
|  15 |  12 |     MOSI | ALT3 | 0 | 19 || 20 |   |      | 0v       |     |     |
|  16 |  13 |     MISO | ALT3 | 0 | 21 || 22 | 0 | ALT3 | RTS2     | 6   | 2   |
|  14 |  14 |     SCLK | ALT3 | 0 | 23 || 24 | 0 | ALT3 | CE0      | 10  | 13  |
|     |     |       0v |      |   | 25 || 26 | 0 | ALT3 | GPIO.11  | 11  | 10  |
+-----+-----+----------+------+---+---LEDs---+---+------+----------+-----+-----+
|  17 |  30 | STAT-LED |  OUT | 0 | 27 || 28 |   |      | PWR-LED  |     |     |
+-----+-----+----------+------+---+-----+----+---+------+----------+-----+-----+
| H2+ | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | H2+ |
+-----+-----+----------+------+--Orange Pi Zero--+---+------+---------+-----+--+

 

I tried to push the values through "echo":

Quote

echo 7 > /sys/class/gpio/export

echo "out" > /sys/class/gpio/gpio7/direction

echo 1 > /sys/class/gpio/gpio7/value

But also without success. That means gpio readall still shows changes in the table but there are no physical changes on the pin (the voltage still is on).

Then I thought that maybe there is no kernel module loaded, but I can see that w1-gpio is loaded:

lsmod
Module                  Size  Used by
aes_arm_bs             20480  2
crypto_simd            16384  1 aes_arm_bs
ccm                    20480  6
xradio_wlan           110592  1
mac80211              532480  1 xradio_wlan
sun4i_gpadc_iio        16384  0
cfg80211              491520  2 mac80211,xradio_wlan
industrialio           53248  1 sun4i_gpadc_iio
zram                   24576  2
sun8i_thermal          16384  0
sunxi_cedrus           32768  0
rfkill                 20480  3 cfg80211
libarc4                16384  1 mac80211
v4l2_mem2mem           20480  1 sunxi_cedrus
videobuf2_dma_contig    20480  1 sunxi_cedrus
videobuf2_memops       20480  1 videobuf2_dma_contig
videobuf2_v4l2         20480  2 sunxi_cedrus,v4l2_mem2mem
videobuf2_common       40960  3 sunxi_cedrus,v4l2_mem2mem,videobuf2_v4l2
w1_gpio                16384  0
wire                   32768  1 w1_gpio
cn                     16384  1 wire
uio_pdrv_genirq        20480  0
uio                    16384  1 uio_pdrv_genirq
cpufreq_dt             20480  0
usb_f_acm              20480  1
u_serial               24576  3 usb_f_acm
g_serial               16384  0
libcomposite           45056  2 g_serial,usb_f_acm
ip_tables              24576  0
x_tables               24576  1 ip_tables
autofs4                36864  2
pwrseq_simple          16384  1
sunxi                  16384  0
phy_generic            20480  2 sunxi

Then I started to read forums, including this one. Still no clue what is happening, I did not find any similar case.

I run out of ideas -maybe anyone would have some?

Oh, I forgot one thing that may be interesting - driving onboard red led actually works. (gpio 30)

 

EDIT:

I changed the driving pin for pin9 and it works fine. Pin 7 is damaged or anything? Dunno.

Link to comment
Share on other sites

I use the same gpio library and all pins are working on my OPi Zero.

It may be worth re-soldering pin 9 on the IDC header and see if the soldered

connection is at fault.

 

Below is  a very  quick bash script to set all pins as outputs, activate them,

then turn off all pins you can use as a check.

There's probably more efficient ways of doing the same thing

 

#!/bin/bash 
gpio reset; 
sleep 1; 
for n in {0..30}; 
do 
        gpio mode $n out;        
        gpio write $n on;        
done 
gpio readall 
sleep 3 
for n in {0..30}; 
do 
        gpio write $n off; 
done     
gpio readall; 
sleep 3;
gpio reset

 

Link to comment
Share on other sites

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