Differences between revisions 1 and 26 (spanning 25 versions)
Revision 1 as of 2016-12-23 13:25:42
Size: 16145
Editor: RudolfReuter
Comment: new
Revision 26 as of 2020-08-02 11:00:41
Size: 45013
Editor: RudolfReuter
Comment: added vncpasswd utility
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
The [[http://orangepi.com/orange-pi-lite]] is a palm sized (69 x 48 mm) computer that plugs into your TV and gets an USB keyboard and an USB mouse. It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. The [[https://linux-sunxi.org/Orange_Pi_Lite|community page]] has some more details. /!\ There are several versions of '''Orange Pi''' computers. I will describe here '''Orange Pi Lite''' and '''Orange Pi One''' (which seems to be no longer manufactured, since 2017-01).

The [[http://orangepi.com/orange-pi-lite]] is a palm sized (69 x 48 mm) computer that plugs into your TV and can use an USB keyboard and an USB mouse. It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. The [[https://linux-sunxi.org/Orange_Pi_Lite|community page]] has some more details.

The '''basics''' are: (for the I/O please see at [[http://orangepi.com/orange-pi-lite]])
 * '''CPU''': Allwinner H3 (ARM A7-quad core)
 * '''RAM''': 512 MB
 * '''Flash''': micro SD-card
 * '''Linux software''': [[https://docs.armbian.com/|Armbian]] is described well.
 * '''Power consumption''': 5 V, Basic 0.3 - 0.5 A + external devices

I will explain here some specific '''Know How''' concerning practical use. Please see the '''picture''' below for details (click on picture to expand).

The '''picture''' below shows the '''Orange Pi Lite''' (!WiFi and Bluetooth version) with the '''serial port''' connected to a '''USB to serial''' converter, in order to setup the '''!WiFi interface'''.


/!\ The serial data wires '''RX, TX and GND''' (or '''RD and TD''') are connected '''1:1''', 115200 Baud 8N1 no handshake.

/!\ Please take care to use the '''3.3 V version''' of the '''serial converter'''. A 5 V version can '''damage''' your Orange Pi.

/!\ If you are using a '''DVI adapter''' on your monitor, you will probably see '''no picture'''. The fix is explained [[OrangePiKnowHow#Screen_resolution_HDMI|later]].

||<tablestyle="float:right;">[[attachment:OrangePi_Lite_DSC06813.jpg|{{attachment:OrangePi_Lite_DSC06813.jpg|attachment:OrangePi_Lite_DSC06813.jpg|width="910"}}]] ||


== Orange Pi Lite ==
Orange Pi Lite is the '''Orange Pi''' version with '''!WiFi and Bluetooth''', without '''Ethernet''' port. A [[http://linux-sunxi.org/File:Orange_pi-lite-v1_1.pdf|schematic]] is available.

A '''sample installation''' of '''Armbian''' on a micro '''SD-card''' (>= 8 GB, class 10) under Mac OS:
{{{
# cd to download folder of "Armbian"
$ cd /Volumes/DAT/HDA8/INSTALL/NAS/OrangePi_Lite/Armbian_5.20_Orangepilite_Debian_jessie_3.4.112_desktop

# find disk number of the SD-card
$ diskutil list # SD-card is disk4

# unmount SD-card
$ diskutil unmountDisk /dev/disk4s1

# copy Armbian image to SD-card
$ sudo dd bs=1m if=Armbian_5.20_Orangepilite_Debian_jessie_3.4.112_desktop.img of=/dev/rdisk4

# eject SD-card
}}}
Line 13: Line 56:
The Linux software [[https://docs.armbian.com/|Armbian]] is also described well.


||<tablestyle="float:right;">[[attachment:OrangePi_Lite_DSC06813.jpg|{{attachment:OrangePi_Lite_DSC06813.jpg|attachment:OrangePi_Lite_DSC06813.jpg|width="905"}}]] ||
I will explain here some specific '''Know How'''.

=== RPi 3, SSH password, WLAN ===
2016-06-28 If you try to connect with '''SSH''' via '''WLAN''' to your '''Raspberry Pi 3''' it can be, that after entering the right '''password''' nothing more happens. This problem is well known, please see [[RaspberryPiKnowHow#Links|Links #13]]. The solution is to edit the SSH daemon config file (server side):
{{{
# edit file /etc/ssh/sshd_config
# add at the end of the file the line:
IPQoS cs0 cs0

# restart the SSH server
$ sudo service ssh restart

# see also:
$ man sshd_config
# IPQoS Specifies the IPv4 type-of-service or DSCP class for connections
# cs = Class selector
# cs0 - meaning: Best Effort
}}}
You can read more about '''Differentiated_services''' [[https://en.wikipedia.org/wiki/Differentiated_services|here]]

=== Armbian software ===
The Armbian (Debian) [[http://www.armbian.com/orange-pi-lite|software]] can be downloaded in a '''XFCE4 Desktop''' or '''Server''' version. Please read the '''Quick Start''' page for informations. I am using the '''Desktop''' version.

/!\ When the software on the micro SD-card is OK, the '''green LED''' blinks, or lits steady.


=== WiFi connect ===
Because the '''Orange Pi Lite''' does '''not''' have an '''Ethernet port''', the '''!WiFi''' connection must be configured via the '''serial port''' (115200 Baud 8N1). To make the connection to a computer with a '''terminal''' ('''PUTTY or !CoolTerm'''), you need an '''USB to serial''' converter ('''3.3 V version only'''), as shown in the '''picture''' above. In my case I did '''not''' need to cross RxD and TxD wires.

/!\ You can use in '''PuTTY''' the '''mouse scroll wheel switch''' to '''insert text''' from the '''clipboard'''.

Next insert the programmed micro '''SD-card''' into the socket of the board and switch on power. In the '''terminal''' you will see:
{{{
U-Boot SPL 2016.09-armbian (Sep 15 2016 - 07:09:20)
DRAM: 512 MiB
Trying to boot from MMC1


U-Boot 2016.09-armbian (Sep 15 2016 - 07:09:20 +0200) Allwinner Technology

CPU: Allwinner H3 (SUN8I 1680)
Model: Xunlong Orange Pi Lite
DRAM: 512 MiB
MMC: SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot/boot.scr
2789 bytes read in 144 ms (18.6 KiB/s)
## Executing script at 43100000
gpio: pin PL10 (gpio 298) value is 1
   Warning: value of pin is still 0
gpio: pin PG11 (gpio 203) value is 1
** File not found /boot/.verbose **
** File not found /boot/.next **
** Unrecognized filesystem type **
** File not found .next **
35912 bytes read in 400 ms (86.9 KiB/s)
3114597 bytes read in 307 ms (9.7 MiB/s)
5025168 bytes read in 455 ms (10.5 MiB/s)
## Loading init Ramdisk from Legacy Image at 43300000 ...
   Image Name: uInitrd
   Image Type: ARM Linux RAMDisk Image (gzip compressed)
   Data Size: 3114533 Bytes = 3 MiB
   Load Address: 00000000
   Entry Point: 00000000
   Verifying Checksum ... OK
Using machid 0x1029 from environment

Starting kernel ...

[sun8i_fixup]: From boot, get meminfo:
        Start: 0x40000000
        Size: 512MB
ion_carveout reserve: 160m@0 256m@0 130m@1 200m@1
ion_reserve_select: ion chipid [0x2004620!
ion_reserve_common: ion reserve: [0x56000000, 0x60000000]!

Debian GNU/Linux 8 orangepilite ttyS0
}}}
Next you will be asked for the '''root''' password ("1234"), and need to change it to a new one. Then you will be asked for a '''user name''' with some not so important details, and a '''user password'''. Preferably the user name is '''pi'''. Then it is much easier to '''copy and paste''' the '''terminal commands''' from my web page.

Then it is time to '''reboot''', in order to login as a user:
{{{
orangepilite login: pi
Password: xxxxx

Linux orangepilite 3.4.112-sun8i #14 SMP PREEMPT Wed Sep 14 20:29:31 CEST 2016 armv7l
  ___ ____ _ _ _ _
 / _ \ _ __ __ _ _ __ __ _ ___ | _ \(_) | | (_) |_ ___
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | | | | | __/ _ \
| |_| | | | (_| | | | | (_| | __/ | __/| | | |___| | || __/
 \___/|_| \__,_|_| |_|\__, |\___| |_| |_| |_____|_|\__\___|
                       |___/

Welcome to ARMBIAN Debian GNU/Linux 8 (jessie) 3.4.112-sun8i
System load: 1.46 Up time: 32 sec
Memory usage: 24 % of 494Mb IP:
CPU temp: 20°C
Usage of /: 33% of 7.2G

# you see, there is not yet an IP number available!
}}}

Now it is time to connect to the '''!WiFi router''', with the setup. The '''network manager''' scans already for available hotspots (router):
{{{
$ sudo nmtui # network manager text user interface
    Set system hostname - orangepilite # for example
    Activate a connection
        Wi-Fi # scan for available hotspots (router)
            FRITZ-7360 - <Activate> # SSID for example
            .....
    Password: xxxx <OK>
    connecting...
    <QUIT>

# check in the router for the IP address
# for example a Fritz!box
orangepilite 192.168.17.171 00:e0:4c:18:0f:ee WLAN 42 Mbit/s
or
$ sudo ifconfig
...
wlan0 Link encap:Ethernet HWaddr 00:e0:4c:18:0f:ee
          inet addr:192.168.17.171 Bcast:192.168.17.255 Mask:255.255.255.0
...
}}}

Then try a '''SSH''' connect for '''remote control''', with a Terminal or PUTTY:
{{{
# Try SSH connect:
$ ssh pi@192.168.17.171
  ___ ____ _ _ _ _
 / _ \ _ __ __ _ _ __ __ _ ___ | _ \(_) | | (_) |_ ___
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | | | | | __/ _ \
| |_| | | | (_| | | | | (_| | __/ | __/| | | |___| | || __/
 \___/|_| \__,_|_| |_|\__, |\___| |_| |_| |_____|_|\__\___|
                       |___/

Welcome to ARMBIAN Debian GNU/Linux 8 (jessie) 3.4.112-sun8i
System load: 0.00 Up time: 25 min
Memory usage: 23 % of 494Mb IP: 192.168.17.171
CPU temp: 36°C
Usage of /: 33% of 7.2G

Last login: Thu Sep 15 07:30:19 2016

$ sudo date MMDDhhmmYYYY # M=Monat, D=Tag, h=Stunde, m=Minute, Y=Jahr
}}}

Now it is time to do an '''software update''' via '''internet''':
{{{
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo shutdown -r # reboot

# kernel 3.4.112-sun8i = linux-image-sun8i (5.25)
# kernel 3.4.113-sun8i = linux-image-sun8i (5.26)

# install the powerful file manager "midnight commander"
$ sudo apt-get install mc
# allow F10 key: Tab Edit->Preferences - remove mark from "Enable the menu accelerator key"
}}}

The following chapters concerning configuration and setup are common for '''the Orange Pi One/Lite'''.


||<tablestyle="float:right;">[[attachment:OrangePi_housing_DSC06921.jpg|{{attachment:OrangePi_housing_DSC06921.jpg|attachment:OrangePi_housing_DSC06921.jpg|width="320"}}]] ||
=== Housing ===
/!\ While inserting the '''Orange Pi board''' into the '''housing''', I unfortunately '''broke''' the '''micro SD-card''', because of the land between '''micro SD-card outcut''' and '''camera cable outcut'''.

In order to avoid that in the future, I cut out the land, as you can see in the '''picture''' on the right. The '''lower''' housing still has the lend, while it was '''cut out''' in the '''upper''' housing.

== Orange Pi One ==
/!\ It looks like, that this board no longer manufactured, since 2017-01.

[[http://www.orangepi.org/orangepione/|Orange Pi One]] is the version with '''Ethernet''' port, without '''!WiFi and Bluetooth'''. A [[http://linux-sunxi.org/File:ORANGE_PI-ONE-V1_1.pdf|schematic]] is available.

Because it is so cheap (about 25 EUR ), it is very attractive to use it in all kinds of embedded computer projects. The offer is from [[https://www.aliexpress.com]], search for '''Orange Pi One SET7''', it contains an Orange Pi One + Transparent ABS case + power cable + 8 GB class 10 micro SD card.


=== Armbian software ===
The Armbian (Debian) [[http://www.armbian.com/orange-pi-one/|software]] can be downloaded in a '''XFCE4 Desktop''' or '''Server''' version. Please read the '''Quick Start''' page for informations. I am using the '''Desktop''' version.

/!\ When the software on the micro SD-card is OK, the '''green LED''' blinks, or lits steady.


== Shared software additions ==
The following software additions will make it more comfortable to work with the '''Orange Pi'''.


=== Screen resolution HDMI ===
If you are using a '''HDMI to DVI''' adapter you will probably see no '''picture''' on your monitor. For changing the resolution on your monitor, and a fix for the DVI Adapter, a [[https://forum.armbian.com/index.php/topic/752-tutorial-h3disp-change-display-settings-on-h3-devices/|tool]] is provided:
{{{
Desktop size: 1024 x 768 # initial setup

$ sudo h3disp
Usage: h3disp [-h/-H] -m [video mode] [-d] [-c [0-2]]

############################################################################

 This is a tool to set the display resolution of your Orange
 Pi by patching script.bin.

 In case you use an HDMI-to-DVI converter please use the -d switch.

 The resolution can be set using the -m switch. The following resolutions
 are currently supported:

    480i use "-m 480i" or "-m 0"
    576i use "-m 576i" or "-m 1"
    480p use "-m 480p" or "-m 2"
    576p use "-m 576p" or "-m 3"
    720p50 use "-m 720p50" or "-m 4"
    720p60 use "-m 720p60" or "-m 5"
    1080i50 use "-m 1080i50" or "-m 6"
    1080i60 use "-m 1080i60" or "-m 7"
    1080p24 use "-m 1080p24" or "-m 8"
    1080p50 use "-m 1080p50" or "-m 9"
    1080p60 use "-m 1080p60" or "-m 10"
    1080p25 use "-m 1080p25" or "-m 11"
    1080p30 use "-m 1080p30" or "-m 12"
    1080p24_3d use "-m 1080p24_3d" or "-m 13"
    720p50_3d use "-m 720p50_3d" or "-m 14"
    720p60_3d use "-m 720p60_3d" or "-m 15"
    1080p24_3d use "-m 1080p24_3d" or "-m 23"
    720p50_3d use "-m 720p50_3d" or "-m 24"
    720p60_3d use "-m 720p60_3d" or "-m 25"
    1080p25 use "-m 1080p25" or "-m 26"
    1080p30 use "-m 1080p30" or "-m 27"
    4kp30 use "-m 4kp30" or "-m 28"
    4kp25 use "-m 4kp25" or "-m 29"
    800x480 use "-m 800x480" or "-m 31"
    1024x768 use "-m 1024x768" or "-m 32"
    1280x1024 use "-m 1280x1024" or "-m 33"
    1360x768 use "-m 1360x768" or "-m 34"
    1440x900 use "-m 1440x900" or "-m 35"
    1680x1050 use "-m 1680x1050" or "-m 36"

 Two examples:

    'h3disp -m 1080p60 -d' (1920x1080@60Hz DVI)
    'h3disp -m 720i' (1280x720@30Hz HDMI)

 You can also specify the colour-range for your HDMI-display with the -c switch.

 The following values for -c are currently supported:

    0 -- RGB range 16-255 (Default, use "-c 0")
    1 -- RGB range 0-255 (Full range, use "-c 1")
    2 -- RGB range 16-235 (Limited video, "-c 2")

Now trying to patch script.bin with your settings. Successfully finished. Please reboot for changes to take effect

# setup for DVI converter (proposal with DVI converter use: 1024x768)
$ sudo h3disp -m 32 -d
}}}
Line 41: Line 305:
First you have to install on the Raspberry Pi a '''VNC Server''', preferably the '''tightvncserver''':
{{{
First you have to install on the Orange Pi a '''VNC Server''', preferably the '''tightvncserver''':

/!\ The '''password length''' must be between 5-8 characters. If it is '''longer''', it will be '''truncated to 8'''.
{{{
# if there was time to the last update, do it now.
Line 48: Line 315:
$ sudo shutdown -r

# prepare an install folder
$ mkdir Install
$ cd Install
Line 65: Line 337:
# VNC server beenden # finish VNC server daemon
Line 67: Line 339:
}}}

In order to '''change the password''', use the [[https://www.tightvnc.com/vncpasswd.1.php|command:]]
{{{
# Path: $HOME/.vnc/passwd

$ vncpasswd
enter password ENTER
enter password to verify ENTER
Line 74: Line 355:
# Check the user name in line 16 and adopt if necessary. At the moment it is set to "pi".
# For safety reasons the user should NOT be named "root".
$ cat tightvncserver-init.txt # just show file
or
$ nano tightvncserver-init.txt # edit file
Line 77: Line 364:
# Check the user name in line 16 and adopt if necessary. At the moment it is set to "pi".
# For safety reasons the user should NOT be named "root".
Line 89: Line 373:
# Manual stop
$ sudo /etc/init.d/tightvncserver stop
Line 91: Line 378:

# Manual stop
$ sudo /etc/init.d/tightvncserver stop
Line 100: Line 384:
Unfortunately the '''clipboard''' just works in one direction only. The other direction can be enabled with the programm '''autocutsel''' on the '''Raspberry Pi''':
{{{
# Install program to synchronise the clipboard
Unfortunately the '''clipboard''' just works in one direction only. The other direction can be enabled with the programm '''autocutsel''' on the '''Orange Pi''':
{{{
# Install program to synchronise the clipboard for VNC use.
Line 106: Line 390:
# edit /home/pi/.vnc/xstartup
# append at the third line:
$ nano ~/.vnc/xstartup  # edit file
# insert at the third line the following line:
Line 123: Line 407:
 * '''Mac OS X''' Mavericks 10.9.2:
  * In Finder you cab call: Goto/connect to server, Server address (e.g.): vnc://192.168.17.187:5901 . Unfortunately the build in '''VNC client''' does not support '''alt gr characters'''.
  * RealVNC: VNC-Viewer-5.1.1: supports the '''alt gr characters'''. Address (z.B.): 192.168.17.187:5901
 * '''Mac OS X''' Sierra 10.12.2:
  * In '''Finder''' you select: Goto/connect to server, Server address (e.g.): vnc://192.168.17.171:5901 . Unfortunately the build in '''VNC client''' does not support '''alt gr characters'''.
  * RealVNC: VNC-Viewer-5.1.1: supports the '''alt gr characters'''. Address (e.g.): 192.168.17.171:5901
Line 135: Line 419:
$ cd /etc/sudoers.d
# create a new parameter file
$ sudo touch xauthority
# edit file
$ sudo visudo xauthority
# enter the following 5 lines and save to file:
# setup for VNC with sudo
# example of /etc/sudoers
Line 144: Line 422:

$ sudo cat /etc/sudoers # show file

$ sudo nano /etc/sudoers # edit file

# append the 2 following lines to the end of the file:
Line 147: Line 431:
# Add these few lines to ~/.bashrc:

if [ -z "$XAUTHORITY" ]; then
    if [ -e $HOME/.Xauthority ]; then
        export XAUTHORITY=$HOME/.Xauthority;
    fi;
fi

# logout and login again
$ sudo nano ~/.bashrc # edit file
# Append the following line to ~/.bashrc: (for VNC + tkinter)
if [ -z "$XAUTHORITY" ] ; then if [ -e $HOME/.Xauthority ] ; then export XAUTHORITY=$HOME/.Xauthority; fi; fi
# check edit
$ cat ~/.bashrc

# restart, to make it work
$ sudo shutdown -r
Line 165: Line 449:
# for screen shot install:
$ sudo apt-get install scrot eog # eog = Eye Of Gnome = picture viewer
Line 177: Line 464:
||<tablestyle="float:right;">[[attachment:RPi_PSU_5V2A_Probe_DSC05296.jpg|{{attachment:RPi_PSU_5V2A_Probe_DSC05296.jpg|attachment:RPi_PSU_5V2A_Probe_DSC05296.jpg|width="320"}}]] ||
=== PSU Problem ===
In order to have enough current for some peripherals, I bought a '''power supply 5 V, 2 A''' from China. Have a look to the name plate, in the '''picture''' above (click to enlarge).

With that switching power supply the Raspberry Pi works in principle, but the '''HDMI output''' did not show any information on the monitor. So, I measured the voltage. With no load I measured 5.6 V, with 0.7 A load 5.5 V.


First I thought that the voltage was too high and searched for a method to reduce the voltage to 5.0 V under load. Fortunately you can open the housing with one screw. The circuit looks pretty standard. At the secondary side '''TL431''' adjustable zener diode is used. Looking at the voltage divider for the '''Ref''' Input of the TL431, it was obvious that the voltage is so hight, with R1 = 2k7, R2 = 2k2 (data sheet naming).

||<tablestyle="float:right;">[[attachment:RPi_PSU_5V2A_22k_DSC05426.jpg|{{attachment:RPi_PSU_5V2A_22k_DSC05426.jpg|attachment:RPi_PSU_5V2A_22k_DSC05426.jpg|width="320"}}]] ||
By soldering a '''27k resistor''' (1/10 W size) parallel to the 2k7 resistor the output voltage was reduced to 5.0 V under load. But that '''did not solve the problem''' with the dark monitor.

'''Next step''' was to measure the output voltage with an '''oscilloscope'''. Fortunately I had '''two power supplies''', one original, and the other already modified with the choke.

You see in the upper trace (CH1) a high frequency (about 5 MHz) oscillation with an '''amplitude''' of 700 mVpp. It happened at the '''switching transient''' only, but not always the same strength.


||<tablestyle="float:right;">[[attachment:RPi_PSU_5V2A_org_choke.gif|{{attachment:RPi_PSU_5V2A_org_choke.gif|attachment:RPi_PSU_5V2A_org_choke.gif|width="395"}}]] ||
The switching frequency was about 8 KHz. It looks like, that it is in synchronism with the 50 Hz of the 230 VAC supply.

This was measure at the '''GPIO''' connector of the Raspberry Pi, please see the first '''picture'''.

After some trial I added a '''choke in series''' of the +5 V line. The choke has a ferrite core and must stand the 2 A maximum current. The resistor of the coil I measured with 0.05 Ohm (12 turns, L = 2.5 uH).

The result you can see in the lower trace (CH2) of the '''oscilloscope''' diagram that the amplitude was reduced to 400 mVpp. The second power supply showed 280 mVpp only, after the modification. With the choke and a '''100 uF capacitor to ground''' the signal was less than 100 mV.

This '''solved the problem''' with the blank monitor. Hence, it was not the over voltage of the power supply, instead the large amplitude of the 5 MHz oscillation.

||<tablestyle="float:right;">[[attachment:RRPi_PSU_5V2A_22k_DSC05427.jpg|{{attachment:RPi_PSU_5V2A_22k_DSC05427.jpg|attachment:RPi_PSU_5V2A_22k_DSC05427.jpg|width="240"}}]] ||
The '''picture''' on the right you can see '''position of the choke''' on the circuit board. Fortunately there is some free space on the circuit board to fit the choke. The '''+5 V trace''' on the copper side must be '''cut''' for the choke to work, see the above '''picture''' of the PCB.

In order to increase the output voltage under load a little bit, I added a 22k resistor parallel to the 2k2 resistor on board. The output voltage under load (1 A) is now 5.2 V.

=== PSU Problem #2 ===
2 years later I bought a set of 5 pieces '''power supply 5 V, 2 A''' from China (banggood.com, Prod-ID 1033702), in the hope, they will be better, than the first one. This time, the output voltage was '''too low''':
{{{
# Load was the Raspberry Pi 2B, about 0.6 to 0.7 A
Voltages: 4.80 V, 4.64 V, 4,70 V, 4,70 V, 4,71 V
}}}

So, I tried to modified the PSU by myself, in order to come closer to the specification.

||<tablestyle="float:right;">[[attachment:PSU_5V2A_housing_DSC06518.jpg|{{attachment:PSU_5V2A_housing_DSC06518.jpg|attachment:PSU_5V2A_housing_DSC06518.jpg|width="320"}}]] ||
This time, the housing had no longer 2 screws for opening. You have to use a knife and a small flat screw driver to open the housing, by opening the '''4 plastic interlocks'''.

Please see the '''picture''' to the right for the '''position of the interlocks'''.

At the secondary side of the power supply a '''TL431''' programmable shunt regulator is used. Looking at the voltage divider for the '''Ref''' Input of the TL431, I found a '''resistor R102''' (15 KOhm), connected to +5 V.

By adding a 39 Kohm resistor (SMD 0805) to ground, I could lift the output voltage by 0.5 V. The closest Ground point for the resistor I found at '''capacitor C104'''. The connection to resistor R102 was made by a thin wire-wrap wire.

After modifying all 5 units, it shows up, that I need '''different resistors''', 39 k, 47 k and 56 k to achieve the specification of +5 V +/- 5%.

||<tablestyle="float:right;">[[attachment:PSU_5V2A_mod3k9m_DSC06519.jpg|{{attachment:PSU_5V2A_mod3k9m_DSC06519.jpg|attachment:PSU_5V2A_mod3k9m_DSC06519.jpg|width="320"}}]] ||
Please see the '''picture''' to the right for the wiring (click on the picture to expand).

Another '''problem''' is the '''high resistance''' of the '''power cable''' to the '''micro USB plug'''. At a current of about 0.75 A (Raspberry Pi 2B) the cable + plug '''voltage loss''' is about '''0.5 V'''. That looks like '''AWG 26''' wires (0.128 mm2) which have a specific resistance of 132 Ohm/km. With a cable length of 2 x 90 cm that will be 0.24 Ohm. So, at the rated current of 2 A this will be a '''voltage loss''' of about 0.48 V.

As a counter measure I cutted off the original cable, about 15 mm from their ends, and soldered a thicker cable (AWG 18 = 0.75 mm2, Schlauchleitung H03 VVH2-F 2x0,75 mm² schwarz) in place, isolating with hot shrink tube. Now the '''voltage loss''' drops to '''0.3 V at 1.5 A'''. This cable will bring in a '''voltage loss''' of about 0.08 V at 2 A.

But there is still some unknown '''current limitation''' left. The current limit at +5 V - 5% of the single units after all modification is:
{{{
1.0 A, 1.2 A, 1.5 A, 1.5 A, 1.5 A
}}}
This time the '''output voltage ripple''' was much better than before, just 80 mVpp at 56 KHz at 0.7 A.

For this '''low price''' of 2.50 EUR a piece (including shipping), those 1.5 A are acceptable, you just have to know. For more details have a look at the [[RaspberryPiKnowHow#Links|Links #11 and #12]]

=== Terminal TAB command complete ===
Unfortunately the function '''command complete''' in the '''terminal''' with the '''TAB''' key does not work in XFCE, see [[http://stackoverflow.com/questions/23418831/command-line-auto-complete-tab-key-not-work-in-terminal-for-ubuntu|here]].

The quick solution is to use '''CTRL/STRG TAB''' instead '''TAB'''. The better solution is to work at the reason. XFCE has captured the '''TAB key''' for the funtion '''switch_window_key''', but I think, the function '''command complete''' is more important. So what to do:
{{{
Applications Menu->Settings->Settings Manager->Settings Editor xfce4-keyboard-shortcuts
    <Super>Tab -> edit value: delete text "switch_window_key"

# to make it work:
$ sudo shutdown -r # reboot
}}}

=== Often use programs ===
In '''XFCE''' often used programs, like '''Terminal, File Manager, Texteditor and File Finder''' are on a low convenience level, to save resources. Because I often work with Ubuntu, I want to have the same often used programs. The installation is easy:
{{{
$ sudo apt-get install nautilus gnome-terminal gedit locate
# Menu Settings->Preferred Applications->Tab Utilities
# Nautilus for file manager
# Gnome-Terminal for terminal
# click on button 'Close'

$ sudo updatedb # for locate, to immediately index file names

# "List View" + "tree view" in file manager Nautilus, version 3.14.1
# Click on folder icon in upper left edge of the window.
# Select: Preferences->
# Tab Views: Default view->View new folders using: List View
# Tab Display->List View-> check mark "Navigate folders in a tree"
}}}

=== Samba share ===
For easier '''file sharing''' in the in-house network, I like to have a '''Samba share''' installed:
{{{
$ sudo apt-get install nautilus-share
$ sudo apt-get install samba

$ sudo adduser $USER sambashare

# edit /etc/samba/smb.conf, add line in global section
    usershare owner only = false

# test if smb.conf is ok:
$ sudo service smbd restart

# for adduser to work, reboot:
$ sudo shutdown -r
# test if user was added to group "sambashare"
$ groups
pi dialout sudo audio video plugdev netdev bluetooth sambashare

# set password for samba, same as user password
$ sudo smbpasswd -a pi

# create samba share with Nautilus
   select in Nautilus the folder /home/pi # user
   click with right mouse button on the icon
   click on "sharing options"
   in window " Folder sharing" mark "share this folder"
       share name: pi-orange
       comment: orange lite
       option: mark "Allow others to create and delete files in this folder"
   click on "Create Share"
   click on: add the permissions automatically

# change owner for easier access:
$ sudo chown pi:pi /var/lib/samba/usershares/pi-orange

# test if you can connect the share
}}}


||<tablestyle="float:right;">[[attachment:Orange-pi-lite_panel-additions_364.png|{{attachment:Orange-pi-lite_panel-additions_364.png|attachment:Orange-pi-lite_panel-additions_364.png|width="364"}}]] ||
=== XFCE4 panel additions ===
I want to see in the panel some information from this computer:
 1. '''actual CPU speed'''
 2. '''CPU load, memory use, swap use'''
 3. '''CPU temperature'''
 4. '''Date'''
In order to get the '''date''' below the '''time''' you can change in the [[http://winaero.com/blog/how-to-display-clock-with-date-in-vertical-xfce-panel/|clock properties]], see the [[http://docs.xfce.org/xfce/xfce4-panel/clock|syntax]]:
{{{
# Clock Options->Format:Custom format: %H:%M%n%F
# %n = new line
# %F = Full date; same as %Y-%m-%d, e.g. 2017-04-17
}}}
For all those informations you can get '''plugins''' for the '''xfce4 panel'''. First you have to install them:
{{{
# CPU Information - CPU Frequency Monitor (About)
$ sudo apt-get install xfce4-cpufreq-plugin

# System Load Monitor version 1.1.1 - (About)
# http://goodies.xfce.org/projects/panel-plugins/xfce4-systemload-plugin
$ sudo apt-get install xfce4-systemload-plugin

# xfce4-genmon-plugin 3.5 - Generic Monitor (About)
$ sudo apt-get install xfce4-genmon-plugin
}}}

All plugins are installed in the '''panel''' in the same way:
{{{
Right click on Panel
    Panel
        Add new item
            Left click on <plugin name> to mark
            Button Add
            Button Close
  CPU Frequency Monitor - click on Add
  System Load Monitor - click on Add
  Generic Monitor - click on Add + Close

# Right click on Panel mem->properties: remove mark from "Uptime monitor" (usually not needed)
# Click on Close
}}}

While the first 2 plugins work immediately, the '''CPU temperature''' needs more effort. You need to prepare your own '''data collection file''':
{{{
# create folder in /home/pi
$ mkdir Install

# create control file
$ touch Install/cpu-temp_panel.sh

# edit control file
$ nano Install/cpu-temp_panel.sh
# insert the following text:
#!/bin/bash
# http://goodies.xfce.org/projects/panel-plugins/xfce4-genmon-plugin
echo "<txt>"$(cat /etc/armbianmonitor/datasources/soctemp | sed 's/\ \ */ /g' | cut -f2 -d" ")"°C</txt>"
# finish with: CTRL/STRG o ENTER
               CTRL/STRG x

# give file "execute" permission
$ chmod ug+x cpu-temp_panel.sh

# right click on the just installed panel plugin and select properties:
  Command: /home/pi/Install/cpu-temp_panel.sh # adopt the user name, if not "pi"
  Label: CPU_ (1 space)
  Period: 5 s
}}}
Now you should see the previous mentioned computer informations, like to see on the '''screen shot''' above.


=== Python, TKinter ===
'''Python2''' is already installed, but some support is missing.
{{{
# Install Python TKinter package
$ sudo apt-get install python-tk

# Install Python integrated development environment
$ sudo apt-get install idle
}}}

'''Python3''' is already installed, but some support is missing.
{{{
# Install Python3 package installer
$ sudo apt-get install python3-pip

# Install Python3 TKinter package
$ sudo apt-get install python3-tk

# Install Python3 integrated development environment
$ sudo apt-get install idle3
}}}

Test the '''Tkinter installation''' with a little program:
{{{
# create file
$ touch Install/tkinter-test.py

# edit file witth the following lines
$ nano Install/tkinter-test.py
# Python 2/3 Tkinter test program: tkinter_test.py
# 2016-12-28 RudolfReuter
try:
    from Tkinter import *
except ImportError:
    from tkinter import *

class Application(Frame):
    def say_hi(self):
        print("hi there, everyone!")

    def createWidgets(self):
        self.QUIT = Button(self)
        self.QUIT["text"] = "QUIT"
        self.QUIT["fg"] = "red"
        self.QUIT["command"] = self.quit

        self.QUIT.pack({"side": "left"})

        self.hi_there = Button(self)
        self.hi_there["text"] = "Hello",
        self.hi_there["command"] = self.say_hi

        self.hi_there.pack({"side": "left"})

    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()
# end of file

# must be started in the Terminal in the GUI
$ python Install/tkinter-test.py
$ python3 Install/tkinter-test.py
}}}
||<tablestyle="float:right;">[[attachment:Orange_pi_tkinter-test.png|{{attachment:Orange_pi_tkinter-test.png|attachment:Orange_pi_tkinter-test.png|width="520"}}]] ||
The '''screenshot''' on the right shows the started test program '''tkinter-test.py''', which works as well with '''Python 2''' as '''Python 3'''.

The used '''Terminal''' is the '''GNOME-Terminal'''.

The '''Graphical User Interface''' (GUI) desktop is '''xfce4'''.

The xfce4 '''desktop''' is shown in the '''RealVNC viewer''' on Mac OS.


=== Wobbulator ===
I have a home made [[RaspberryPiWobbulator|Wobbulator, RF Network Analyzer]] working with a '''Raspberry Pi'''. I liked to know, if it also works with the '''Orange PI Lite''', with a '''!WiFi''' network connection to a laptop computer. That offers the possibility to run the application '''portable''' with a '''5 V powerbank'''. The average '''power consumption''' in this case is about '''0.4 A'''.

Fortunately the '''26 pin flatcable''' connector was hardware compatible, just the software needed some modification. A [[attachment:wobbulator_orangePi_patch.txt|patch file]] can be downloaded, to show the difference in '''hardware access''' from '''Raspberry Pi''' to the '''Orange Pi'''.

/!\ Install first [[OrangePiKnowHow#GPIO_Python]].

The program [[attachment:wobbulator2.6.3o.py]] is already adopted to the '''Orange Pi'''. Because it is a '''Python3''' graphical (TKinter) program, it must be started from the '''XFCE4 GUI''', in a '''terminal''', see a sample run:
{{{
$ sudo python3 ./wobbulator2.6.3o.py
[sudo] password for pi:
start pgm
tk init
start mainloop
sweep
bias [V] 0.8035714285714286
Dauer (s) 1.0870912075042725
}}}

||<tablestyle="float:right;">[[attachment:Wobbulator_OrangePiLiteXFCE.jpg|{{attachment:Wobbulator_OrangePiLiteXFCE.jpg|attachment:Wobbulator_OrangePiLiteXFCE.jpg|width="910"}}]] ||
The '''screenshot''' above shows the '''Orange Pi Lite''' desktop with the program '''wobbulator2.6.3o.py''' running.

The test object was a '''10.7 MHz filter''', scanned from '''1 MHz''' to '''31 MHz''' with an increment of '''100 KHz''' (300 steps). The '''input RF-level''' to the filter was about '''0 dBm'''. The '''sweep time''' was 1.1 seconds.
You can see, that the filter has a '''side peak''' at about half the major frequency (5.35 MHz), which is about 23 dB below the filter working frequency amplitude (-9 dBm).

=== Clone SD-card ===
/!\ Because of different net storage capacity values, it is advisable to use '''95%''' only of a SD-card. That avoids '''problems''' when cloning an image to a slightly smaller SD-card.

If a SD-card fails, it is the quickst way to restore it from a back up file. In order to make it easier, some example commands are shown:
{{{
# show the mounted mass storage
$ df -h

# save a SD-card image (16 GB)

# change disk to a >16 GB free folder
$ cd /media/<user>/<disk-folder>
# unmount SD-card
$ umount ../<SD-card-folder>
# save image (class 10, duration about 20 min.)
$ sudo dd bs=4M if=/dev/sdb of=orangepilight.img
# remove SD-card
-----------------------
# restore SD-card image

# change disk to the SD-card image folder
$ cd /media/<user>/folder
# insert new SD-card
# unmount SD-card
$ umount /media/<user>/xxx
# restore image (class 10, duration about 25 min.)
$ sudo dd bs=4M if=orangepilight.img of=/dev/sdb # or other device

# change file /etc/hostname, e.g. orangepilight1
# remove SD-card
}}}
Line 248: Line 742:
 * '''shutdown Orange Pi'''
 {{{
 $ sudo shutdown -h # Halt after shutdown (power off)
 }}}
 * Add '''sbin''' and '''/usr/sbin''' to path:
 {{{
 # edit /home/pi/.bashrc, add the following line after the "esac" line
 export PATH="$PATH:/sbin:/usr/sbin"

 # activate
 $ source .bashrc

 $ echo $PATH
 PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin
 }}}
 * '''Build date of the software''':
 {{{
 $ uname -a
  Linux orangepilite 3.4.112-sun8i #10 SMP PREEMPT Sun Oct 23 16:06:55 CEST 2016 armv7l GNU/Linux
 }}}
 * '''find newer files''', [[http://stackoverflow.com/questions/6964747/find-all-files-recursively-newer-than-given-time|explanation]]:
 {{{
 # Syntax
  find /directory -newermt $(date +%Y-%m-%d -d '1 day ago') -type f -print
 # example
 $ find moin-1.9.9/wiki/data/pages -newermt $(date +%Y-%m-%d -d '1 month ago') -type f -print

 # Delete all Mac OS control files:
 $ sudo find . -name "._.DS_Store" -type f -delete
 }}}
 * '''Test file system''' at boot time
 {{{
 $ sudo touch /forcefsck

 # Restart OrangePi
 $ sudo shutdown -r
 }}}
 * Get '''root shell'''
 {{{
 $ sudo su
 # Exit root shell
 $ exit # or CTRL/STRG D
 }}}
 * '''update/upgrade''': If you login via '''serial port''' or '''SSH''' and get an '''upgrade message''' the action is:
 {{{
 # number of updated packages in total
 [ 16 updates to install: apt-get upgrade ]

 # update the package lists
 $ sudo apt-get update

 # install the upgrade packages (of the installed packages only)
 $ sudo apt-get upgrade
 }}}
 * '''Power button''': [[http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=1339|info 1]], [[http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=28|info 2]]
Line 250: Line 798:
  * I tested with good success the above mentioned wireless mouse and keyboard, see on the first '''picture''' on this page the wireless dongle. The benefit is, that you have now '''1 free USB port'''.<<BR>> Unfortunately it '''does not work''' in Raspbian version 2013-02-09, just in version 2014-01-07.
 * '''Problem with Flicker in the HDMI video''' and periodic shutdown (black screen)
  * the +5 V power supply is weak (< 4.7 V)
  * Try [[http://elinux.org/R-Pi_Troubleshooting#Interference_visible_on_a_HDMI_or_DVI_monitor|Interference_visible_on_a_HDMI_or_DVI_monitor]]
  * Edit file '''/boot/config.txt''' and remove comment:
  {{{
  $ sudo nano /boot/config.txt
    config_hdmi_boost=4
  # save file

  # reboot Raspberry Pi
  }}}


=== Links ===
  * I tested with good success the above mentioned wireless mouse and keyboard, see on the first '''picture''' on this page the wireless dongle. The benefit is, that you have now '''1 free USB port'''.
 * Check for '''Debian version''':
 {{{
 $ cat /etc/issue
 Debian GNU/Linux 8 \n \l
 }}}


== Hardware IO ==
Here are documented hardware I/O related informations.


=== Analog ===
There is no '''Analog to Digital''' converter, but you have a '''Pulse Wide Modulation''' (PWM) output.


=== Audio ===
There is a '''microphone''' for '''Audio input'''. '''Audio output''' can be achieved via '''HDMI''' device (TV, Monitor).


=== GPIO ===
'''Wiring''' Orange Pi is a '''GPIO library''', explained [[http://www.orangepi.org/Docs/WiringPi.html|here]], and can be [[https://github.com/zhaolei/WiringOP|clone with git, or downloaded and unzipped in user folder]].
{{{
$ cd ~/Install
$ git clone https://github.com/zhaolei/WiringOP.git
$ cd WiringOP

or with download
$ cd WiringOP-h3

# make executable
$ chmod +x ./build

# build and install
$ sudo ./build

# kernel modules:
[Compile] wiringPi.c
[Compile] wiringSerial.c
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
[Compile] wiringPiI2C.c
[Compile] softPwm.c
[Compile] softTone.c
[Compile] softServo.c
[Compile] mcp23008.c
[Compile] mcp23016.c
[Compile] mcp23017.c
[Compile] mcp23s08.c
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
[Compile] mcp3002.c
[Compile] mcp3004.c
[Compile] mcp4802.c
[Compile] mcp3422.c
[Compile] max31855.c
[Compile] max5322.c
[Compile] sn3218.c
[Compile] drcSerial.c

# Device libraries
[Compile] ds1302.c
[Compile] maxdetect.c
[Compile] piNes.c
[Compile] gertboard.c
[Compile] piFace.c
[Compile] lcd128x64.c
[Compile] lcd.c
[Compile] piGlow.c

NOTE: To compile programs with wiringBP v2, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).
}}}

The '''pin''' assignement for '''WiringOP''' is (see also [[http://elinux.org/RPi_BCM2835_GPIOs|BCM2835 GPIOs]]):
{{{
$ gpio 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 | ALT4 | 0 | 19 || 20 | | | 0v | | |
 | 65 | 13 | MISO | ALT4 | 0 | 21 || 22 | 0 | ALT3 | RTS2 | 6 | 2 |
 | 66 | 14 | SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | 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 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | TxD1 | 28 | 198 |
 | | | 0v | | | 39 || 40 | 0 | ALT3 | RxD1 | 29 | 199 |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
 +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+
BCM = Broadcom SOC channel
wPi = Wiring Orange Pi
Mode = I/O mode
Physical = Pin number of 40 pin GPIO connector
}}}

The '''Pin''' assignement for the utility '''gpio''' in '''armbian''' (2016-09)
{{{
WiringPi vs. BCM, GPIO, Port Pin numbering
     WiringPi BCM GPIO-r2 Port Pin Function
     ──────────────────────────────────────────────
         0 1 17 PA1 11 RxD2
         1 110 18 PD14 12 (PWM)
         2 0 27 PA0 13 TxD2
         3 3 22 PA3 15 CTS2
         4 68 23 PC4 16
         5 71 24 PC7 18
         6 2 25 PA2 22 RTS2
         7 6 4 PA6 7
         8 12 2 PA12 3 I2C: SDA0
         9 11 3 PA11 5 I2C: SCL0
        10 67 8 PC3 24 SPI: CE0
        11 21 7 PA21 26 SPI: CE1
        12 64 10 PC0 19 SPI: MOSI
        13 65 9 PC1 21 SPI: MISO
        14 66 11 PC2 23 SPI: SCLK
        15 13 14 PA13 8 TxD3
        16 14 16 PA14 10 RxD3
        21 7 5 PA7 29
        22 8 6 PA8 31
        23 9 13 PA9 33
        24 10 19 PA10 35
        25 20 26 PA20 37
        26 200 12 PG8 32 RTS1
        27 201 16 PG9 36 CTS1
        28 198 20 PG6 38 TxD1
        29 199 21 PG7 40 RxD1

# Examples:
# Switch LED on pin 11 (PA1) ON and OFF
# gpio numbering
$ gpio -g mode 17 output
$ gpio -g write 17 1
$ gpio -g write 17 0
# or BCM numbering
$ gpio mode 1 output
$ gpio write 1 1
$ gpio write 1 0
# or 40 pin connector numbering
$ gpio -1 mode 11 output
$ gpio -1 write 11 1
$ gpio -1 write 11 0
}}}

A good information is [[http://www.cnx-software.com/2015/09/26/status-of-orange-pi-boards-gpio-support/|here]]. An example:
{{{
$ sudo modprobe gpio-sunxi
$ sudo ls /sys/class/gpio_sw/
PA0 PA10 PA14 PA21 PA6 PA8 PC4 PD14 PG7 PG9
PA1 PA13 PA2 PA3 PA7 PA9 PC7 PG6 PG8

$ sudo echo 1 > /sys/class/gpio_sw/PA1/data
$ sudo echo 0 > /sys/class/gpio_sw/PA1/data
}}}

More '''Python GPIO''' examples are [[http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=523&extra=&page=1|here]].

[[https://github.com/duxingkei33/orangepi_PC_gpio_pyH3|orangepi_PC_gpio_pyH3 - Python GPIO library]], see also: [[http://raspberrypi.stackexchange.com/questions/12966/what-is-the-difference-between-board-and-bcm-for-gpio-pin-numbering|gpio pin numbering differences]]

=== GPIO Python ===
{{{
# Install
$ sudo apt-get install python-dev git make gcc
$ cd /home/pi/Install
$ git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3.git
$ cd orangepi_PC_gpio_pyH3
$ sudo python setup.py install

# also for Python3
$ sudo apt-get install python3-dev
$ sudo python3 setup.py install

# Install kernel module
$ sudo modprobe gpio-sunxi

# see, if loaded
$ lsmod | grep gpio
gpio_sunxi 8269 0

$ cd ..
# create testfile led_pa1.py
$ touch led_pa1.py

# copy and paste (mouse) the following program in file led_pa1.py
$ nano led_pa1.py
# -*- coding: utf-8 -*-
# 2016-12-25 program: led_pa1.py

from pyA20.gpio import gpio
from pyA20.gpio import port
from pyA20.gpio import connector
import time

COUNT = 3
#LED = port.PA1
LED = connector.gpio1p11 # gpio1p11 = PA1
# PWR_LED = port.POWER_LED # does NOT work
STAT_LED = port.STATUS_LED
gpio.init()
gpio.setcfg(LED, gpio.OUTPUT)
# STATUS_LED is already set to output

for _ in xrange(COUNT):
    gpio.output(LED,True)
    gpio.output(STAT_LED,True)
    time.sleep(1.0)
    gpio.output(LED,False)
    gpio.output(STAT_LED,False)
    time.sleep(1.0)
# end of file
                                                           +------+ LED
# connect LED to pin 11 (PA1) of 40 pin connector: pin 11 -| 220R |--|>|- pin 9 0V (GND)
                                                           +------+
# start test program:
$ sudo python ./led_pa1.py
# Status LED and LED on pin 11 should blink 3 times.
}}}


=== I2C bus ===
Also called '''TWI''' (Two Wire Interface, maybe clock stretching is not supported). [[http://www.i2c-bus.org|I2C-bus]] was designed by Philips in the early ’80s to allow easy communication between components which reside on the same circuit board. Philips Semiconductors migrated to NXP in 2006.

Lets see, what is already on board:
{{{
~$ ls -ls /dev/i2*
0 crw------- 1 root root 89, 0 Dec 26 23:08 /dev/i2c-0
0 crw------- 1 root root 89, 1 Dec 26 23:08 /dev/i2c-1
}}}

Make '''armbian''' more [[https://forum.armbian.com/index.php/topic/1851-rfc-make-armbian-more-iot-friendly/|user friendly]]:
{{{
# Install i2c-tools smbus
$ sudo apt-get install i2c-tools python-smbus

# change i2c device group from root to i2c
$ sudo chown root:i2c /dev/i2c*
$ sudo adduser $USER i2c
# logout / login
or
$ sudo shutdown -r
# test groups
$ groups
pi dialout sudo audio video plugdev netdev bluetooth sambashare i2c
# Now i2c access needs no longer "root" rights, just group "i2c" rights.

# If "i2cdetect" is not found, add "sbin" to the environment "path".

# connect an Adapter PCF8574 (I2C address 0x27) to pin 3 = SDA and pin 5 = SCK
$ /usr/sbin/i2cdetect -y 0
     0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
...
}}}

There is a nice test program for '''I2C LCD''' (16 x 2 characters, Adapter PCF8574). It needs a little modification, then it works.
{{{
# LCD wire connection to 40 pin connector: GND to pin 6, +5 V to pin 4, SDA to pin 3, SCK to pin 5

$ cd Install
# download example
$ git clone https://github.com/sweetpi/python-i2c-lcd.git
$ cd python-i2c-lcd

# edit file lcddriver.py
# change BUS = 1 to BUS = 0

# write the numbers 1234567 to the LCD
$ python display.py 1234567
# the numbers show up
}}}


=== Infrared ===
The infrared Port is just a '''receiver''' only, see Links #2.


== Links ==
 1. [[http://www.cnx-software.com/2016/06/08/allwinner-h3-boards-comparison-tables-with-orange-pi-banana-pi-m2-nanopi-p1-and-h3-olinuxino-nano-boards|allwinner-h3-boards-comparison-tables]]
 1. [[http://www.cnx-software.com/2016/05/09/orange-pi-lite-development-board-with-wifi-is-now-available-for-12/|range-pi-lite-development-board-with-wifi-is-now-available]]
 1. [[https://github.com/igorpecovnik/lib/blob/master/documentation/H3_mini_faq.md|CPU H3 mini FAQ]]
 1. [[http://linux-sunxi.org/BROM|Allwinner SoC Boot ROM BROM description]]
Line 267: Line 1104:
 1. [[http://elinux.org/RPi_Low-level_peripherals|Raspberry Pi, low level peripherals]]
Line 269: Line 1105:
 1. [[http://www.ti.com/product/tl431|Texas Instruments TL431 description and data sheet]]
 1. [[http://www.pocketmagic.net/2012/05/simple-switched-power-supplies/#.U1Ftm8dmGmM|switching power supply examples, schematics]]
 1. [[http://www.mikrocontroller.net/articles/Controller_an_230V|Netzteil Beispiele, Schaltnetzteil]]
 1. [[http://www.mikrocontroller.net/articles/Raspberry_Pi|Mikrocontroller.net, Deutsch]] Raspberry Pi Erklärungen
 1. [[http://www.raspberrypi-spy.co.uk/2014/07/raspberry-pi-model-b-3-5mm-audiovideo-jack/|Raspberry Pi Model B+ 3.5mm Audio/Video Jack]]
 1. [[http://blog.pi3g.com/2014/07/modell-b-getestet-und-im-detail-erklrt-was-ist-neu-was-ist-besser/|Modell B+ getestet und im Detail erklärt – was ist neu, was ist besser?]]
 1. [[http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=148&extra=&page=13|Forum about Orange Pi wiring library]]
 1. [[https://github.com/duxingkei33/orangepi_PC_gpio_pyH3/blob/master/examples/blink_POWER_STATUS_PL10.py|blink_POWER_STATUS_PL10.py]]
Line 277: Line 1109:
 1. [[https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=138631&start=100|[RPi3] SSH not working via wifi]]  1. [[https://oshlab.com/enable-g_serial-usb-otg-console-orange-pi-armbian/|
Enable g_serial USB OTG console Orange Pi on Armbian]]
 1. [[http://linux-sunxi.org/Fex_Guide|FEX guide, this file defines various aspects of how the SoC works]]
 1. [[https://pypi.python.org/pypi/pyA20|pyA20 documented]]
 1. [[https://github.com/duxingkei33/orangepi_PC_gpio_pyH3|pyH3 from olimex]]
 1. [[https://forum.armbian.com/index.php?/topic/3084-orange-pi-zero-python-gpio-library/&|orange pi gpio library talks]]
 1. [[http://www.cnx-software.com/tag/orange-pi/|orange-pi informations from cnx]]

Know How for the Orange Pi

/!\ There are several versions of Orange Pi computers. I will describe here Orange Pi Lite and Orange Pi One (which seems to be no longer manufactured, since 2017-01).

The http://orangepi.com/orange-pi-lite is a palm sized (69 x 48 mm) computer that plugs into your TV and can use an USB keyboard and an USB mouse. It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. The community page has some more details.

The basics are: (for the I/O please see at http://orangepi.com/orange-pi-lite)

  • CPU: Allwinner H3 (ARM A7-quad core)

  • RAM: 512 MB

  • Flash: micro SD-card

  • Linux software: Armbian is described well.

  • Power consumption: 5 V, Basic 0.3 - 0.5 A + external devices

I will explain here some specific Know How concerning practical use. Please see the picture below for details (click on picture to expand).

The picture below shows the Orange Pi Lite (WiFi and Bluetooth version) with the serial port connected to a USB to serial converter, in order to setup the WiFi interface.

/!\ The serial data wires RX, TX and GND (or RD and TD) are connected 1:1, 115200 Baud 8N1 no handshake.

/!\ Please take care to use the 3.3 V version of the serial converter. A 5 V version can damage your Orange Pi.

/!\ If you are using a DVI adapter on your monitor, you will probably see no picture. The fix is explained later.

attachment:OrangePi_Lite_DSC06813.jpg

Orange Pi Lite

Orange Pi Lite is the Orange Pi version with WiFi and Bluetooth, without Ethernet port. A schematic is available.

A sample installation of Armbian on a micro SD-card (>= 8 GB, class 10) under Mac OS:

# cd to download folder of "Armbian"
$ cd  /Volumes/DAT/HDA8/INSTALL/NAS/OrangePi_Lite/Armbian_5.20_Orangepilite_Debian_jessie_3.4.112_desktop

# find disk number of the SD-card
$ diskutil list  # SD-card is disk4

# unmount SD-card
$ diskutil unmountDisk /dev/disk4s1

# copy Armbian image to SD-card
$ sudo dd bs=1m if=Armbian_5.20_Orangepilite_Debian_jessie_3.4.112_desktop.img of=/dev/rdisk4

# eject SD-card

Because it is so cheap (about 27 EUR ), it is very attractive to use it in all kinds of embedded computer projects. The offer is from https://www.aliexpress.com, search for Orange Pi Lite SET12, it contains an Orange Pi Lite + Transparent ABS case + power cable + 16 GB class 10 micro SD card.

Armbian software

The Armbian (Debian) software can be downloaded in a XFCE4 Desktop or Server version. Please read the Quick Start page for informations. I am using the Desktop version.

/!\ When the software on the micro SD-card is OK, the green LED blinks, or lits steady.

WiFi connect

Because the Orange Pi Lite does not have an Ethernet port, the WiFi connection must be configured via the serial port (115200 Baud 8N1). To make the connection to a computer with a terminal (PUTTY or CoolTerm), you need an USB to serial converter (3.3 V version only), as shown in the picture above. In my case I did not need to cross RxD and TxD wires.

/!\ You can use in PuTTY the mouse scroll wheel switch to insert text from the clipboard.

Next insert the programmed micro SD-card into the socket of the board and switch on power. In the terminal you will see:

U-Boot SPL 2016.09-armbian (Sep 15 2016 - 07:09:20)
DRAM: 512 MiB
Trying to boot from MMC1


U-Boot 2016.09-armbian (Sep 15 2016 - 07:09:20 +0200) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Xunlong Orange Pi Lite
DRAM:  512 MiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot/boot.scr
2789 bytes read in 144 ms (18.6 KiB/s)
## Executing script at 43100000
gpio: pin PL10 (gpio 298) value is 1
   Warning: value of pin is still 0
gpio: pin PG11 (gpio 203) value is 1
** File not found /boot/.verbose **
** File not found /boot/.next **
** Unrecognized filesystem type **
** File not found .next **
35912 bytes read in 400 ms (86.9 KiB/s)
3114597 bytes read in 307 ms (9.7 MiB/s)
5025168 bytes read in 455 ms (10.5 MiB/s)
## Loading init Ramdisk from Legacy Image at 43300000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    3114533 Bytes = 3 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
Using machid 0x1029 from environment

Starting kernel ...

[sun8i_fixup]: From boot, get meminfo:
        Start:  0x40000000
        Size:   512MB
ion_carveout reserve: 160m@0 256m@0 130m@1 200m@1
ion_reserve_select: ion chipid  [0x2004620!
ion_reserve_common: ion reserve: [0x56000000, 0x60000000]!

Debian GNU/Linux 8 orangepilite ttyS0

Next you will be asked for the root password ("1234"), and need to change it to a new one. Then you will be asked for a user name with some not so important details, and a user password. Preferably the user name is pi. Then it is much easier to copy and paste the terminal commands from my web page.

Then it is time to reboot, in order to login as a user:

orangepilite login: pi
Password: xxxxx

Linux orangepilite 3.4.112-sun8i #14 SMP PREEMPT Wed Sep 14 20:29:31 CEST 2016 armv7l
  ___                               ____  _   _     _ _
 / _ \ _ __ __ _ _ __   __ _  ___  |  _ \(_) | |   (_) |_ ___
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | | |   | | __/ _ \
| |_| | | | (_| | | | | (_| |  __/ |  __/| | | |___| | ||  __/
 \___/|_|  \__,_|_| |_|\__, |\___| |_|   |_| |_____|_|\__\___|
                       |___/

Welcome to ARMBIAN Debian GNU/Linux 8 (jessie) 3.4.112-sun8i
System load:   1.46             Up time:       32 sec
Memory usage:  24 % of 494Mb    IP:
CPU temp:      20°C
Usage of /:    33% of 7.2G

# you see, there is not yet an IP number available!

Now it is time to connect to the WiFi router, with the setup. The network manager scans already for available hotspots (router):

$ sudo nmtui  # network manager text user interface
    Set system hostname - orangepilite  # for example
    Activate a connection
        Wi-Fi         # scan for available hotspots (router)
            FRITZ-7360 - <Activate>  # SSID for example
            .....
    Password: xxxx <OK>
    connecting...
    <QUIT>

# check in the router for the IP address
# for example a Fritz!box
orangepilite    192.168.17.171  00:e0:4c:18:0f:ee WLAN 42 Mbit/s 
or
$ sudo ifconfig
...
wlan0     Link encap:Ethernet  HWaddr 00:e0:4c:18:0f:ee
          inet addr:192.168.17.171  Bcast:192.168.17.255  Mask:255.255.255.0
...

Then try a SSH connect for remote control, with a Terminal or PUTTY:

# Try SSH connect:
$ ssh pi@192.168.17.171
  ___                               ____  _   _     _ _       
 / _ \ _ __ __ _ _ __   __ _  ___  |  _ \(_) | |   (_) |_ ___ 
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | | |   | | __/ _ \
| |_| | | | (_| | | | | (_| |  __/ |  __/| | | |___| | ||  __/
 \___/|_|  \__,_|_| |_|\__, |\___| |_|   |_| |_____|_|\__\___|
                       |___/                                  

Welcome to ARMBIAN Debian GNU/Linux 8 (jessie) 3.4.112-sun8i 
System load:   0.00             Up time:       25 min           
Memory usage:  23 % of 494Mb    IP:            192.168.17.171
CPU temp:      36°C             
Usage of /:    33% of 7.2G      

Last login: Thu Sep 15 07:30:19 2016

$ sudo date MMDDhhmmYYYY  # M=Monat, D=Tag, h=Stunde, m=Minute, Y=Jahr

Now it is time to do an software update via internet:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo shutdown -r   # reboot

# kernel 3.4.112-sun8i = linux-image-sun8i (5.25)
# kernel 3.4.113-sun8i = linux-image-sun8i (5.26)

# install the powerful file manager "midnight commander"
$ sudo apt-get install mc
# allow F10 key: Tab Edit->Preferences - remove mark from "Enable the menu accelerator key"

The following chapters concerning configuration and setup are common for the Orange Pi One/Lite.

attachment:OrangePi_housing_DSC06921.jpg

Housing

/!\ While inserting the Orange Pi board into the housing, I unfortunately broke the micro SD-card, because of the land between micro SD-card outcut and camera cable outcut.

In order to avoid that in the future, I cut out the land, as you can see in the picture on the right. The lower housing still has the lend, while it was cut out in the upper housing.

Orange Pi One

/!\ It looks like, that this board no longer manufactured, since 2017-01.

Orange Pi One is the version with Ethernet port, without WiFi and Bluetooth. A schematic is available.

Because it is so cheap (about 25 EUR ), it is very attractive to use it in all kinds of embedded computer projects. The offer is from https://www.aliexpress.com, search for Orange Pi One SET7, it contains an Orange Pi One + Transparent ABS case + power cable + 8 GB class 10 micro SD card.

Armbian software

The Armbian (Debian) software can be downloaded in a XFCE4 Desktop or Server version. Please read the Quick Start page for informations. I am using the Desktop version.

/!\ When the software on the micro SD-card is OK, the green LED blinks, or lits steady.

Shared software additions

The following software additions will make it more comfortable to work with the Orange Pi.

Screen resolution HDMI

If you are using a HDMI to DVI adapter you will probably see no picture on your monitor. For changing the resolution on your monitor, and a fix for the DVI Adapter, a tool is provided:

Desktop size: 1024 x 768 # initial setup

$ sudo h3disp
Usage: h3disp [-h/-H] -m [video mode] [-d] [-c [0-2]]

############################################################################

 This is a tool to set the display resolution of your Orange
 Pi by patching script.bin.

 In case you use an HDMI-to-DVI converter please use the -d switch.

 The resolution can be set using the -m switch. The following resolutions
 are currently supported:

    480i        use "-m 480i" or "-m 0"
    576i        use "-m 576i" or "-m 1"
    480p        use "-m 480p" or "-m 2"
    576p        use "-m 576p" or "-m 3"
    720p50      use "-m 720p50" or "-m 4"
    720p60      use "-m 720p60" or "-m 5"
    1080i50     use "-m 1080i50" or "-m 6"
    1080i60     use "-m 1080i60" or "-m 7"
    1080p24     use "-m 1080p24" or "-m 8"
    1080p50     use "-m 1080p50" or "-m 9"
    1080p60     use "-m 1080p60" or "-m 10"
    1080p25     use "-m 1080p25" or "-m 11"
    1080p30     use "-m 1080p30" or "-m 12"
    1080p24_3d  use "-m 1080p24_3d" or "-m 13"
    720p50_3d   use "-m 720p50_3d" or "-m 14"
    720p60_3d   use "-m 720p60_3d" or "-m 15"
    1080p24_3d  use "-m 1080p24_3d" or "-m 23"
    720p50_3d   use "-m 720p50_3d" or "-m 24"
    720p60_3d   use "-m 720p60_3d" or "-m 25"
    1080p25     use "-m 1080p25" or "-m 26"
    1080p30     use "-m 1080p30" or "-m 27"
    4kp30       use "-m 4kp30" or "-m 28"
    4kp25       use "-m 4kp25" or "-m 29"
    800x480     use "-m 800x480" or "-m 31"
    1024x768    use "-m 1024x768" or "-m 32"
    1280x1024   use "-m 1280x1024" or "-m 33"
    1360x768    use "-m 1360x768" or "-m 34"
    1440x900    use "-m 1440x900" or "-m 35"
    1680x1050   use "-m 1680x1050" or "-m 36"

 Two examples:

    'h3disp -m 1080p60 -d' (1920x1080@60Hz DVI)
    'h3disp -m 720i' (1280x720@30Hz HDMI)

 You can also specify the colour-range for your HDMI-display with the -c switch.

 The following values for -c are currently supported:

    0 -- RGB range 16-255 (Default, use "-c 0")
    1 -- RGB range 0-255 (Full range, use "-c 1")
    2 -- RGB range 16-235 (Limited video, "-c 2")

Now trying to patch script.bin with your settings. Successfully finished. Please reboot for changes to take effect

# setup for DVI converter (proposal with DVI converter use: 1024x768)
$ sudo h3disp -m 32 -d

VNC server

Virtual Network Computing (VNC) allows you, to show the monitor screen of a remote computer (VNC Server) on a local computer (VNC Client), also to use your local keyboard and mouse for control of the remote computer. That allows to control a remote computer which does not have its own screen, keyboard and mouse.

First you have to install on the Orange Pi a VNC Server, preferably the tightvncserver:

/!\ The password length must be between 5-8 characters. If it is longer, it will be truncated to 8.

# if there was time to the last update, do it now.
# update first the software Repository
$ sudo apt-get update

# upgrade packages
$ sudo apt-get upgrade
$ sudo shutdown -r

# prepare an install folder
$ mkdir Install
$ cd Install

$ sudo apt-get install tightvncserver

# start server
$ vncserver :1
You will require a password to access your desktops.

Password: raspberr     # max 8 characters, e.g. raspberr
Verify:
Would you like to enter a view-only password (y/n)? n

New 'X' desktop is raspberrypi:1

Creating default startup script /home/pi/.vnc/xstartup
Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log

# finish VNC server daemon
$ vncserver -kill :1

In order to change the password, use the command:

# Path: $HOME/.vnc/passwd

$ vncpasswd
enter password ENTER
enter password to verify ENTER

For an automatic start of the VNC server, you need a script, see at the links.

# Get the script
$ wget http://www.penguintutor.com/otherfiles/tightvncserver-init.txt

# Check the user name in line 16 and adopt if necessary. At the moment it is set to "pi".
# For safety reasons the user should NOT be named "root".
$ cat tightvncserver-init.txt   # just show file
or
$ nano tightvncserver-init.txt  # edit file

# copy to the init.d folder
$ sudo cp tightvncserver-init.txt /etc/init.d/tightvncserver

# Change user and group
$ sudo chown root:root /etc/init.d/tightvncserver

# Adjust the rights (execute)
$ sudo chmod 755 /etc/init.d/tightvncserver 

# Put the script in the "run levels" 
$ sudo update-rc.d tightvncserver defaults

# Manual stop
$ sudo /etc/init.d/tightvncserver stop

# Manual start
$ sudo /etc/init.d/tightvncserver start

# Check, if the process is active
$ ps -Af | grep vnc
pi        5135     1  0 06:42 ?        00:00:05 Xtightvnc :1 -desktop X -auth /home/pi/.Xauthority -geometry 1024x768 -depth 24 -rfbwait 120000 -rfbauth /home/pi/.vnc/passwd -rfbport 5901 -fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/ -co /etc/X11/rgb

Unfortunately the clipboard just works in one direction only. The other direction can be enabled with the programm autocutsel on the Orange Pi:

# Install program to synchronise the clipboard for VNC use.
$ sudo apt-get install autocutsel

# enable auto start
$ nano ~/.vnc/xstartup  # edit file
# insert at the third line the following line:
autocutsel -fork
xrdb $HOME/.Xresources
...

# stop the VNC Server
$ sudo /etc/init.d/tightvncserver stop

# start with "autocutsel"
$ sudo /etc/init.d/tightvncserver start

Now you can establish a connection with a VNC client viewer.

/!\ It may be needed, to append the port numer 5901 to the IP address (Real VNC: Connection refused (61))

  • Password (was entered at setup, max. 8 characters): raspberr

  • Mac OS X Sierra 10.12.2:

    • In Finder you select: Goto/connect to server, Server address (e.g.): vnc://192.168.17.171:5901 . Unfortunately the build in VNC client does not support alt gr characters.

    • RealVNC: VNC-Viewer-5.1.1: supports the alt gr characters. Address (e.g.): 192.168.17.171:5901

    • The window size default is 1024 x 768 Pixel.
  • Windows

    • RealVNC: VNC-Viewer-5.1.1

VNC and sudo

In the VNC viewer, if you start a program with sudo, you can get an error _tkinter.TclError: couldn't connect to display ":1.0".

The solution is to setup XAUTHORITY, see more about at the links:

# example of /etc/sudoers
Defaults    env_reset
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

$ sudo cat /etc/sudoers   # show file

$ sudo nano /etc/sudoers  # edit file

# append the 2 following lines to the end of the file:
Defaults    env_keep += "DISPLAY"
Defaults    env_keep += "XAUTHORITY"

$ sudo nano ~/.bashrc  # edit file
# Append the following line to ~/.bashrc: (for VNC + tkinter)
if [ -z "$XAUTHORITY" ] ; then if [ -e $HOME/.Xauthority ] ; then export XAUTHORITY=$HOME/.Xauthority; fi; fi
# check edit
$ cat ~/.bashrc

# restart, to make it work
$ sudo shutdown -r

# Please be care that for entering the password an ENGLISH keyboard is used!
# for password "raspberry" you must type "raspberrz"!

Now it should be possible to start a X-Windows program with sudo.

VNC and Screen Shot

If you like to do a screen shot from your graphic window, type on the command line:

# for screen shot install:
$ sudo apt-get install scrot eog  # eog = Eye Of Gnome = picture viewer

$ scrot -s -d 4

# option "-s" select a window, or a rectangle, with the mouse
# option "-d 4" have a 4 s delay before the screen shot, in order to restore the window
# and read "man scrot"

# result:
$ ls -ls | grep 2014-05-05
   36 -rw-r--r-- 1 pi   pi      33458 Mai  5 14:00 2014-05-05-140020_655x643_scrot.png

Terminal TAB command complete

Unfortunately the function command complete in the terminal with the TAB key does not work in XFCE, see here.

The quick solution is to use CTRL/STRG TAB instead TAB. The better solution is to work at the reason. XFCE has captured the TAB key for the funtion switch_window_key, but I think, the function command complete is more important. So what to do:

Applications Menu->Settings->Settings Manager->Settings Editor xfce4-keyboard-shortcuts
    <Super>Tab -> edit value: delete text "switch_window_key"

# to make it work:
$ sudo shutdown -r   # reboot

Often use programs

In XFCE often used programs, like Terminal, File Manager, Texteditor and File Finder are on a low convenience level, to save resources. Because I often work with Ubuntu, I want to have the same often used programs. The installation is easy:

$ sudo apt-get install nautilus gnome-terminal gedit locate
# Menu Settings->Preferred Applications->Tab Utilities
#  Nautilus for file manager
#  Gnome-Terminal for terminal
#  click on button 'Close'

$ sudo updatedb  # for locate, to immediately index file names

# "List View" + "tree view" in file manager Nautilus, version 3.14.1
#   Click on folder icon in upper left edge of the window.
#       Select: Preferences->
#           Tab Views: Default view->View new folders using: List View
#           Tab Display->List View-> check mark "Navigate folders in a tree"

Samba share

For easier file sharing in the in-house network, I like to have a Samba share installed:

$ sudo apt-get install nautilus-share
$ sudo apt-get install samba

$ sudo adduser $USER sambashare

# edit /etc/samba/smb.conf, add line in global section
    usershare owner only = false

# test if smb.conf is ok:
$ sudo service smbd restart

# for adduser to work, reboot:
$ sudo shutdown -r
# test if user was added to group "sambashare"
$ groups
pi dialout sudo audio video plugdev netdev bluetooth sambashare

# set password for samba, same as user password
$ sudo smbpasswd -a pi

# create samba share with Nautilus 
   select in Nautilus the folder /home/pi  # user
   click with right mouse button on the icon
   click on "sharing options"
   in window " Folder sharing" mark "share this folder"
       share name: pi-orange
       comment: orange lite
       option: mark "Allow others to create and delete files in this folder"
   click on "Create Share"
   click on: add the permissions automatically

# change owner for easier access:
$ sudo chown pi:pi /var/lib/samba/usershares/pi-orange

# test if you can connect the share

attachment:Orange-pi-lite_panel-additions_364.png

XFCE4 panel additions

I want to see in the panel some information from this computer:

  1. actual CPU speed

  2. CPU load, memory use, swap use

  3. CPU temperature

  4. Date

In order to get the date below the time you can change in the clock properties, see the syntax:

# Clock Options->Format:Custom format: %H:%M%n%F
# %n = new line
# %F = Full date; same as %Y-%m-%d, e.g. 2017-04-17

For all those informations you can get plugins for the xfce4 panel. First you have to install them:

# CPU Information - CPU Frequency Monitor (About)
$ sudo apt-get install xfce4-cpufreq-plugin

# System Load Monitor version 1.1.1 - (About)
# http://goodies.xfce.org/projects/panel-plugins/xfce4-systemload-plugin
$ sudo apt-get install xfce4-systemload-plugin

# xfce4-genmon-plugin 3.5 - Generic Monitor (About)
$ sudo apt-get install xfce4-genmon-plugin

All plugins are installed in the panel in the same way:

Right click on Panel
    Panel
        Add new item
            Left click on <plugin name> to mark
            Button Add
            Button Close
  CPU Frequency Monitor - click on Add
  System Load Monitor - click on Add
  Generic Monitor - click on Add + Close

# Right click on Panel mem->properties: remove mark from "Uptime monitor" (usually not needed)
# Click on Close

While the first 2 plugins work immediately, the CPU temperature needs more effort. You need to prepare your own data collection file:

# create folder in /home/pi
$ mkdir Install

# create control file
$ touch Install/cpu-temp_panel.sh

# edit control file
$ nano Install/cpu-temp_panel.sh
# insert the following text:
#!/bin/bash
# http://goodies.xfce.org/projects/panel-plugins/xfce4-genmon-plugin
echo "<txt>"$(cat /etc/armbianmonitor/datasources/soctemp | sed 's/\ \ */ /g' | cut -f2 -d" ")"°C</txt>"
# finish with: CTRL/STRG o ENTER 
               CTRL/STRG x

# give file "execute" permission
$ chmod ug+x cpu-temp_panel.sh

# right click on the just installed panel plugin and select properties:
  Command: /home/pi/Install/cpu-temp_panel.sh   # adopt the user name, if not "pi" 
  Label: CPU_  (1 space)
  Period: 5 s

Now you should see the previous mentioned computer informations, like to see on the screen shot above.

Python, TKinter

Python2 is already installed, but some support is missing.

# Install Python TKinter package
$ sudo apt-get install python-tk

# Install Python integrated development environment
$ sudo apt-get install idle

Python3 is already installed, but some support is missing.

# Install Python3 package installer
$ sudo apt-get install python3-pip

# Install Python3 TKinter package
$ sudo apt-get install python3-tk

# Install Python3 integrated development environment
$ sudo apt-get install idle3

Test the Tkinter installation with a little program:

# create file
$ touch Install/tkinter-test.py

# edit file witth the following lines
$ nano Install/tkinter-test.py
# Python 2/3 Tkinter test program: tkinter_test.py
# 2016-12-28 RudolfReuter
try:
    from Tkinter import *
except ImportError:
    from tkinter import *

class Application(Frame):
    def say_hi(self):
        print("hi there, everyone!")

    def createWidgets(self):
        self.QUIT = Button(self)
        self.QUIT["text"] = "QUIT"
        self.QUIT["fg"] = "red"
        self.QUIT["command"] = self.quit

        self.QUIT.pack({"side": "left"})

        self.hi_there = Button(self)
        self.hi_there["text"] = "Hello",
        self.hi_there["command"] = self.say_hi

        self.hi_there.pack({"side": "left"})

    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()
# end of file

# must be started in the Terminal in the GUI
$ python Install/tkinter-test.py
$ python3 Install/tkinter-test.py

attachment:Orange_pi_tkinter-test.png

The screenshot on the right shows the started test program tkinter-test.py, which works as well with Python 2 as Python 3.

The used Terminal is the GNOME-Terminal.

The Graphical User Interface (GUI) desktop is xfce4.

The xfce4 desktop is shown in the RealVNC viewer on Mac OS.

Wobbulator

I have a home made Wobbulator, RF Network Analyzer working with a Raspberry Pi. I liked to know, if it also works with the Orange PI Lite, with a WiFi network connection to a laptop computer. That offers the possibility to run the application portable with a 5 V powerbank. The average power consumption in this case is about 0.4 A.

Fortunately the 26 pin flatcable connector was hardware compatible, just the software needed some modification. A patch file can be downloaded, to show the difference in hardware access from Raspberry Pi to the Orange Pi.

/!\ Install first OrangePiKnowHow#GPIO_Python.

The program wobbulator2.6.3o.py is already adopted to the Orange Pi. Because it is a Python3 graphical (TKinter) program, it must be started from the XFCE4 GUI, in a terminal, see a sample run:

$ sudo python3 ./wobbulator2.6.3o.py 
[sudo] password for pi: 
start pgm
tk init
start mainloop
sweep
bias [V]  0.8035714285714286
Dauer (s)  1.0870912075042725

attachment:Wobbulator_OrangePiLiteXFCE.jpg

The screenshot above shows the Orange Pi Lite desktop with the program wobbulator2.6.3o.py running.

The test object was a 10.7 MHz filter, scanned from 1 MHz to 31 MHz with an increment of 100 KHz (300 steps). The input RF-level to the filter was about 0 dBm. The sweep time was 1.1 seconds. You can see, that the filter has a side peak at about half the major frequency (5.35 MHz), which is about 23 dB below the filter working frequency amplitude (-9 dBm).

Clone SD-card

/!\ Because of different net storage capacity values, it is advisable to use 95% only of a SD-card. That avoids problems when cloning an image to a slightly smaller SD-card.

If a SD-card fails, it is the quickst way to restore it from a back up file. In order to make it easier, some example commands are shown:

# show the mounted mass storage
$ df -h

# save a SD-card image (16 GB)

# change disk to a >16 GB free folder
$ cd /media/<user>/<disk-folder>
# unmount SD-card
$ umount ../<SD-card-folder>
# save image (class 10, duration about 20 min.)
$ sudo dd bs=4M if=/dev/sdb of=orangepilight.img
# remove SD-card
-----------------------
# restore SD-card image

# change disk to the SD-card image folder
$ cd /media/<user>/folder
# insert new SD-card
# unmount SD-card
$ umount /media/<user>/xxx
# restore image (class 10, duration about 25 min.)
$ sudo dd bs=4M if=orangepilight.img of=/dev/sdb  # or other device

# change file /etc/hostname, e.g. orangepilight1
# remove SD-card

Tipps

  • shutdown Orange Pi

     $ sudo shutdown -h  # Halt after shutdown (power off)
  • Add sbin and /usr/sbin to path:

     # edit /home/pi/.bashrc, add the following line after the "esac" line
     export PATH="$PATH:/sbin:/usr/sbin"
    
     # activate
     $ source .bashrc
    
     $ echo $PATH
     PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin
  • Build date of the software:

     $ uname -a
      Linux orangepilite 3.4.112-sun8i #10 SMP PREEMPT Sun Oct 23 16:06:55 CEST 2016 armv7l GNU/Linux
  • find newer files, explanation:

     # Syntax
      find /directory -newermt $(date +%Y-%m-%d -d '1 day ago') -type f -print
     # example
     $ find moin-1.9.9/wiki/data/pages -newermt $(date +%Y-%m-%d -d '1 month ago') -type f -print
    
     # Delete all Mac OS control files:
     $ sudo find . -name "._.DS_Store" -type f -delete
  • Test file system at boot time

     $ sudo touch /forcefsck
    
     # Restart OrangePi
     $ sudo shutdown -r
  • Get root shell

     $ sudo su
     # Exit root shell
     $ exit  # or CTRL/STRG D
  • update/upgrade: If you login via serial port or SSH and get an upgrade message the action is:

     # number of updated packages in total
     [ 16 updates to install: apt-get upgrade ]
    
     # update the package lists
     $ sudo apt-get update
    
     # install the upgrade packages (of the installed packages only)
     $ sudo apt-get upgrade
  • Power button: info 1, info 2

  • Wireless optical mouse and keyboard X1800 from RAPOO

    • I tested with good success the above mentioned wireless mouse and keyboard, see on the first picture on this page the wireless dongle. The benefit is, that you have now 1 free USB port.

  • Check for Debian version:

     $ cat /etc/issue
     Debian GNU/Linux 8 \n \l

Hardware IO

Here are documented hardware I/O related informations.

Analog

There is no Analog to Digital converter, but you have a Pulse Wide Modulation (PWM) output.

Audio

There is a microphone for Audio input. Audio output can be achieved via HDMI device (TV, Monitor).

GPIO

Wiring Orange Pi is a GPIO library, explained here, and can be clone with git, or downloaded and unzipped in user folder.

$ cd ~/Install
$ git clone https://github.com/zhaolei/WiringOP.git
$ cd WiringOP

or with download
$ cd WiringOP-h3

# make executable
$ chmod +x ./build

# build and install
$ sudo ./build

# kernel modules:
[Compile] wiringPi.c
[Compile] wiringSerial.c
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
[Compile] wiringPiI2C.c
[Compile] softPwm.c
[Compile] softTone.c
[Compile] softServo.c
[Compile] mcp23008.c
[Compile] mcp23016.c
[Compile] mcp23017.c
[Compile] mcp23s08.c
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
[Compile] mcp3002.c
[Compile] mcp3004.c
[Compile] mcp4802.c
[Compile] mcp3422.c
[Compile] max31855.c
[Compile] max5322.c
[Compile] sn3218.c
[Compile] drcSerial.c

# Device libraries
[Compile] ds1302.c
[Compile] maxdetect.c
[Compile] piNes.c
[Compile] gertboard.c
[Compile] piFace.c
[Compile] lcd128x64.c
[Compile] lcd.c
[Compile] piGlow.c

NOTE: To compile programs with wiringBP v2, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).

The pin assignement for WiringOP is (see also BCM2835 GPIOs):

$ gpio 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 | ALT4 | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  65 |  13 |     MISO | ALT4 | 0 | 21 || 22 | 0 | ALT3 | RTS2     | 6   | 2   |
 |  66 |  14 |     SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | 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 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | TxD1     | 28  | 198 |
 |     |     |       0v |      |   | 39 || 40 | 0 | ALT3 | RxD1     | 29  | 199 |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+
BCM = Broadcom SOC channel
wPi = Wiring Orange Pi
Mode = I/O mode
Physical = Pin number of 40 pin GPIO connector

The Pin assignement for the utility gpio in armbian (2016-09)

WiringPi vs. BCM, GPIO, Port Pin numbering
     WiringPi   BCM    GPIO-r2 Port  Pin  Function
     ──────────────────────────────────────────────
         0        1      17    PA1   11     RxD2
         1      110      18    PD14  12     (PWM)
         2        0      27    PA0   13     TxD2
         3        3      22    PA3   15     CTS2
         4       68      23    PC4   16    
         5       71      24    PC7   18
         6        2      25    PA2   22     RTS2
         7        6       4    PA6    7
         8       12       2    PA12   3     I2C: SDA0
         9       11       3    PA11   5     I2C: SCL0
        10       67       8    PC3   24     SPI: CE0
        11       21       7    PA21  26     SPI: CE1
        12       64      10    PC0   19     SPI: MOSI
        13       65       9    PC1   21     SPI: MISO
        14       66      11    PC2   23     SPI: SCLK
        15       13      14    PA13   8     TxD3
        16       14      16    PA14  10     RxD3
        21        7       5    PA7   29
        22        8       6    PA8   31
        23        9      13    PA9   33
        24       10      19    PA10  35
        25       20      26    PA20  37
        26      200      12    PG8   32     RTS1
        27      201      16    PG9   36     CTS1
        28      198      20    PG6   38     TxD1
        29      199      21    PG7   40     RxD1

# Examples:
# Switch LED on pin 11 (PA1) ON and OFF
#    gpio numbering
$ gpio -g mode 17 output
$ gpio -g write 17 1
$ gpio -g write 17 0
#    or BCM numbering
$ gpio mode 1 output
$ gpio write 1 1
$ gpio write 1 0
#    or 40 pin connector numbering
$ gpio -1 mode 11 output
$ gpio -1 write 11 1
$ gpio -1 write 11 0

A good information is here. An example:

$ sudo modprobe gpio-sunxi
$ sudo ls /sys/class/gpio_sw/
PA0  PA10  PA14  PA21  PA6  PA8  PC4  PD14  PG7  PG9
PA1  PA13  PA2   PA3   PA7  PA9  PC7  PG6   PG8

$ sudo echo 1 > /sys/class/gpio_sw/PA1/data
$ sudo echo 0 > /sys/class/gpio_sw/PA1/data

More Python GPIO examples are here.

orangepi_PC_gpio_pyH3 - Python GPIO library, see also: gpio pin numbering differences

GPIO Python

# Install
$ sudo apt-get install python-dev git make gcc
$ cd /home/pi/Install
$ git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3.git
$ cd orangepi_PC_gpio_pyH3
$ sudo python setup.py install

# also for Python3
$ sudo apt-get install python3-dev
$ sudo python3 setup.py install

# Install kernel module
$ sudo modprobe gpio-sunxi

# see, if loaded
$ lsmod | grep gpio
gpio_sunxi              8269  0

$ cd ..
# create testfile led_pa1.py
$ touch led_pa1.py

# copy and paste (mouse) the following program in file led_pa1.py
$ nano led_pa1.py
# -*- coding: utf-8 -*-
# 2016-12-25 program: led_pa1.py

from pyA20.gpio import gpio
from pyA20.gpio import port
from pyA20.gpio import connector
import time

COUNT = 3
#LED = port.PA1
LED = connector.gpio1p11    # gpio1p11 = PA1
# PWR_LED = port.POWER_LED  # does NOT work
STAT_LED = port.STATUS_LED
gpio.init()
gpio.setcfg(LED, gpio.OUTPUT)
# STATUS_LED is already set to output

for _ in xrange(COUNT):
    gpio.output(LED,True)
    gpio.output(STAT_LED,True)
    time.sleep(1.0)
    gpio.output(LED,False)
    gpio.output(STAT_LED,False)
    time.sleep(1.0)
# end of file
                                                           +------+  LED
# connect LED to pin 11 (PA1) of 40 pin connector: pin 11 -| 220R |--|>|- pin 9 0V (GND)
                                                           +------+
# start test program:
$ sudo python ./led_pa1.py
# Status LED and LED on pin 11 should blink 3 times.

I2C bus

Also called TWI (Two Wire Interface, maybe clock stretching is not supported). I2C-bus was designed by Philips in the early ’80s to allow easy communication between components which reside on the same circuit board. Philips Semiconductors migrated to NXP in 2006.

Lets see, what is already on board:

~$ ls -ls /dev/i2*
0 crw------- 1 root root 89, 0 Dec 26 23:08 /dev/i2c-0
0 crw------- 1 root root 89, 1 Dec 26 23:08 /dev/i2c-1

Make armbian more user friendly:

# Install i2c-tools smbus
$ sudo apt-get install i2c-tools python-smbus

# change i2c device group from root to i2c
$ sudo chown root:i2c /dev/i2c*
$ sudo adduser $USER i2c
# logout / login
or
$ sudo shutdown -r
# test groups
$ groups
pi dialout sudo audio video plugdev netdev bluetooth sambashare i2c
# Now i2c access needs no longer "root" rights, just group "i2c" rights.

# If "i2cdetect" is not found, add "sbin" to the environment "path".

# connect an Adapter PCF8574 (I2C address 0x27) to pin 3 = SDA and pin 5 = SCK
$ /usr/sbin/i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
...

There is a nice test program for I2C LCD (16 x 2 characters, Adapter PCF8574). It needs a little modification, then it works.

# LCD wire connection to 40 pin connector: GND to pin 6, +5 V to pin 4, SDA to pin 3, SCK to pin 5

$ cd Install
# download example
$ git clone https://github.com/sweetpi/python-i2c-lcd.git
$ cd python-i2c-lcd

# edit file lcddriver.py
# change BUS = 1 to BUS = 0

# write the numbers 1234567 to the LCD
$ python display.py 1234567
# the numbers show up

Infrared

The infrared Port is just a receiver only, see Links #2.

  1. allwinner-h3-boards-comparison-tables

  2. range-pi-lite-development-board-with-wifi-is-now-available

  3. CPU H3 mini FAQ

  4. Allwinner SoC Boot ROM BROM description

  5. Setup of tightvncserver

  6. VNC with sudo

  7. raspberry-pi-rev2-gpio-pinout, JPG

  8. Forum about Orange Pi wiring library

  9. blink_POWER_STATUS_PL10.py

  10. USB cable size matters

  11. Micro USB test jig

  12. [[https://oshlab.com/enable-g_serial-usb-otg-console-orange-pi-armbian/|

Enable g_serial USB OTG console Orange Pi on Armbian]]

  1. FEX guide, this file defines various aspects of how the SoC works

  2. pyA20 documented

  3. pyH3 from olimex

  4. orange pi gpio library talks

  5. orange-pi informations from cnx

List of pages in this category:

-- RudolfReuter 2016-12-23 13:25:42


Go back to CategoryRaspberryPi or FrontPage

OrangePiKnowHow (last edited 2020-08-02 11:00:41 by RudolfReuter)