Know How for the Raspberry Pi

The Raspberry Pi is a credit-card sized computer that plugs into your TV and 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.

Because it is so cheap (about 40 EUR), it is very attractive to use it in all kinds of embedded computer projects.

The main page for Raspberry Pi information is here.


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 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 here

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 Raspberry Pi a VNC Server, preferably the tightvncserver:

# update first the software Repository
$ sudo apt-get update

# upgrade packages
$ sudo apt-get upgrade

$ 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
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

# VNC server beenden
$ vncserver -kill :1

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

# Get the script
$ wget

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

# 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".

# 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 start
$ sudo /etc/init.d/tightvncserver start

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

# 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 Raspberry Pi:

# Install program to synchronise the clipboard
$ sudo apt-get install autocutsel

# enable auto start
# edit /home/pi/.vnc/xstartup
# append at the third 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))

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:

$ 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
Defaults    env_reset
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults    env_keep += "DISPLAY"
Defaults    env_keep += "XAUTHORITY"

# Add these few lines to ~/.bashrc:

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

# logout and login again
# 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:

$ 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


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).


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.


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.


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 (, 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.


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%.


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 Links #11 and #12


  1. Setup of tightvncserver

  2. VNC with sudo

  3. Raspberry Pi, low level peripherals

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

  5. Texas Instruments TL431 description and data sheet

  6. switching power supply examples, schematics

  7. Netzteil Beispiele, Schaltnetzteil

  8., Deutsch Raspberry Pi Erklärungen

  9. Raspberry Pi Model B+ 3.5mm Audio/Video Jack

  10. Modell B+ getestet und im Detail erklärt – was ist neu, was ist besser?

  11. USB cable size matters

  12. Micro USB test jig

  13. [RPi3] SSH not working via wifi

List of pages in this category:

-- RudolfReuter 2014-04-18 17:05:37

Go back to CategoryRaspberryPi or FrontPage

RaspberryPiKnowHow (last edited 2016-11-02 21:35:48 by RudolfReuter)