Tuesday, August 4, 2020

Remote WSPR with a Raspberry Pi

Monitoring my WSPR station on an iPad

WSPR (Weak Signal Propagation Reporter) is a good way check the performance of antennas, and it is always very cool to see how far I can transmit with low power.  

For example, the map below shows where my 5 watt WSPR signal was received over a 24 hour period on 20 meters (using my 80-meter full-wave loop in Nevada City, CA, grid CM99mg):


But WSPR requires a computer, and because my radio room is not close to my "home office" where I normally use my laptop, if I want to use WSPR I have to first eject my laptop from its docking station in the office, carry it to the radio room, and connect it to my WSPR interface.

All very inconvenient.

A friend, Dick Benson (W1QG), mentioned that he was making a WSPR computer using a Raspberry Pi.  The Raspberry Pi would be stand-alone -- it would not need to be directly connected to his home computer.  

Instead, the Raspberry Pi would be a dedicated "remote" computer (without display, keyboard, or mouse) and he would communicate with it (and control it) via the internet (WIFI), using a "remote desktop" application on his PC, operating under Windows.

Well, this idea sounded like just what I needed in my ham shack.  I could keep my laptop in my home office and have a small, dedicated processor out in the radio shack handling WSPR communications.

But I am a newbie to the Raspberry Pi and to Linux, so I approached the project with some trepidation.  Overall, though, I found the process more straightforward than I had anticipated (Google searches were very helpful whenever I ran into a stumbling block).  This blog post documents the steps I took to create my own "remote" Raspberry Pi WSPR computer.   


The Raspberry Pi board is shown above (along with a USB Audio Interface).  

And below is a screen-shot of my laptop's "remote desktop" view of the Raspberry Pi running WSJT-X:


I'll start by describing the hardware I'm using, including an audio-derived VOX PTT interface to control PTT for my radios that do not have CAT control interfaces.  

I will also describe using the Raspberry Pi to control the FT-1000D's PTT via a CAT-interface PTT, in lieu of the audio-derived VOX PTT. 


Hardware, Overall:

The image, below, shows the different bits and pieces that comprise my remote WSPR station.  Note that I am using a Yaesu FT-1000D as my WSPR transceiver.  Note that, although the FT-1000D does have CAT control, I'm going to start by describing a system that controls the transceiver's PTT using audio-derived VOX PTT.


And here's a block diagram:



HW, XCVR Audio I/F

My "Transceiver Audio Interface" is one that I originally built to connect my FT-1000D Rx and Tx audio to my Lenovo P50 laptop.  I use this same interface module, without modification, to connect the transceiver to the Raspberry Pi. 

Because my Lenovo laptop uses a single 3.5mm Tip/Ring/Ring/Shield (TRRS) jack for both audio input and audio output (i.e. it is the headset jack), my Transceiver Audio Interface has a corresponding 3.5mm TRRS plug to connect it to the Lenovo's TRRS headset jack.  

This same TRRS plug will connect to the Raspberry Pi (via adapters, to be described below).

The Transceiver Audio Interface is shown, below.  You can see cable terminated with the TRRS plug coming from the left-hand side of the box. 


At the right side of the box (next to the two red-knobbed potentiometer volume controls) are two 3.5mm stereo (TRS) jacks.  These two jacks connect to the transceiver's audio input and output (via appropriate patch cords)

The top 3.5mm jack brings in Receiver Audio from the FT-1000D's "AF Out" 3.5mm TRS jack on the transceiver's back panel.  This connection is made with a stereo 3.5mm male-male patch cable (TIP is the sub-receiver audio out, and RING is the main-receiver audio out.  My Transceiver Audio Interface uses the RING (main receiver) audio, not the sub-receiver audio).

The bottom 3.5mm jack in the image, above, sends audio from the Raspberry Pi to the FT-1000D's Mic input.  This 3.5mm jack is wired with TIP as PTT and RING as Mic Audio.

A 3.5mm stereo male-male patch cable connects this jack to a jack on a homebrew adapter that then connects to the FT-1000D's 8-pin Mic DIN connector.  (Adapter wiring described later in this post).

XCVR Audio I/F Schematic:

Here is the Audio Interface schematic.

Schematic Notes:
  • PTT is audio derived (VOX), and requires 5 to 12VDC to power the VOX circuitry
  • The PTT output is open-collector, and is low-true when active (pull-up required at xcvr).
  • Overall circuit based upon a design by Dick Benson, W1QG

HW, 3.5mm to FT-1000D Mic Adapter:

I made the following adapter to connect a 3.5mm TRS patch cable to the FT-1000D's mic input:


The illustration, below, shows how I wire the signals between these two connectors:
 


HW, Raspberry Pi and USB Audio Interface:

The photo, below, shows the Raspberry Pi and USB Audio Adapter I'm using:


The Raspberry Pi is a "Raspberry Pi 3 Model B+".  To simplify the purchasing process, I decided to purchase a Starter Kit from Amazon that includes:
  • Raspberry Pi 3 Model B+
  • 32GB micro SD card, pre-programmed with NOOBS 
  • DC Power Adapter, 5V/3A
  • Case
  • HDMI cable
  • And other bits and pieces (e.g. heatsinks, quickstart guide).  
Below is the Amazon link to this Raspberry Pi 3 B+ Starter Kit:


Note, although the Raspberry Pi has an Audio/Video (A/V) interface connector on its board, this interface only provides Audio Out.  There is no Audio Input on the Raspberry Pi 3 B+ board.

I need both Audio In and Audio Out for WSPR.  A simple way to provide both functions is with a USB Audio Adapter.  The USB Audio Adapter provides for the Raspberry Pi an analog Mic Input (mono) and a stereo analog Headphone Output.

Below is the Amazon Link to the USB Audio Adapter I am using:



Y-Splitter Cable:

I needed some way to connect the USB Audio Adapter's two 3.5mm TRS audio jacks to my Transceiver Audio Interface's 3.5mm TRRS plug (the plug that would normally be inserted into my laptop's headset jack).  The Y-Splitter cable, shown below, provides this function. 


Here's the link for the cable I purchased:


By the way...I can eliminate the Y-Splitter cable if I change my USB Audio Adapter to one that accepts a 3.5mm TRRS Headset plug, such as this one:


Version 2 Block Diagram if using this Adapter:

And a photo, too:



Setting up the Raspberry Pi and the Windows Remote Viewer:

1.  Raspberry Pi, Out of Box:

The Raspberry Pi 3 Model B+ starter kit contained a 32 GB micro SD card that already had the NOOBS package (New Out Of Box Software) installed on it.  (If you need to load NOOBS onto a virgin SD card, go to the website in the previous link).

To get started with the Raspberry Pi I needed a display (with HDMI interface), a USB keyboard, and a USB mouse in addition to the shipped pre-programmed 32 GB micro-SD card and the 5VDC power adapter.

I connected together the above items in the following order:
  1. Insert programmed 32 GB micro-SD card into the micro SD card holder on the bottom of the Raspberry Pi board.
  2. Attach a USB Keyboard and a USB Mouse to two of the Pi's USB ports
  3. Attach the HDMI cable to the Pi's HDMI port.  The other end of the cable attaches to an HDMI port on a monitor.
  4. And attach the 5VDC Power Adapter's plug into the Pi's "PWR IN" connector (J1).
Then, power up the Raspberry Pi.  If it successfully boots, you should be taken through a few setup prompts which should be self-explanatory (be wary, though of removing the "black space" around the screen.  If your choice is incorrect, this can be a bit of a headache to fix).

Being a complete "newbie" to Raspberry Pi's, I found the following video helpful:


Note that the presenter discusses a number of topics that might not be needed, but I found his procedure for enabling/disabling the "back space" around the image very helpful, after I discovered, during the Pi's setup procedure, that the black space I saw around the image should not be removed.  After I accidentally "removed" the non-existent black space, the image was too large for the display and I had to edit the config file (a process described in the video) to bring its margins back into the displayed area.


2.  Obtaining the Pi's IP Address:

To operate WSPR remotely using the Raspberry Pi, we need to communicate with it over the internet, and thus we need to know the Raspberry Pi's IP address.

To obtain the Raspberry Pi's IP address, click on the LXTerminal icon on the menu bar at the top of the screen and then type "hostname -I" at the prompt in the LXTerminal's window:


Then press "Enter" on the keyboard.  LXTerminal should return a sequence of numbers representing the IP address, e.g:  123.456.78.90.  Write this number down -- you will use it later.


3.  Update and Upgrade the Raspberry Pi's software:

A website I'd found recommended that after successfully booting up the Raspberry Pi for the first time, its software should be updated and upgraded.

To update the software, use LXTerminal and type: "sudo apt-get update" <ENTER> at the prompt.

Next, to upgrade the software, use LXTerminal and type: "sudo apt full-upgrade" <ENTER> (the upgrade will probably take some time).

Note:  You could also upgrade using a "sudo apt-get upgrade" command.  But I found the "sudo apt full-upgrade" to be preferable to "sudo apt-get upgrade".  I had first tried this latter command and, although it seemed to work OK, I discovered when I tried using the Raspberry Pi's File Manager that the File Manager was screwed up (the file tree would appear and then immediately disappear).

Googling, I found a website recommending using "sudo apt full-upgrade" in lieu of  "sudo apt-get upgrade" to fix this problem.  I tried the 'full-upgrade' command, and it worked.


4.  Setting up a Remote Viewer on the Windows Desktop:

Next, I installed a remote viewer on my laptop, operating under Windows 7.

There are a couple of choices for remote viewers that I am aware of.  One choice is Windows "Remote Device Connection" that comes pre-packaged with Windows. (Note that this viewer requires the installation of XRDP on the Raspberry Pi.  If you would like to install this package, type "sudo apt-get install xrdp" in the LXTerminal).

However, I do not recommend this viewer, simply because I am unable to use the Raspberry Pi's "Shutdown" button (under "Logout" in its menu) to remotely shut-down the Raspberry Pi.  Instead, I can only remotely shutdown the Raspberry Pi by typing "sudo shutdown -h now" into LXTerminal.  Very inconvenient!

The second viewer (and my preferred choice) is better behaved with respect to Shutdown.  This viewer is "VNC Viewer".  The Raspberry Pi should already have VNC Viewer's associated "VNC Server" loaded on it (if you are using the NOOBS software package).  You can identify if the VNC Server is present on your Raspberry Pi by the presence of its icon on the Raspberry Pi's menu bar, as shown, below:


If the icon is there, you should be good to go.  Download the Windows "VNC Viewer" via the link, below:


With "VNC Viewer" now installed on my laptop and operating under Windows, I did all further Raspberry Pi setup operations remotely, via my laptop, with the Raspberry Pi operating "headless" (that is, without display or keyboard attached to the Raspberry Pi).  

To operate "headless", do the following:
  1. Shutdown the Raspberry Pi (use the Shutdown button under the Raspberry Pi menu's "Logout" icon).
  2. Turn off power to the Raspberry Pi.
  3. Disconnect the USB Keyboard.
  4. Disconnect the USB Mouse.
  5. Disconnect the HDMI cable.
  6. Connect the USB Audio Adapter to a USB port.
  7. Power-up the Raspberry Pi.
The Raspberry Pi should now be powered up, but of course, with no display attached, you cannot see its desktop.

Now, launch "VNC Viewer" on your PC.  If the Raspberry Pi has finished booting, a prompt should appear asking for the IP address to which VNC Viewer should connect.  You will need to type into this prompt the Raspberry Pi's IP address that you (hopefully) wrote down earlier.

VNC Viewer will then attempt to connect to the Raspberry Pi.  If it is successful, you should next see an "Authentication" window asking for your User Name on the Raspberry Pi (if you haven't changed it in the Raspberry Pi setup, its default is "pi") and a Password (its default is "raspberry").  


Type in the appropriate User Name and Password, then click "OK".

You should then see your Raspberry Pi's desktop appear in a new window on your Windows desktop!

If the Raspberry Pi is running "headless", the VNC Viewer's window of the Raspberry Pi desktop will probably be set to the Raspberry Pi's default resolution of 768 by 480 pixels.  If this is the case, your Windows desktop might look like this (note that my Windows desktop, which you can see below, has an overall resolution of 1920 x 1080 pixels).


I have found that the default resolution of 768 x 480 is not adequate for viewing WSJT-X, as you can see in the following screen-capture of the VNC Viewer window:


Increasing the Raspberry Pi's resolution to 1280 x 720 greatly improved viewing WSTJ-X (procedure for doing this described next).


Much better!

Note:  The "VNC Viewer" App also exists for other devices.  For example, I downloaded VNC Viewer from the Apple app store (it was free) and installed it on my iPad:



5.  Changing the Raspberry Pi's Display Resolution:

You can change the Raspberry Pi's screen resolution the easy way, by using the Raspberry Pi menu, or the harder way, via commands typed into LXTerminal.

Let's look at the easy way...

Changing Display Resolution via Raspberry Pi's menus:

First, go to the "Preferences" under the Raspberry icon and select "Raspberry Pi Configuration".


When the "Raspberry Pi Configuration" window appears, go  to the "Display" tab.  Then click on "Set Resolution" and select the desired resolution from the pull-down menu.


Click "OK".  Then click "OK" again to exit the "Raspberry Pi Configuration" window.  You will then be prompted to reboot the Raspberry Pi (after which your display will be at the new resolution).


And here is the harder way to change the Raspberry Pi's resolution...

Changing Display Resolution via LXTerminal:

First, launch LXTerminal and at the prompt type "sudo raspi-config".


Press the keyboard's ENTER key to perform the command.  You should then see the "Raspberry Pi Software Configuration Tool" (pictured below).  Use the arrow keys to scroll down to "Advanced Options" and press the keyboard's ENTER key.


Now you should see the "Advanced Settings" menu.  Use the arrow keys to scroll down to "Resolution" and press the keyboard's ENTER key.


The "Resolution" menu should now appear.  Scroll down to the desired resolution (I use 1280x720):


Then press the ENTER button.  Finish up by using the arrow keys to select <OK>, <FINISH>, and finally <YES> at the reboot prompt.

After rebooting (which will cause VNC Viewer to temporarily lose its connection with the Raspberry Pi), you should see on your Windows desktop a larger window for VNC Viewer:



Next, let's setup the USB Audio Adapter to be the Raspberry Pi's default Audio device.


6.  Select the USB Audio Adapter to be the Raspberry Pi's default Audio device, and setting its Output Volume:

(In these menus I've changed the Raspberry Pi's "Appearance Settings" defaults to be for "Medium Screens" (via Preferences>Appearance Settings>Default Tab).  This enlarges the icons for improved viewing.)

First, right-click on the speaker icon at far right on the top menu bar .  You should then see two selections, "Audio Outputs", and "Audio Inputs".


Select Audio Outputs.  Then select USB Audio Device


Repeat for Audio Inputs:


That's it!

(Note, for reference, you can also set the USB Audio Interface to be the default audio device by using commands typed into the LXTerminal.  For more information on this procedure, see THIS WEBSITE.)

Finally, here's how to set the Audio Output volume (I use this to set the Raspberry Pi's Output Audio level so that it is high enough to trigger my Transceiver Audio Interface's VOX PTT circuit):



Next, load WSJT-X onto the Raspberry Pi...


7.  Loading WSJT-X onto the Raspberry Pi:

Loading WSJT-X is straightforward if you don't mind not having the latest version of WSJT-X.

First, one must get the WSJT-X packages that are compatible with Raspberry Pi Linux.  To do this, go to "Preferences" and select "Add/Remove Software":


(Note that I've changed my wallpaper from the default "Temples" image to one of my own photos.)

Next, type "WSJTX" <ENTER> into the text line.  The search result will be displayed in the large pane to the right, as shown, below (which shows that 3 packages for WSJTX version 2.0.0 were found).  

Make sure all three boxes are checked, then click OK in the lower right-hand corner:


WSJT-X (version 2.0.0) will now be installed.

Following the installation I do a reboot.  When the VNC Viewer screen reappears, I can launch WSJT-X by clicking on the "WSJTX" icon under "Sound & Video":


You should see something like this:


To configure WSJT-X, click on "File" and select "Settings...":


The "Settings" window should appear.  Under its "General" tab I've filled in my call and grid location:


Next, I need to select the Audio "Soundcard" device that WSJT-X will use on the Raspberry Pi.  This is set under the "Audio" tab.  The "Soundcard" devices are initially set to Default, and they need to be changed to the USB Audio Adapter.

To find the list of devices, click on the "arrows" (shown below) for both Input and Output:


From the list, I selected the "plughw" device. (From the listed names, this selection certainly was not clear to me, so I went with the one that had "plug" in its description, and fortunately it turned out to be the USB Adapter).


Below are my final Audio settings:


After everything is setup properly, WSJT-X should start decoding the WSPR signals being received (make sure input audio levels are set properly, per WSJT-X recommendations).

To transmit I need to ensure that the output audio level is high enough to trigger my VOX PTT circuitry in my Audio Interface module.  To do this, I adjust the Volume control, as shown, below:


That's pretty much it!  The WSPR station should now be operating.


Raspberry Pi with CAT Control and the FT-1000D:

I had been using an analog-derived VOX PTT signal to key my FT-1000D (VOX PTT because I use my Transceiver Audio Interface module to operate WSPR with other transceivers whose only method of transmission-control is via the PTT on a mic connector).  

But the FT-1000D has CAT control, so why not try using it in lieu of audio-derived VOX PTT?  I would no longer need an analog VOX PTT circuit and could thus disconnect the +12VDC supply from my Transceiver Audio Interface module.

I purchased this CAT Interface cable for the FT-1000D:


The following Block Diagram shows its connection to the Raspberry Pi and the FT-1000D:


(Note that there is no longer a +12VDC supply connected to the Transceiver Audio Interface.

And here's a photo of the same setup:


Setting up WSJT-X on the Raspberry Pi to use CAT contro is "fairly" straightforward.  After inserting the CAT Interface cable into the Raspberry Pi's USB port, discover its name by typing "ls -l /dev/serial/by-id" <ENTER> into the LXTerminal window, as shown, below:


I only have one serial device attached to the Raspberry Pi, and, as shown in the image above, its name ends with "/ttyUSB0".  This is the device I will select in the WSJT-X Settings menu (under the "Radio" tab) for the CAT Control "Serial Port", as shown, below:


In addition to the "Serial Port" that I've selected, as shown above, I'll also make the following menu selections for FT-1000D CAT Control:
  • Baud Rate: 4800
  • Data Bits: 8
  • Stop Bits: 2
  • Handshake: Default
  • PTT Method: CAT
These changes are shown in the screen-shot, below:


After the menu selections have been made, test the CAT interface by clicking on the "Test CAT" button in this same WSJT-X window.  But note, the button might not change color (green indicates that the CAT test was successful, red indicates failure).

The image below shows how the button should look if the CAT test is successful.  Note that it becomes green:


In fact, after I had clicked the "Test CAT" button, it turned neither green (pass) nor red (fail) -- it simply remained its default color and there was no other indication on the WSJT-X window that the CAT interface was working, or not.  

After playing around with the options settings, I did notice that some settings would invoke a "CAT failure" window (which did not appear with the settings I show selected, above).  

Finally, I noticed a "CAT System" annunciator blinking on the FT-1000D's front panel:


This blinking "CAT System" indicator was the only indication that the Raspberry Pi was successfully communicating with the FT-1000D.

The Raspberry Pi was communicating with the FT-1000D.  And WSJT-X could now initiate transmissions via CAT Control.

The CAT Interface was now successfully integrated with the Raspberry Pi.


Weird Things about CAT Operation with WSJT-X on the Raspberry Pi:

There are a couple of weird things I noticed when using WSJT-X and CAT PTT operation with the Raspberry Pi, compared to my previous PTT operation with audio-derived VOX PTT.  These things are:

1.  As mentioned above, the "CAT Test" button does not change color to indicate the result of the CAT test (neither green for pass, nor red for fail, yet the test, in my case, seemed to have passed).  At the moment, I do not know the cause.

2.  There seems to be a significant delay (on the order of seconds) in the actual engagement of the FT-1000D's PTT when controlled via CAT and the Raspberry Pi from "VNC Viewer" on my laptop.  I especially notice this delay if I toggle the "Tune" button on the WSJT-X control panel.  It seems like the actual toggling of the PTT state at the transceiver is delayed by 2 to 4 seconds from the moment I click on the "Tune" button, which I find quite noticable.  

I will note, though, that this delay does not seem to affect transmission or reception of WSPR signals.


Other Hints and Kinks:

1.  Changing the Raspberry Pi's Wallpaper Image.

You can select from a number of pre-supplied images using "Appearance Settings" under the Raspberry Pi's "Preferences" icon.

If you'd like to use your own image (as I did), you can do the following.  This might not be the most effective way (after all, VNC Server does let you transfer files), but it works:
  • Transfer your JPG image onto a USB memory stick.
  • Insert the USB memory stick into one of the Raspberry Pi USB ports.
  • In the Raspberry Pi's LXTerminal, type "sudo pcmanfm" <ENTER>.
You should now see a new window with file folders.  Locate the memory stick, open it, grab your image, and move it to the folder usr/share/rpd-wallpaper.

Eject your USB memory stick and close down this file-folders window.  If you then return to "Appearance Settings", you should now see your image as one of the images you can use for wallpaper.


2.  To display Raspberry Pi processor temperature:

To display the temperature of the Raspberry Pi core, open the LXTerminal and type into it:

"vcgencmd measure_temp" <ENTER>

You will then see the temperature returned in degrees Celsius.


3.  Capturing screenshots of VNC Viewer:

If you try to get a screenshot of VNC Viewer on Windows the normal way (using, for example, the Alt-PrintScreen keys), you will be unable to capture an image.  This is because the "special keys" that Windows normally uses are, by default, passed to the VNC Server rather than used by Windows.

To allow Windows to screen-grab the VNC Viewer window we need to disable the passing of the "special keys" to the VNC Server:

First, move the mouse pointer into the small white area at the top of the VNC Viewer window:


You should see a small menu appear.  Click on the "Gear" (i.e. Properties) icon:


In the "Properties" window that appears, go to the "Options" tab and uncheck the box for "Pass special keys directly to VNC Server".


You should now be able to use Alt-PrintScreen to grab screen captures of VNC Viewer.


Standard Caveat:

I might have made a mistake in my designs, equations, schematics, models, etc. If anything looks confusing or wrong to you, please feel free to comment below or send me an email.

Also, I will note:

This design and any associated information is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.