Friday, April 3, 2015

The Internet-of-Things and MQTT

UPDATED: 2015/04/07
To include mosquitto2sms status via mqtt

The Internet Hobby Electronics world is ABLAZE with Esp8266 excitement.  These Ebay $3.00 modules are being used to create some very interesting Internet-of-Things (IoT) projects. Search Google and Youtube for Esp8266.

To make interesting projects, code can be downloaded into the processor on the Esp8266, or it can be connected to a processor like the Arduino. In either case, access to the Internet for a Hobby Project is very exciting.

One way to provide status and/or control to/from the Esp8266 is via a (little known) protocol called "MQTT", which provides simple and small processor code footprint. Actually, it is not unknown, Facebook uses it !

For Raspberry PI and Linux people, there are downloadable commands that implement MQTT, the package that contain these are "mosquitto" and "mosquitto-clients"




$ sudo apt-get install mosquitto mosquitto-clients




With "mosquitto" and the "curl" command (see previous post), I implemented a mosquitto2sms gateway, as:

mosquitto2sms


#! /bin/bash
# Author: Eldon R Brown - WA0UWH

 # Usage: mosquitto2sms [-h BrokerHostAddress] []


 # set -xv   # For Debug

 mosquitto_sub -v -t 'ToSMS/#' $* |

 sed -u -n 's/^ToSMS\/\([0-9][0-9]\+\) /\1 /p' |         # Extract just the phone Number and Message

 while read phone mesg
 do

  # echo -e "\n\n${phone} ${mesg}"  # For Debug
  curl http://textbelt.com/text -d "number=${phone}" -d "message=${mesg}" 2>&1 |
  grep -q true &&
  mosquitto_pub -t "ToSMS/${phone}/Stat" -m 1 $* ||
  mosquitto_pub -t "ToSMS/${phone}/Stat" -m 0 $*

 done

# End




On another system, or any MQTT device, a simple message can be easily sent to a Cell Phone. Example as shown is from Raspberry PI.




mosquitto_pub -q 1 -t ToSMS/2025551212 -m 'Test Message'




To watch (or monitor) all of the activity on the messaging system, execute the following (i.e., subscribe to all):




mosquitto_sub -v -t '+/#'




 I am anxiously awaiting the arrival of my ebay Esp8266's, . . . only a few more days !


-- Home Page: https://WA0UWH.blogspot.com

Wednesday, April 1, 2015

Sending SMS from the Raspberry PI

Yesterday my friend Larry - KB7KMO was in my Shop, we both have need for Status and/or Alarm Messaging from the Raspberry PI, a casual google searches did not provide much easy help. There is/was much information on how to do it with very long and complex configurations, but we wanted something simple.

After Larry left, and after several hours (actually more than a few) of research, I have found a free service that can be used to send a "SMS" messages from the Raspberry PI to a Cell Phone, using the "curl" command.

Obviously, An Internet connection is needed for the PI, and the "curl" command must be installed (if not already).



$ sudo apt-get install curl



The free SMS service is provided by "textbelt.com" (thanks, textbelt !).

There are limitations to the "textbelt.com" service; no more than 75 messages sent per day from a single IP Address, and no more than 3 messages per 3 minutes can be sent to a single Cell Phone number. For most typical use, this should not be a problem.

Note: the SMS messages received by the Cell Phone will be delivered from "txt@textbelt.com".

Usage: on the command line or shell script:



$ curl http://textbelt.com/text -d "number=AAAPPPNNNN" -d "message=This is a test message"



Where "AAAPPPNNNN" is the: Cell Phone Number, AreaCode, Prefix, and Number. Also, dashes ("-") can be used within the phone number, as: "number=202-555-1212"

Note: the words "number=" and "message=" must be used as shown.

For Canada and International use see: Web page.


- Have Fun with PI Messaging !


-- Home Page: https://WA0UWH.blogspot.com

Tuesday, March 31, 2015

Esp8266 - The Intenet-of-Things

My friend Larry - KB7KMO put me onto a new interesting and inexpensive device, - the Esp8266. The breakout board is available on ebay and others for only a few bucks ( <$5.00, the prices seem to vary all over the map).

Esp8266-ESP11
Currently there are several Rev's available (e.g., -ESP03, -ESP04, through -ESP12). I have Esp8266-ESP11 and Exp8266-ESP12 on order. I will know more about what the Rev's really mean later. Found: see Link.

Apparently the device is relatively NEW, forums are starting to fill with; information, example code, and projects.

Esp8266 is WIFI Device with a Digital Interface

The Esp8266 can be used to add WIFI to any processor with just a few lines of code. Many of the standard processors (i.e. Arduino) have support libraries already available.

Or Better YET !

The Esp8266 is a processor in it own right. There is a specially constructed GitHup repository with the new (1.6.1) Arduino IDE configuration the can be used to download and run code directly on the Esp8266 board. (see the GitHub Readme file)

The number of I/O's is a little lacking on the Esp8266, but for Networked Device for checking; a simple temperature, a water level, or alarming circuit, which reports status via Text Message, this is a great little part. As a stand-alone device, the one or two digital pins may be enough for some projects, just plan for multiple devices.

The Exp8266 can be configured as a simple Web Server, Web Client, Access Point, send Text Messages, and much-much more.

I think this is going to be a fascinating part for our Ham Radio and Hobby projects, this will make them all a part of the Internet-of-Things.

More info to follow, on how I will be using this part, I am very excited.



-- Home Page: https://WA0UWH.blogspot.com

Tuesday, March 24, 2015

More Tasks for the Raspberry

As shown in the previous post, I have been working with the Raspberry PI 2 Computer Board. Thus far I have Connect a Camera and Servos to point the camera. In time, this will become a Roving Robot (more on that in a future post).

Also, I have been waiting for the Raspberry to grow large enough to run the OpenCPN Navigation software for my Boat. Previously, it was ran on a LapTop (which is now old and klunky).

Previous hardware Raspberry PI configurations (A, B, B+) did not have enough RAM nor CPU speed to make any of that that really possible. The Raspberry PI 2, with its 2x RAM, 4x Processors (which provide about 6x Speed). is a good match for the Boat's Navigation requirement. I do not have all of the details worked out yet, but it appears do able (that will be a subject of another blog post).

To make Boat Navigation and Rover Robot possible I need a network connection between the Raspberry PI and my Tablet. The boat navigation software runs on the PI and displayed on the Tablet. The PI will be in the Roving Robot with Camera display and Controls at my Tablet.

There are several pieces of software need to make all of this possible, most are readily available.  The Center piece is the  WIFI Access Point, with it I can connect Tablet directly (ah, . .  via WIFI) to the Raspberry PI, and when the PI is connected to my home Internet (i.e., during development) I can enjoy normal Internet access. Obviously, on the Boat and while Roving as a Robot, the Internet connection may not be available.

Adafruit has a nice tutorial which is helpful when setting up the Raspberry PI as a WIFI Access Point. With only a little head scratching, I got it and the attending DHCP up and running.  My internal home private is 192.168.2.xx, the new PI private address is 192.168.4.xx.  The PI routers between the two. Once set up, it was easy to attach my Cell Phone and Tablet to the new PI WIFI network.

Access to the devices and files on the Raspberry PI private network from my home network can easily be accoumplished with the "sshuttle" command, "rp22" is the name of my Raspberry.





$ sshuttle -DNHr rp22 192.168.4.0/24




The OpenCPN Navigation Software is ran on the PI, in a virtual "vncserver" window. The window is configured to match the aspect ratio (600x900) of the Tablet.

I use "ssh" to access the PI and execute the "vncserver" command. Once set up, what ever is running, will continue to run even when a viewer is disconnected, the next connection just continue the previous session. With the "-alwaysshared" option, multiple viewers can be connected simultaneously. This will be very convenient for both the Boat and the Rover.





$ vncserver -alwaysshared -geometry 600x900 :3




I use "vncviewer" on the Tablet (and/or cell phone) to view the results.

OpenCPN running on The Raspberry PI
and Displayed on the Tablet

As can be seen below with "xosview", the Raspberry PI 2 is just idling along.

Xosview
System Resource Report
For the Roving Robot I will use the PI to operate the Camera pointing Servos and eventually control wheels. Currently I am streaming the camera's video to my Tablet.

All of this functionality is useful and will be used on several of my projects, including my Minima Transceiver (see many previous posts). I plan to write software to provide a Remote Panel for the Minima.


Boat Camping

During last years Boat Camping trip to the San Juan Islands,  I had 8 adults and their attending kids on board my Boat. Most camped overnight on shore.

They all had there personal devices and after the first night, they all needed to be re-charged. We had a few USB Chargers in the Boat, but there was a line waiting to gain access, I had little time on the charger myself.

For this next year, I plan to install MotorCycle USB Chargers in several places on the Boat. One will be installed on the Bridge, where I can use it with the Tablet and Navigation Software.

MotorCycle USB Charging Ports



More details to follow - while having fun with the Raspberry PI !



-- Home Page: https://WA0UWH.blogspot.com

A Lurking Raspberry PI 2

I have been playing with the Raspberry PI 2, connecting a PI Camera and Servos to it. To provide articulation, I used an optional 12" Camera Cable for the connection.

After several hours of research I have figured out how to capture and stream images. Recently I have also figured out how to use the Servos Hat (servo adaptor board) via the Adafruit's I2C Libraries.

So with the combination of Camera and Servos, I now have a "Lurking Raspberry PI".

 I have bits and pieces of programs to control the camera and adjust the servos over the Internet, I just need to assemble the pieces together for a convenient Internet controlled system. Most of the programming will be in python, as contributed libraries are readily available.

The Raspberry PI is currently tethered via a Network Cable, and Power Cord.  But, by adding Wheels, (a big) Battery, and WIFI, is should be able to roam as desired.

My goal is complete control from my Tablet (and from any place on the Internet). Currently, simple Servo Commands can be sent via "ssh" and "telnet" on a private Public IP Address, Private Port, and Private Password. Video is also streamed to a Browser, with and a similar network connection. When completed, a single interactive Web Browser session will control the Camera Servos and future Wheel motors.

One of my goals is to, make the "Lurking Raspberry PI" available to the public with limited control, but that will be in the future.

Raspberry PI 2

I added the Servo Hat, and of course the Adafruit Case was full.

Full Case

Note: it appears that I did not have the Raspberry PI completely snapped in place.

There is not a space to mount the Camera and the Case Lid no longer fit on. So, I cut the bottom out of another one of a Ladyada's cases, which with just a little cutting and adjusting fits perfectly stacked (it almost snaps together). But it may not be an easy task for someone with two left (or right) thumbs. To make things easier, I believe Ladyada is planning an extension case similar to this.

Stacked Cases, The Bottom was Removed from Top Case

The removed (cut out) bottom is being used as an insulator between the Raspberry PI and the Servo Hat, otherwise the Servo through hole pins touch the metal HDMI connector, and it helps stabilize the Hat without special screws and spacers. The Nibs were left on the plastic to help hold-up the far side of the Servo Hat. A slot was cut to accommodate the Camera Cable.

Salvaged Case Bottom

The Two Ganged Servos are mounted on the Case cover.

Servos Mounted

The Case is closed and the Camera is installed, now it is almost ready for Action. The Bands ensure that it does NOT spring apart, and provides anti-skid feet.

Ready For Action
It's Lurking, . . . at me?

It looks like I could have use a little shorter 8" Camera Cable, but 12" Camera Cable will work fine.

More details of this project will follow, I plan to post some photos and/or captured video.

--

Sunday, March 15, 2015

More, CloseUp Tablet Photos

After thinking about the photos taken for the previous post, I was wondering how photos compare; when taken with the Tablet "Magnify App", and when taken through the Microscope Lens with a Tablet or Cell phone Camera?

Here is a photo taken with the Cell Phone Camera (at the Eyepiece Lens) through the Microscope at 15x Power (30x Eyepiece and with a 0.5 Diopter Object Lens).


Cell Phone Photo
through the Microscope Lens
(2.6MB)
The following photo shows the same area, taken with just the Tablet Camera with the "Magnify App".

Tablet Photo using "Magnify App"
(1.5MB)
And the same area with just the Normal Tablet Camera.

Tablet Photo using Normal Camera App
(2.5MB)
The following is the set up, as can be seen, I am just holding the Tablet, using the Microscope LED Ring Light for lighting. The photo was taken with a Cell Phone. The mouse-PCB (the photo subject) is in the spot light.

Set up Configuration
Photo take with Cell Phone
(3.7MB)
By the sizes of the saved photo files, it is obvious that the Magnify App is using Digital Zoom. but for my blogs the photos are large enough and have enough resolution.

Conclusion: I think until I get a better Microscope Mounted USB Camera, I will be using the Tablet with the "Magnify App" for most of my blog photos.

To make taking photos easier, I plan to build a stand to hold the Tablet steady. The Microscope Ring Light works fine for my photos.

--

Saturday, March 7, 2015

Mouse Surgery

Several weeks ago my Computer Mouse started acting up.  It would sometimes Double-Click on a single left button Click. This is very frustrating as unexpected functions results.

I had recently updated the OS and was thinking that the update had tweaked the Mouse Drivers and inappropriately set the de-bounce timing in the software. But Nope, replacing the mouse solved the problem.

Because I had a similar junk box mouse, I decided to see if I could replace the left button switch and solve the problem.

Right Button Switch Salvaged
From Junk Box Mouse
I successfully removed and reinstalled the mouse switch, I used the right switch from the junk box mouse, thinking that it had "less use" than the left switch. De-soldering the switch was a pain, because it was constructed with Lead Free solder.

I hate Lead Free solder ! And now, my local source for good 62/36/2 is going away, that is RadioShack is going out of business.
62/36/2 Solder

This Mouse surgery was done under heave sedation (battery removed) and with the aid of a Microscope :-)

After surgery, I decide to take some Microscope photos, but my standard microscope USB Camera is OLD and with a bare minimum resolution, I think it is 3Meg Pixel Photo Frame. For modern photos, a minimum is 9 to 12Meg Pixels would be ideal, but high resolution Microscope USB Cameras are expensive.

Recently I had read that reasonable photo can be taken through the Microscope (or telescope) with a cell phone camera, just place the phone camera at the eyepiece. Holding the my tablet steady and in focus was a real problem. Adaptors and fixtures are available on-line.

Microscope and Tablet Camera Photo
The photo resolution is 3264 x 1836 pixels (1.8Mbytes).

The tablet has a Camera "Magnify" Application, just for fun I decided to try it on some small parts. The following were taken with just the tablet camera. Most photos are about 2MBytes in size. I am pleased with the simple results.

The first part is the dis-assembled bad mouse switch, I was wondering if I could spot the problem, I thinks so, "crud" on the contact causing switch bounce.


The following were take just for fun. Note: all of these were taken with just the Tablet Camera. The dime in the corner for scale, note: at this scale, everything appears with "crud" attached. It is no wonder that "clean rooms" are necessary for manufacturing.


For me, this switch is amazing, beautiful, and a marvel of Engineering and Manufacturing.

Just for fun, more photos were taken of other miscellaneous parts.

I Think this is a 1206 size Capacitor
BTW: The Mouse will live, to Run another day :-)


-- Home Page: https://WA0UWH.blogspot.com

Saturday, February 28, 2015

Pi's and Install Configuration

UPDATED:

My Raspberry Pi 2's have arrived!  Two of which are now running on the Internet.  I have three locations that I want to install and run them from.

New Raspberry Pi 2's
The initial installations will be running Raspbian (wheezy) serving simple Ham Radio Blog pages and running some HF Beaconing or Receiver code. See: http://dc01.ebcon.com:8040/

As a system administrator for large employers, I have installed and configured many Linux (UNIX) systems, I now have it down to quick trivial process.

For Raspberry Pi, First:

On the Raspberry Pi, I immediately execute the following commands:




$ sudo aptitude install ssh sshuttle
$ sudo aptitude install xosview htop tree wicd apache2 php5
$ sudo aptitude install vnc-server vnc-viewer




Note: if these are already installed, no harm. See the man pages as necessary.

Then I add users as necessary, with:



$ sudo adduser <user_name>




And then, add the appropriate admin "user_name" to the "sudo" group


$ sudo adduser <user_name> sudo




Then:

There are several things I DO NOT like about most default UNIX installations.

The first is the default command "prompt", which is typically a long string of characters that is; the user and system name, and the current working directory. The information is good, but the format is terrible. While in a directory way down in the directory structure, typing space on the displayed command line is very limited, and wraps around and is difficult to use. For example, change to the directory as shown:



$ cd /usr/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Control/



This will result in a Command Prompt of:



pi@rbpi3 /usr/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Control $ 




Note: there is little typing space on the line to the right of the "$". There is little wonder why most users get turned OFF with the Linux Command Line environment.

I personally like the same information, only in a different prompt format. For example (see below), the "date" command was entered at the prompt, and then executed, a new prompted followed:




/usr/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Control
rbpi3$ date
Sat Feb 28 12:32:40 PST 2015

/usr/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Control
rbpi3$




In this example the prompt starts with a blank line, followed by the current directory, and then on the next line, the name of the system, followed by the "$" prompt. Regardless of the length of the current directory, the user starts typing at the same location on the command line (and with space to spare).

Modifying or Adding this type of Prompt is simple, but I have done it "too" many times, see shell script below.



PS1='\n$PWD\n\h\$ '



Also, I set the default "command line editor" to "vi", this allows the use of "vi" key commands to "edit the command line", and access "command history stack". As in; "h" and "l" (cursor Hop-left and Leap-right), "j" and "k" (history Jump-down and Klimb-up). Also, see shell script below.



set -o vi



I now add a simple script (/etc/bash.bashrc.local) to each system I install. It contains all of my favourite system modifications. The script is as shown below, details are not provided, but maybe you will find bits-of-it you would like also.

Note, depending on the initial OS installation, each user may want to remove the ".bashrc" and ".profile" from their home directory, or adopt parts of this script in their files. I like the system wide approach, an yet, while knowing that it is a little dictatorial.




#
# Usage in /etc/bash.bashrc
# Add the following two lines to the end of /etc/bash.bashrc, uncommenting the "test" line.

   # Start up /etc/bash_localrc for Local Stuff
   # test -f /etc/bash.bashrc.local && . /etc/bash.bashrc.local

# Local Startup files for Bash

   #echo "Start: /etc/bash.bashrc.local"
   #set -xv

   TZ='PST8PDT'; export TZ
   PATH=/usr/local/lbin:$PATH

# Show System Key

   # KEY="$(ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub)"
   # KEY="${KEY#* }"
   # echo
   # echo "System Key: ${KEY% *}"

# Setup the default editor
   export EDITOR='vi'
   set -o "$EDITOR"

# Setup History
   HISTSIZE=10000
   HISTCONTROL=ignoreboth:erasedups
   shopt -s cmdhist histappend lithist execfail

# Add extended globing
   shopt -s extglob

# Set the Terminal Tab value
   # If this is an xterm set the title to user@host:dir
   case "$TERM" in
   xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
     ;;
   esac

# Prompt # for root, $ otherwise
   PS1='\n$PWD\n\h\$ '


# Local Aliases
   alias ll='ls -l '
   alias bdf='df '
   alias is='ps -ef | grep -v grep | grep -- '

   #set +xv
   #echo "End: /etc/bash.bashrc.local"


# Some Interesting Shell Stuff
   alias ralias='. $HOME/.alias'; # reread HOME aliases
   alias ...='cd ../..'
   alias ..='cd ..'

# Local GitHUB Aliases
# Git related
   alias gco='git checkout'
   alias gci='git commit'
   alias gst='git status'
   alias gbr='git branch'
   alias gls='gbr'
   alias gsbr='git show-branch'
   alias gmg='git merge --no-ff -v --progress'

   alias gad='git add'
   alias gdf='git diff'
   alias glg='git log'
   alias ggp='git grep'
   alias gpu='git push'
 
   alias gk='gitk --all &'
   alias gr='git rebase'
   alias gri='git rebase --interactive'
   alias gcp='git cherry-pick'
   #alias grm='git rm'

# End



I use "scp" to grab the script from a previously installed system.


Security Tip

If you going to put a Raspberry Pi on the Internet:
  • Remember to set a new passwd on the pi login
  • Do not open the ssh port 22 directly to the Internet, use a router to NAT and route another port to the Raspberry Pi. Note: if you DO open port 22, your system will be hammered by break-in attempts. Check your logs often.
  • Open only the ports that are necessary for your applications.
  • Also, I recommend doing something similar for port 80.

Be careful, the Internet is full of malicious hackers and "script kiddies" that will take over and eat your Raspberry Pi.

The following is a script that I wrote many years ago, as "taillogs", it "lists" and "follows" the system logs, showing new log events as they occur. I know it is somewhat cryptic, but does a nice job.

I saved this in a file: "/usr/local/lbin/taillogs".

Note: "/usr/local/lbin" is where I save all of my authored scripts.




#! /bin/sh
# Author: Eldon R. Brown, eldonb@ebcon.com

        cd /var/log &&
        find . -type f -print |
        egrep -v "\.[0-9][0-9]*$|OLD|mbox|\.offset$" |
        xargs ls -tr |
        xargs file |
        sed -n '/ text/s/:.*//p' |
        xargs tail -n2 -f

# End



With this script, it is easy to check your system logs.


-- Home Page: https://WA0UWH.blogspot.com

Minima - My Coding Efforts Resumes

After a long delay (due to surgery), I am returning my attention to my Minima Controller Alternate Tuning Method coding effort.

My previous (i.e. current) revisions as available on GitHub "radiono_erb" will remain as-is, with little or no further development for now.

I will "Fork" (GitHub speak for clone) my current Minima Controller GitHub Repro and give it a new name, currently the planned name will be "radiono_PNW_Exp". This Fork will initially be used to experiment with some new Minima Controller software and hardware strategies. Later, "radiono_PNW" will be published for general use. Note: PNW denotes Controller coding efforts that some Minima Builders around the "Pacific NorthWest" are considering. See: http://groups.yahoo.com/group/pQRP/

Goals

One Goal is to reduce the front panel switch and knob foot print, that is, maybe reduce the number of switches and knobs, but at the same time increase the Controller functionality. Maybe this can be done by optimising the circuit and supporting code. The standard Minimal Volume control could be eliminated with a change of the circuit to add an I2C Quad POT. The Quad POT has four sections; 1) for volume control, the three others could be assigned other tasks, for example: 2) LCD backlight control, 3) LCD Contrast control, 4) and maybe a future Automatic Level or Gain Control (ALC or AGC). Others could be added as required or wanted.

My personal Goal is to reduce my Minima to a small hand-held unit by using very small SMT parts, yet, maintain compatibility with the majority of Builders using their Through-Hole and/or Ugly style of construction. I am a fan of Ugly Style of construction, but for my Minima project small(est) is better.

I plan to maintain circuit and software flexibility to potentially use and include a computer interface, via bluetooth or direct cable connections. Current (readily available) software programs could control and provide a familiar user environment for the Minima.

My overall Goal, which is similar to the main idea of the "Minima", is to; "Use Less Hardware, and Do More with Software".



-- Home Page: https://WA0UWH.blogspot.com

Friday, February 20, 2015

Back to My Projects - Remote Desktop Protocal (RDP)

OK, it has been almost eleven weeks since my surgery - So now I can get back to; My Blog,  Electronic, Programming and Ham Radio Projects. I have been working on them, but in very short sessions.

The last few days I have been updating all of my Workstations to/with LinuxMint 17.1 (Cinnamon). I gave up on Ubuntu due to bloat and continual lack of support for problems that continued to bug me.

But LinuxMint (17.1) appears to have one of the same problems as Ubuntu - that is, Lack of "easy to use" Remote-Desktop-Protocal (RDP) configuration.

My desire is to connect and control other remote workstations and a few Raspberry Pi's from my Main Workstation. RDP is designed to display the remote Consoles on the main workstation, but people on the web have complained that after the last few system updates, it does not work as advertised, and I found that to be the case.

Disclaimer: There are many aspects of X Display, VNC and Remote Consoles that I do NOT know, nor understand. Information provided here has be found experimentally or after much online reading, your mileage may vary.

After many long hours of web research, trial and error, I now have a possible solution, which is really simple, once the magic is known. The solution is different for the remote Raspberry Pi (wheezy) than a remote LinuxMint (17.1) or newer Ubuntu system. The following examples assumes you have ssh, vnc-server and x11vnc installed as needed.

Using Remote Console of a Raspberry Pi is very easy, but several solutions are available depending on whether the Pi has a HDMI attached console or not, and whether or not there is an active logged in session.

Different methods are used to create, or use existing, Frame Buffers, and its address is denoted by the ":N" in the following examples. Any unused number can be used, but ":0" is normally reserved for the real graphic console (hardware monitor).



Pi systems "without" an HDMI attached Console (headless)

For Pi systems without an HDMI attached Console a "Display Frame Buffer" (fb) will not have been automatically created. The "vncserver" command creates a virtual Frame Buffer ":2", as seen in the following example. Also, note: ":2" is an alias for the value of the last two digits of "port number 5902".

Execute the following on the local system:

$ ssh remote_pi_sys_address 'vncserver -geometry 900x600 :2'
$ vncviewer remote_pi_sys_address:2

Note: the Geometry can be any size you like, I like 900x600 because it does not completely fill my local display.

Remote Virtual Console
Enjoy remote access to the PI, if the local window is deleted, it can be re-entered by re-executing the second command.



Pi systems "with" an HDMI attached Console, with Active Session

On remote system, run "Share Desktop", then on the local system execute:

$ vncviewer remote_pi_sys_address:0



Or, Pi systems "with" an HDMI attached Console, with Active Session

$ ssh -xCf -L 5900:localhost:5900 remote_pi_sys_address -l root \
        'x11vnc -q -auth /var/run/lightdm/root/:0 -display :0 -N'

$ vncviewer :0

Note: The required "-auth /var/lib/mdm/:0.Xauth" parameter is dependent on your remote_system and display manager used, which normally can be found via a remote "ps -efl | grep auth" command.



LinuxMint, Ubuntu and other Debian derived systems with RDP and VNC Console bugs.

See the Note above, regarding "auth". The following is accessing a remote LinuxMint system at the login prompt, supplying user name and passwd starts a normal remote session. Note: the displayed window will be the size and resolution of the remote monitor, scrolling may be necessary.

$ ssh -xCf -L 5900:localhost:5900 remote_sys_address -l root \
        'x11vnc -q -auth /var/lib/mdm/:0.Xauth -display :0 -N'

$ vncviewer :0

Remote Login
Note: failure can occur if the Local and Remote ports (5900) (as being requested here) are already in use, some of the following commands can be executed on the Local and Remote systems to help find port collision problem, killing the offending processes will free the port.

$ netstat -ta
$ lsof | grep 5900
$ ps -efl | grep 5900
$ ps -efl | grep vnc

The use of a "virtual" Console would be much better, one that allows you to specify the window size. But alas, it does not work as expected, the default configuration does NOT provide an interactive window manager.

This example does not work as well as it should.

$ ssh -xCf -L 5908:localhost:5908 remote_sys_address \
        'vncserver -geometry 900x600 :8'

$ vncviewer :8

I plan to continue to explore for a usable solution that provides a specified size of window for LinuxMint, Ubuntu and other Debian Derived systems. Currntly only the Raspberry Pi (wheezy) works as expected.



-- Home Page: https://WA0UWH.blogspot.com