Raspberry Pi – VNC Mirror (Repeater) – Make any computer public anywhere

***Please visit the new simplified installation of the Raspberry Pi VNC Mirror***

Here is an extenstion for this blog-entry you also might to read!

Raspberry Pi LogoRaspberry Pi Logo

The idea is to show any machine (virtual or real) to public. So you can setup a computer with VNC anywhere and can put a big TV screen at another place.

We need a Raspberry Pi Model B, a network connection and a micro USB power plug (either over USB <-> micro USB plugged into your RPi or TV or seperate power device)

I have downloaded the 2012-09-18 Image of the Raspbian Image wheezy.

Follow the basic instructions of the RPi config.

Important: if you don’t have 1920×1080 resolution (Full HD) it might not work for you. I have experienced that if your remote computer has a resolution of 1280×768 the ssvncviewer exits immediately. But if you changed it to a common resoltion of 1280×720 it will work with one little dissadvantage: The screen stays black with a circle shaped cursor. You have to login from another computer on the remote machine first, so it will work. These 1280xYYY resolutions make somehow troubles.

paste these lines in your commandline (or over putty)

Ommit the lines with proxy if you have none.

Programms and settings

# start a root session
sudo bash
echo "exec openbox-session">/home/pi/.config/openbox/autostart.sh
# proxies
export http_proxy=http://proxy1.sysstem.at:8080
export https_proxy=https://proxy1.sysstem.at:8080
echo "Acquire::http::Proxy "http://proxy1.sysstem.at:8080";">>/etc/apt/apt.conf
# updates
apt-get update
apt-get upgrade -y
# install programs
apt-get install x11vnc vim ssvnc unp htop -y
# autostart x11vnc
mkdir .config/autostart/
echo [Desktop Entry]>/home/pi/.config/autostart/x11vnc.desktop
echo Encoding=UTF-8>>/home/pi/.config/autostart/x11vnc.desktop
echo Type=Application>>/home/pi/.config/autostart/x11vnc.desktop
echo Name=X11VNC>>/home/pi/.config/autostart/x11vnc.desktop
echo Comment=>>/home/pi/.config/autostart/x11vnc.desktop
echo Exec=x11vnc -forever -shared -usepw -ultrafilexfer -display :0>>/home/pi/.config/autostart/x11vnc.desktop
echo StartupNotify=false>>/home/pi/.config/autostart/x11vnc.desktop
echo Terminal=false>>/home/pi/.config/autostart/x11vnc.desktop
echo Hidden=false>>/home/pi/.config/autostart/x11vnc.desktop
# remove desktop links
rm /home/pi/Desktop/*.desktop

Info

If the X11VNC does not start correctly after boot try to change parameters in the x11vnc.desktop file

sudo vim /home/pi/.config/autostart/x11vnc.desktop

Time settings

# set timezone and select your city
sudo dpkg-reconfigure tzdata

#reconfigure ntp
sudo dpkg-reconfigure ntp

# set timeserver
sudo vim /etc/ntp.conf
server ntp.sysstem.at iburst

#stop ntp daemon
sudo /etc/init.d/ntp stop

#set time
sudo ntpdate ntp.sysstem.at

#start ntp
sudo /etc/init.d/ntp start

Monitor preferences

sudo vim /boot/config.txt

search and edit the following

# remove black borders on screen. set to 0 if problem occour
disable_overscan=1

# pretend hdmi is plugged in and hdmi resolution will work
hdmi_force_hotplug=1

#Force console size

framebuffer_width=1920
framebuffer_height=1080

# set resolution to 1920x1080@60Hz
# hdmi_mode=4 for 1280x720@60Hz
#check website for more modes
#http://elinux.org/RPi_config.txt
hdmi_group=1
hdmi_mode=16

# remove 1 of 2 desktops (we only need 1)

vim /home/pi/.config/openbox/lxde-rc.xml
# at desktops:
<number>1</number>

X11VNC settings

# define a password for your x11vnc
x11vnc -storepasswd /home/pi/.vnc/passwd

Upload a new desktop wallpaper, most likely the logo of your company

Change background by rightclicking on your desktop and choose a new picture

 VNC client – autostart script

sudo vim /home/pi/.config/autostart/vncview.sh

paste the following:

# Process check script: The script simply checks if a process is running and if it is not found to be running it will execute it.
# The script loops in preset intervals, hence it is possible to monitor a process continuously.

# Variables
Running=1
SleepInterval=60
ProcessInstances=`sudo ps aux | grep [s]svncviewer | wc -l`

#VNC Variables
vnc=ssvncviewer
host=WSTERMNL01
display=0
resolution=1920x1080
passfile=/home/pi/.vnc/passwd2
para="-display :$display -viewonly -fullscreen -shared -passwd $passfile -scale $resolution -encodings zywrle"

# Logic
while [ $Running -gt 0 ]
do

if [ `sudo ps aux | grep [s]svncviewer | wc -l` -gt 0 ]; then
echo Process already running! Nothing to do.
else
echo Process not running! Starting process
# This is the command that should start the process in question
$vnc $host $para &
fi

# How often shall we repeat the check?
echo Sleeping for $SleepInterval seconds
sleep $SleepInterval

done

exit 0

Service for VNC Client script

sudo vim /etc/init.d/vncviewd

paste the following

### BEGIN INIT INFO
# Provides: vncviewd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Viewer Daemon.
# Description: Start VNC Viewer at boot time.
### END INIT INFO

#! /bin/sh
# /etc/init.d/vncviewd

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting vncviewd"
    # run application you want to start
    su pi /home/pi/.config/autostart/vncview.sh
    exit 0
    ;;
  stop)
    echo "Stopping vncviewd"
    # kill application you want to stop
    pkill -f vncview.sh
    exit 0
    ;;
  *)
    echo "Usage: /etc/init.d/vncviewd {start|stop}"
    exit 1
    ;;
esac

exit 0

register vncviewd for autostart

sudo update-rc.d vncviewd

Monitor script

sudo vim /etc/init.d/monitor

paste the following

### BEGIN INIT INFO

# Provides: monitor
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop Monitor
# Description: Start or stop Monitor
### END INIT INFO
#! /bin/sh
# /etc/init.d/monitor
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting monitor"
# Enable HDMI with preferred mode
/opt/vc/bin/tvservice -p
# Change console to enable monitor output
# not very nice
sudo chvt 6
sudo chvt 7
;;
stop)
echo "Stopping monitor"
/opt/vc/bin/tvservice -o
;;
*)
echo "Usage: /etc/init.d/monitor {start|stop}"
exit 1
;;
esac
exit 0

register for autostart

sudo update-rc.d monitor

Disable sleep mode for monitor

sudo vim /etc/kbd/config
# DO NOT changes this line. VNC needs to blank the console for fullscreen mode
BLANK_TIME=30 (Was 30)

# Powerdown time. The console will go to DPMS Off mode POWERDOWN_TIME
# minutes _after_ blanking. (POWERDOWN_TIME + BLANK_TIME after the last input)
# change this line (original was 30)
POWERDOWN_TIME=0

restart KBD

sudo /etc/init.d/kbd restart

Set a time schedule for your monitor. This reduces energy consumption.

Monitor only runs form 6 am to 6 pm (06:00-18:00)

sudo vim /etc/crontab

paste the following

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
0  6 * * 1-5    root    /etc/init.d/monitor start
0 18 * * 1-5    root    /etc/init.d/monitor stop
#

Delete your history

history -c

Test your configuration and make a backup of your SD card. It is always good to have one 😉

The only thing left what i wanted to do was to add a custom loading screen while booting.

Maybe you can get it working by using plymouth or other programs. If so please don’t hesitate to leave me a comment.

Here is an extenstion for this blog-entry you also might to read!

*Raspberry Pi is a trademark of the Raspberry Pi Foundation

12 thoughts on “Raspberry Pi – VNC Mirror (Repeater) – Make any computer public anywhere”

  1. Hi Stefan,

    I don’t really understand what is happening here. It appears that you are running the vnc server and client on the same host. Is that correct?

    Is the idea that the person wanting to display something should connect to the vncserver and do whatever they want to present there on that host, or that they can somehow push a vncserver from another computer onto the vncserver?

    Actually what I would like to do is mirror my laptop screen on my TV and I think that is what you are doing but I can’t figure out what is supposed to run on the laptop end, from my understanding this would be a vncserver.

    Regards,

    Darren

    1. Hi Darren,

      thank you for your comment and interrest in my blog.
      The thing is that you run a VNC server for example a production machine (server) where you can see some messages. This server may be located in a serverroom.
      The Raspberry Pi and the monitor where you want to display the servers display is located in your office (for example)

      So you get the display from a let’s say far away computer on a display in your office with the help of the raspberry pi. It’s some kind of digital signage.

      If you want to mirror the laptop screen on the TV this is the a good way to do so. You have to install a VNC server on your laptop and the raspberry pi connects to it. But you have to know that the screen refresh rate is not that fast because of the delay comming from the network. Video and other stuff which refreshes the screen more than once a second is not suitable for this project. If you want to have video on tv in realtime you better buy a VGA or HDMI cable for it.

  2. Cruise was this. Jet was this. Dollar Shave Club (as
    best I will figure was .5 this and .5 the previous group).

    In the event the Cruise exchange gone downwards, everyone was inquiring me how GM created the $1b+ determine.

  3. Types of crowdfunding
    Crowdfunding portals that are built like social media sites connect you to investors and other folks
    willing to help small-business owners get products and services into the market.

  4. We established latest features considering each one attribute would make the inflection issue we were hoping
    to find. ‘Ticketing would be a online game changer,’ or ‘this
    new cell app will permit us to promote within a better rate level.

  5. Staying slender is certainly a vital piece to staying away from a start up
    tarpit. It is a thing I hoped we focused more about.

    Actually, I might in no way increase cash to launch much more improvement once again.

  6. “It determines a research value of $600, and from now on in regards down — that’s quite, incredibly interesting,” explained Dan Ariely, a Duke University personality economist
    and the publisher of “Predictably Irrational,” a guide about how
    exactly.

  7. To be able to come to be outstanding at that which you do, you
    have to learn to be disciplined. Set crystal clear goals
    and objectives and propose a plan for how you’ll begin achieving
    these goals.

Leave a Reply

Your email address will not be published. Required fields are marked *