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 Use Raspberry Pi Imager to burn zip file images https://photobyte.org/use-raspberry-pi-imager-to-burn-zip-file-images/ https://photobyte.org/use-raspberry-pi-imager-to-burn-zip-file-images/#respond Sat, 20 Aug 2022 13:18:11 +0000 https://photobyte.org/?p=10524 The excellent Raspberry Pi Imager software is ideal for burning zipped operating system images to a SD card or hard drive. There’s no need to unzip the file as Imager does it for you.
Here’s the step-by-step process:

  1. Download the free Imager from here: Raspberry Pi Imager software:
  2. Double-click the downloaded file to install the Imager.
  3. Run the Imager
  4. Insert your blank SD card (16GB or more) into a card reader on your Windows computer
  5. Click the Operating System box (left-hand) of Imager and scroll down to Use Custom
  6. Navigate to the zip file that you want to burn
  7. Move to the Storage box in Imager and choose your blank SD card. Be careful here to choose the correct drive
  8. Click the Write box and follow the prompts
  9. When the copy has been verified you will see a message to that effect
  10. Move your new card to the Pi, which may boot a couple of times before being ready for use.
]]>
https://photobyte.org/use-raspberry-pi-imager-to-burn-zip-file-images/feed/ 0
Raspberry Pi Unreliable WiFi & Power Saving https://photobyte.org/raspberry-pi-unreliable-wifi-power-saving/ https://photobyte.org/raspberry-pi-unreliable-wifi-power-saving/#respond Sat, 21 May 2022 16:44:47 +0000 https://photobyte.org/?p=10481 When using the Raspberry Pi over marginal Wi-Fi links I have experienced problems with the Pi dropping the network entirely. When that happens the only fix is a reboot. After much searching, it would appear that the Wi-Fi power save feature may be contributing to the problem. The Wi-Fi power save is enabled by default but can be temporarily disabled by entering:

iw wlan0 set power_save off

To make the change permanent, open a terminal session and use the following commands to edit the rc.local file.

sudo nano /etc/rc.local

In a blank line above exit 0, enter the following:

/sbin/iw dev wlan0 set power_save off

Next press Ctl+X followed by Enter to exit and save the file
That completes the changes and you can reboot the Pi. To check that the wlan power save is disabled use the following command:

iw wlan0 get power_save

]]>
https://photobyte.org/raspberry-pi-unreliable-wifi-power-saving/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
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