Raspberry Pi – Mike Richards G4WNC https://photobyte.org Freelance Technical Author, Illustrator & Photographer Tue, 18 Apr 2023 10:19:51 +0000 en-GB hourly 1 https://wordpress.org/?v=6.4.2 SimSmith on the Raspberry Pi https://photobyte.org/simsmith-on-the-raspberry-pi/ https://photobyte.org/simsmith-on-the-raspberry-pi/#respond Thu, 13 May 2021 11:23:35 +0000 https://photobyte.org/?p=10185 Anyone using a VNA in the workshop will find SimSmith an excellent tool. By combining the analysis of S parameters from a VNA with a circuit simulator, SimSmith becomes a powerful tool for designing matching circuits. In this post, I’ll show you how to install SimSmith on the Raspberry Pi.

SimSmith is a Java program, so all we need is the latest version of Java and the SimSmith.jar file.

Here are the steps to complete installation.

Visit: http://www.ae6ty.com/Smith_Charts.html and follow the links to download the latest SimSmith.jar file

Install Java by opening a terminal session (Ctl-Alt-T) and enter the following commands:

sudo apt install -y default-jdk

Confirm the installation with:java --version

Move the downloaded SimSmith.jar file from Downloads to your pi folder.

mv ~/Downloads/SimSmith.jar ~

Run SimSmith with: java -jar SimSmith.jar

For a desktop link, create a new file in the Desktop folder called SimSmith.desktop and add the following content:

[Desktop Entry]
Name=SimSmith
Comment=Runs SimSmith Java app from pi folder
Icon=/usr/share/pixmaps/openbox.xpm
Exec=java -jar /home/pi/SimSmith.jar
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;

]]>
https://photobyte.org/simsmith-on-the-raspberry-pi/feed/ 0
NanoVNA Saver on the Raspberry Pi https://photobyte.org/nanovna-saver-on-the-raspberry-pi/ https://photobyte.org/nanovna-saver-on-the-raspberry-pi/#comments Thu, 13 May 2021 10:11:06 +0000 https://photobyte.org/?p=10183 UPDATED 14-April 2023: The latest version of NanoVNA Saver requires PyQt6 which is not yet available for the Pi. I will update these instructions when it’s available.

NanoVNA Saver is an excellent package that provides a host of useful features for owners of the NanoVNA V1 and V2. When looking around the Internet for Pi installation instructions, I found several conflicting and out-of-date posts, so decided to develop my own. I thought it might be helpful if I post my solution here.

NanoVNA Saver works well on the Raspberry Pi models 3, 4 and 400, but installation requires a few simple steps as shown here. These instructions assume you’re using the latest Raspberry Pi OS.

Open a terminal session (Ctl-Atl-T) and enter the following commands sequentially.

cd ~

sudo apt install -y python3-pyqt5 python3-scipy

git clone https://github.com/NanoVNA-Saver/nanovna-saver

cd nanovna-saver

sudo chmod +r ~/nanovna-saver/nanovna-saver.py

You can now run NanoVNA Saver by entering: python3 nanovna-saver.py

To create a desktop link for NanoVNA Saver, use the following steps:

Create a new file called NanoVNA-Saver.desktop, add the following content and save it in the desktop folder.

[Desktop Entry]

Name=NanoVNA-Saver

Comment=Runs NanoVNA Saver from the nanovna-saver folder

Icon=/usr/share/pixmaps/openbox.xpm

Exec=python3 /home/pi/nanovna-saver/nanovna-saver.py

Type=Application

Encoding=UTF-8

Terminal=false

Categories=None;

]]>
https://photobyte.org/nanovna-saver-on-the-raspberry-pi/feed/ 27
WSJT-X 2.3 – Transmit Audio Failure with PiOS https://photobyte.org/wsjt-x-2-3-transmit-audio-failure-with-pios/ https://photobyte.org/wsjt-x-2-3-transmit-audio-failure-with-pios/#comments Fri, 19 Mar 2021 22:53:16 +0000 https://photobyte.org/?p=10135 Thanks to a report from John, GM0WRR, I have identified a problem with WSJT-X 2.3 and the use of PulseAudio on the Raspberry Pi.

When setting the input and output soundcard you would normally set both to pulse. However, if you do that, WSJT-X will fail after the first transmission. If you close and try to restart WSJT-X you will get a file lock error that you can’t clear. This is because, in its failled state, closing the program stops the interface but a WSJTX process is left running. To restart WSJT-X you need to reboot the Pi or Open the Task Manager (Accessories – Task Manager) and find wsjtx, right-click and kill it!

The work-around to this problem is to select the soundcard device, rather than pulse as the audio input and output.

Here’s a step-by-step process:

  1. With your USB soundcard or USB rig plugged in, start WSJT-X
  2. Go to File – Settings – Audio
  3. In the Soundcard, Input drop-down, select the entry that begins with: alsa_input.usb (it will probably be near the bottom of the list)
  4. In the Output drop-down, select the entry that begins with: alsa_output.usb (near bottom of list)
  5. Click OK to close and save the settings
  6. You should now be back in business.

Regards,

Mike – G4WNC

]]>
https://photobyte.org/wsjt-x-2-3-transmit-audio-failure-with-pios/feed/ 5
Installing & upgrading CQRLOG on a Raspberry Pi https://photobyte.org/installing-upgrading-cqrlog-on-a-raspberry-pi/ https://photobyte.org/installing-upgrading-cqrlog-on-a-raspberry-pi/#comments Tue, 14 Jul 2020 22:26:28 +0000 https://photobyte.org/?p=9865 Updated 17 July 2020 to add missing wildcards from the apt install line!

CQRLOG is one of the most complete contact logging programs for Linux and the Raspberry Pi, but building the latest version from source can be problematic. In this post I’ll show you a simple trick that simplifies the upgrade.

The main source of build problems is database configuration. The simple solution is to first install the old version of CQRLOG fom the Pi repository. To do that, open a terminal session (Ctl-Alt-T) and enter the following line:

sudo apt install cqrlog

By installing from the repository, all the supporting software, including the database application will also be installed. Once the installation has completed you should run CQRLOG by typing cqrlog. Answer’yes’ when asked if you want to store logs on the local machine. This will configure the database and could take a few minutes to complete. Once complete open a log and you will probably see prompts to download various updates, you should accept these. When you’re happy that everything looks ok, close CQRLOG.

With the old version installed and working, we can start the upgrade process. There are two parts to the process. The first is to install some prerequisite packages that are required to support the build. We then download the source code and build the latest version – all with just 6 lines of commands and here they are:

sudo apt install -y lcl*2.0 lazarus*2.0 fp*3.0.4 fpc*3.0.4 libssl-dev
cd ~
git clone https://github.com/ok2cqr/cqrlog.git
cd cqrlog
make
sudo make install

You can now start CQRLOG and you will find that you have the latest version.

Installing an old package from the repository can be a quick way to overcome build problems with other software. It doesn’y always work but can be worth a try.

Mike – G4WNC

]]>
https://photobyte.org/installing-upgrading-cqrlog-on-a-raspberry-pi/feed/ 16
Raspberry Pi – Transfer WSJT-X, JS8Call and FLDIGI settings to a new image https://photobyte.org/raspberry-pi-transfer-wsjt-x-js8call-and-fldigi-settings-to-a-new-image/ https://photobyte.org/raspberry-pi-transfer-wsjt-x-js8call-and-fldigi-settings-to-a-new-image/#comments Fri, 03 May 2019 09:48:34 +0000 https://photobyte.org/?p=2151 Several customers have asked me how they can move their settings and macros from one Pi image to another. This post attempts to simplify the process. To preserve your settings, you just need to copy a few files from the original Pi image to a USB stick and then move them back onto the new image once it is running.

The files to move are:

~/.fldigi/fldigi.prefs

~/.fldigi/macros/macros.mdf. NB: If you have created any personal macro files, they will be stored here and should also be copied.

~/.config/JS8Call.ini

~/.config//WSJT-X.ini

NB: ~ is a shortcut to the Pi home directory, /home/pi

You can use the Pi File Manager to do the move using simple drag and drop.

For those of you that are new to the Pi, here is a step-by-step description of the process:

  1. You need an empty USB memory stick. Any size will do as you’re only storing a few kB of data.
  2. Give the stick a name, i.e. Pidata. This is not essential, but it can make finding it on the Pi a bit easier.
  3. Boot the original Pi image, but don’t run any data modes programs.
  4. Insert the USB stick into the Pi USB socket
  5. You will see a popup on the Pi screen asking if you want to open File Manager; say yes to this.
  6. If you miss the File Manager prompt, you will find the USB stick mounted at: /media/pi/Pidata (or whatever name you gave the stick).
  7. Open a second instance of File Manager by clicking the File Manager icon on the top menu bar.
  8. Make sure the new instance is showing the contents of /home/pi
  9. Arrange the two File Manager instances so they are side-by-side with one showing /home/pi and the other is showing your USB stick.
  10. In the /home/pi File Manager instance, go to the View menu and select Show Hidden. This will reveal a set of hidden directories whose names begin with a period ( . ).
  11. Double-click on .fldigi to see the contents of this directory.
  12. Drag and drop the fldigi.prefs file to the USB stick.
  13. Open the macros directory in .fldigi. Drag and drop all files in this directory with a .mdf suffix.
  14. Click the Up-arrow icon by the address line to return to the /home/pi directory.
  15. Double-click on .config to see the contents of this directory
  16. Drag and drop JS8Call.ini and WSJT-X.ini to the USB stick.
  17. Close both File Managers, shutdown the Pi and remove the USB stick.
  18. Replace the Pi microSD card with the new image and power-up the Pi.
  19. Repeat steps 4 to 10 so that you have the two File Manager instances open.
  20. Navigate to ~/.fldigi and copy fldigi.prefs from the USB stick to that directory.
  21. Navigate to ~/.fldigi/macros and copy all the files with a .mdf suffix to that folder.
  22. Navigate to ~/.config and copy WSJT-X.ini and JS8Call.ini to that directory.
  23. Remove the USB stick, reboot the Pi and all your settings should have been transferred!
]]>
https://photobyte.org/raspberry-pi-transfer-wsjt-x-js8call-and-fldigi-settings-to-a-new-image/feed/ 2
Raspberry Pi – Multiple Instances of RTLSDR as a Service https://photobyte.org/raspberry-pi-multiple-instances-of-rtlsdr-as-a-service/ https://photobyte.org/raspberry-pi-multiple-instances-of-rtlsdr-as-a-service/#comments Wed, 06 Mar 2019 16:57:10 +0000 https://photobyte.org/?p=2069 My Raspberry Pi RTL Dongle server cards run the server as a service under systemd. This has several benefits including a better-defined start and the facility to stop/restart a service gracefully. One of my customer recently asked if it was possible to support 2 dongles and switch between them.

From previous tests, I know that a Pi3-B can support up to 4 RTL-SDR server instances, so switching between two should be easy. To add a second instance we just need to create a second Service file that’s a duplicate of the original with just one line changed. Here’s a copy of the original, single device, service file:

[Unit]
Description=RTL-SDR Server

Wants=network-online.target
After=network-online.target

[Service]

ExecStartPre=/bin/sleep 15
ExecStart=/bin/sh -c ‘/usr/local/bin/rtl_tcp -a $(hostname -I)’
WorkingDirectory=/home/pi
StandardOutput=inherit
StandardError=inherit
Restart=always

[Install]
WantedBy=multi-user.target

The line we need to change is the ExecStart as this line actually starts the server. To add another instance it should read:

ExecStart=/bin/sh -c ‘/usr/local/bin/rtl_tcp -a $(hostname -I) -d1 -p1235’

The -d suffix is the device number which counts from 0 and the -p1235 entry forces the second server instance to use port 1235.

Here’s a step-by-step guide to adding a second instance. NB: Back-up your SD card first!

  • Open a terminal session (Ctl-Atl-t)
  • Enter: cd /etc/systemd/system
  • sudo cp rtlsdr.service rtlsdr1.service
  • sudo nano rtlsdr1.service
  • Edit the ExecStart line to add: -d1 -p1235 as in above example
  • Press Ctl-x followed by y to save and close the file
  • Make sure you have two dongles connected to the Pi
  • Enter sudo systemctl start rtlsdr1
  • Enter sudo systemctl status rtlsdr1 This checks the status so you should see your dongle reported
  • If all is well enter: sudo systemctl enable rtlsdr1 This will make the second instance automatically run at boot.

That’s it! If you want to stop either service from starting at boot use: sudo systemctl disable rtlsdr or rtlsdr1

To start or stop a service it’s sudo systemctl stop rtlsdr or rtlsdr1 to start it’s sudo systemctl start rtlsdr or rtlsdr1

Good Luck,

Mike – G4WNC

]]>
https://photobyte.org/raspberry-pi-multiple-instances-of-rtlsdr-as-a-service/feed/ 5
Raspberry Pi Buster – GPS Dongle as a time source with Chrony & Timedatectl https://photobyte.org/raspberry-pi-stretch-gps-dongle-as-a-time-source-with-chrony-timedatectl/ https://photobyte.org/raspberry-pi-stretch-gps-dongle-as-a-time-source-with-chrony-timedatectl/#comments Sat, 21 Apr 2018 23:53:22 +0000 https://photobyte.org/?p=1746 UPDATE 17-12-21: Sean (see comments below) has noted that, when using these instructions with the latest OS, the operation fails unless you comment-out  (prefix line with #) START_DAEMON=”true” in the gpsd config file. I will run some checks here and develop modified instructions.

The latest release of Raspberry PiOS for the Pi has replaced the familiar NTP application with a lightweight solution using timedatectl. As a result, many of the online tutorials for adding  a GPS USB dongle are out of date.

After some experimenting, I have devised the following process:

For my tests, I was using the Diymall VK-172 GPS dongle that’s available from Amazon UK for £12.95. This is a ublox 7020 based dongle.

Start with a fresh download of Buster and do the usual sudo update/upgrade to get the latest patches.

1 — Install the following software:

sudo apt -y install gpsd gpsd-clients python-gps chrony python-gi-cairo

2 — Next step is to make some changes to the gpsd configuration file as follows:

sudo nano /etc/default/gpsd

3 — In the file that opens, add or amend lines to make sure the following is present:

#START_DAEMON=”true”

USBAUTO=”true”

DEVICES=”/dev/ttyACM0″

GPSD_OPTIONS=”-n”

Hit ctl-x followed by y to close and save the file.

4 — Reboot the Pi and check that the following services are active:

systemctl is-active gpsd

systemctl is-active chronyd

5 — You can use any of the following three commands to check that the GPS is visible and delivering NMEA words. NB: Most GPS dongles will show a flashing LED when they have a fix:

cgps – s   or   gpsmon -n  or   xgps

6 — Next, we need to make a change to the chrony configuration file:

sudo nano /etc/chrony/chrony.conf

Add the following line to the end of the file:

refclock SHM 0 offset 0.5 delay 0.2 refid NMEA

Hit ctl-x followed by y to close and save the file.

7 — You can now check chrony’s sources with the command:

chronyc sources -v

If you are connected to the network, you will see a list of available time servers plus the GPS source which will be shown as NMEA. If you’re not network connected, you will just see the NMEA source listed. The two punctuation characters immediately before NMEA, indicate its status and you need to see #* where # means thge GPS is recognised as a local clock and * means that it’s being used to synchronise the Pi system time.

8 — You can now use chronyc to provide a more detailed view using the command:

sudo chronyc tracking.

This will confirm that NMEA is being used as the reference and will list the time difference between the reference and the system clock. To avoid clock jitter that can cause lots of software problems, chrony slowly changes the system clock until it matches the reference. However, this makes for a very slow synchronisation.

9 — If you want to quickly synchronise the time, use the following command to make a step change to the system clock:

sudo chronyc makestep

Operational Notes

If you boot the Pi with a network connection, chrony will automatically sync to the time server with the shortest propagation delay. If you remove the network connection after boot, it will take a while for chrony to switch back from the network server to the local GPS. This is because Chrony makes repeated attempts to reach what it considers to be the best timeserver. The simplest way to overcome this delay is to reboot the Pi without a network connection. It will immediately revert to using the NMEA (GPS) data as it’s the only timing source available.

NB: Pi Pixel Clock Update Delay – Please note that the PIXEL desktop clock (top right corner) only synchronises with the system time every 5 minutes. As a result, updates to the system time can take up to 5 minutes to permeate to the desktop clock! The most reliable way to check the system time is to use: sudo timedatectl. This shows all the vital timing detail and synchronisation with GPS USB dongle is indicated when the ‘NTP Synchronized’ entry reports yes.

Here are some useful time-related commands:

sudo date -s “Aug 7 09:15” – Manually sets the system time and is useful when testing RTC and GPS units.
sudo hwclock -w – This command updates the RTC with the current system time. Use this when you are connected to a network and want to force the RTC to sync with network/system time.
sudo hwclock -r – This displays the current RTC time and is useful for checking the RTC.
sudo hwclock – s -Sets the system time from the RTC
sudo hwclock –set –date ”8/11/18 15:24:00” Manually sets the RTC time and date – useful for testing.
sudo timedatectl – Displays the status of all the Pi clock sources.
sudo chronyc makestep – Forces the system time to make a step change to the reference time, i.e. GPS. This avoids the time lag caused by chrony incrementally adjusting the clock.

Mike Richards – G4WNC

]]>
https://photobyte.org/raspberry-pi-stretch-gps-dongle-as-a-time-source-with-chrony-timedatectl/feed/ 50
PiFace on the Raspberry Pi – Problem Solved! https://photobyte.org/piface-on-the-raspberry-pi-problem-solved/ https://photobyte.org/piface-on-the-raspberry-pi-problem-solved/#comments Sun, 01 Apr 2018 23:17:31 +0000 https://photobyte.org/?p=1720 UPDATE – 19-8-2022

The board producers have updated their code, and the instructions on their Github site now work perfectly. Here’s the link: PiFace installation: PiFace github
You can also use this excellent board on the Pi 4B, but you will need to file away a notch on the PiFace PCB so it clears the larger Ethernet port on the Pi 4. There are no PCB tracks in the area that needs to be removed, so it’s quite safe. The notch has to extend the full width of the word element 14 on the PCB and be deep enough to touch the top of the lowercase letters in that word.

Introduction

I recently wasted many hours trying to get the PiFace board to work with Python. I eventually discovered the root cause of the problem, so have documented it here, both for my own reference, and for anyone else who might be pulling their hair out!!

About PiFace

The PiFace Digital-2  expansion board for the Raspberry Pi is a very well built add-on that features 2 decent capacity relays, 8 inputs and 8 outputs, all of which are accessed via screw terminals around the edge of the board. The PiFace boards have been around for a long time and are (supposed to be) easy to use.

The Problem:

A recent change in the Raspbian distribution set the default SPI (Serial Peripheral Interface) speed to a value (125MHz) that the PiFace board doesn’t support. Unfortunately, the Python initialisation code for PiFace didn’t include a command to initialise the SPI speed. The net result is that the PiFace board won’t initialise under Python and you will see an error along the lines … ‘PiFace board cannot be found’. Just to make matters worse, the PiFace Common library was updated to fix the SPI speed problem, but there is an issue with the ‘corrected’ version held in the repositories. This claims to be version 4.2.1 which is the correct version number for the SPI speed fix. However, a look at the spi.py file (/urs/local/lib/python2.7/dist-packages/pifacecommon) reveals that the line (speed_hz=ctypes.c_uint32(100000)) is still missing from the SPI transfer struct! I’m sure this will get fixed in due course, but for now, I suggest you use the following solution.

The Solution

The simple answer is to download and install the correct version of pifacecommon direct from the Piface GitHub site. Here’s how:

Start a terminal session in the pi directory (cd ~) and enter the following commands:

git clone https://github.com/piface/pifacecommon.git

cd pifacecommon

python setup.py build

sudo python setup.py install

That’s it!

Accessing PiFace with Python

To complete installation of the Python libraries you need to install the pifacedigitalio library as follows:

sudo pip install pifacedigitalio

With the library installation complete, access is easy. Here’s a basic example taken from the GitHub readme.

import pifacedigitalio as p # import the library and give it the alias or nickname p

p.init()  # initialise the Piface board

p.digital_write(0,1) # make pin 0 high, NB: o/p pins number 0-7

p.digital_read(7) # read input pin 7, NB: i/p pins number 0-7

Happy programming,

Mike – G4WNC

]]>
https://photobyte.org/piface-on-the-raspberry-pi-problem-solved/feed/ 19
RTL-SDR Server as a service on Raspberry Pi https://photobyte.org/rtl-sdr-server-as-a-service-on-raspberry-pi/ https://photobyte.org/rtl-sdr-server-as-a-service-on-raspberry-pi/#comments Wed, 21 Mar 2018 00:31:51 +0000 https://photobyte.org/?p=1696 Updated 25th Aug 2021 Clarified RTL-SDR build requirements

NB: This post assumes that you have already built the RTL-SDR server from source using the following instructions. 

Install RTL-SDR server 

These instructions will not work if you install RTL-SDR via the repository, i.e. sudo apt install…

Now that Raspbian has changed to Systemd for managing auto-starting programs and daemons, I thought it was about time I moved away from using rc.local to start the rtl-sdr server.

If you ‘re currently using the rc.local file to start the server, begin by removing the server commands from that file.

The next job is to create a unit file to provide Systemd with the essential information for the management of the service. To create the unit file, use nano as follows.

Enter: sudo nano /etc/systemd/system/rtlsdr.service

Once nano opens, populate it with the following lines:

[Unit]
Description=RTL-SDR Server

Wants=network-online.target
After=network-online.target

[Service]

ExecStartPre=/bin/sleep 15
ExecStart=/bin/sh -c ‘/usr/local/bin/rtl_tcp -a $(hostname -I)’
WorkingDirectory=/home/pi
StandardOutput=inherit
StandardError=inherit
Restart=always

[Install]
WantedBy=multi-user.target

When you’ve entered the lines above, press ctl x then y and Enter to save the file.

To test the service, make sure the RTL dongle and network are connected and enter: sudo systemctl start rtlsdr.service. If that proceeds without error, you can check the status of the service with sudo systemctl status rtlsdr.service. If all is well, you should see a message showing that the RTL-SDR dongle has been found. You can stop the service with sudo systemctl stop rtlsdr.service. If you’re happy that all is working ok, you can enable the service so it automatically starts at boot time. Enter the following: sudo systemctl enable rtlsdr. To disable the auto-start service it’s sudo systemctl disable rtlsdr.service

Time Saving Tip: When entering systemctl commands, you can omit the .service suffix.

You can find out more about Systemd at: https://fedoramagazine.org/what-is-an-init-system/

ExecStart Explanation

ExecStartPre=/bin/sleep 15

This line adds a 15 second delay between completion of the network setup and starting the Spy Server. This is included as a precaution to allow time for a slow router to allocate an IP address for the Pi. If the start-up delay is a problem for you try reducing the sleep time or eliminating this line completely.

ExecStart=/bin/sh -c ‘/usr/local/bin/rtl_tcp -a $(hostname -I)’

This line starts the server but warrants some explanation. One of the problems with starting the rtl-sdr server as a service is the lack of a system variable to provide the Pi IP address. We need this because we have to pass the IP address to the server when it’s started. In this solution, I’ve called sh first and used the -c option. This tells sh to get the command line instruction from the quoted string that follows. That way we can use our standard call to rtl_tcp and combine it with the command line $(hostname -I) instruction to retrieve the IP address.

Mike – G4WNC

]]>
https://photobyte.org/rtl-sdr-server-as-a-service-on-raspberry-pi/feed/ 11
Raspberry Pi – Fixing a slow mouse https://photobyte.org/raspberry-pi-fixing-a-slow-mouse/ https://photobyte.org/raspberry-pi-fixing-a-slow-mouse/#comments Thu, 15 Feb 2018 15:28:09 +0000 https://photobyte.org/?p=1601 I recently changed my keyboard/mouse combo to a Perixx Periduo-712. When I restarted the Pi, I found that my mouse pointer had become very slow. A quick look around the Internet revealed a fix as follows:

To speed-up the mouse, you need to amend a line in the cmdline.txt file in the boot directory. Here’s how to do that:

  1. Open a terminal session and enter: sudo nano /boot/cmdline.txt
  2. That will open the file in the Nano text editor.
  3. You will see that the file has a single long line and we need to add our changes to the end of that line.
  4. At the end of that line, enter a space followed by: usbhid.mousepoll=0
  5. Next press Ctl-x followed by y to close and save the amended file.
  6. Enter: sudo reboot from the terminal session to restart the Pi and your mouse should be fine!
]]>
https://photobyte.org/raspberry-pi-fixing-a-slow-mouse/feed/ 6