Tuesday, October 17, 2023

Raspberry Pi Collection

cat /sys/firmware/devicetree/base/model
  1. Raspberry Pi Model B Rev 2 (June 2013)
  2. Raspberry Pi 2 Model B Rev 1.1 (Apr 2016)
  3. Raspberry Pi 3 Model B Rev 1.2 (Feb 2018)
  4. Raspberry Pi Model A Plus Rev 1.1 (Aug 2015)
  5. Raspberry Pi Zero Rev 1.2 (Jan 2016)
  6. Raspberry Pi Zero W Rev 1.1 (Jul 2020)
  7. Raspberry Pi Zero W Rev 1.1 (Mar 2021)
  8. Raspberry Pi Zero 2 W Rev 1.0 (Oct 2024)

https://en.wikipedia.org/wiki/Raspberry_Pi

https://www.raspberrypi.com/products/

Saturday, December 24, 2022

Downloading iPhone Photos...

There appear to be three main ways:

Adobe Photoshop

  • Can be downloaded into sub-folders by date, but these are incorrect
  • Live photos are downloaded as a jpeg and 2 second .mov file with the same root name (e.g. IMG_6920.JPG/ IMG_6920.MOV)
  • Edited photos are downloaded as the original (e.g. IMG_8372.JPG), and an edited version (e.g. IMG_E8372.JPG)
  • Instagram photos are downloaded with a 8 char UID, e.g. CHSP3732.JPG

Download from iCloud

  • Downloaded as a zip file extracting to a single folder
  • Live photos are downloaded as a jpeg and 2 second .mov file with the same root name
  • Edited Photos are downloaded as the edited version only, with a .JPEG extension (rather than the usual .JPG)
  • Instagram photos are downloaded with a UUID name (e.g. 5815967B-18C8-4CB8-8550-B7C2147F7187.jpg)

Copy from DCIM directory

  • Stored in directories according to month, e.g. 202110_
  • Live photos are downloaded as a jpeg and 2 second .mov file with the same root name
  • Edited photos are downloaded as the original (e.g. IMG_8372.JPG), an edited version (e.g. IMG_E8372.JPG), and the AAE metadata (e.g. IMG_8372.AAE)
  • Instagram photos are downloaded with a 8 char UID, e.g. CHSP3732.JPG

In short, using Photoshop is probably the best way to download images from an iPhone, although they must be on the device, not stored on iCloud with smaller versions downloaded kept on the phone...

Sunday, November 06, 2022

Raspberry Pi Gadget Mode

 As the USB to UART doesn't appear to work with Windows 11, an alternative is to connect the RPi direct to the laptop. A tutorial on how to do this can be found here.

Sunday, September 11, 2022

Installing Android apps on a Kindle

There are instructions on how to install Google Play on oa Kndle at howtogeek.com.

However, it is also possible to simply download the APK file from apkmirror.com.

It is easiest to copy the .apk file to a micro SD card to transfer it to the kindle. The app is installed through simply selecting it in the Files app on the kindle.

Saturday, January 01, 2022

Git Remote Repositories

To manage remote repositories in Git:

# to view current remotes
git remote -v

# to update the URL
git remote set-url 

Saturday, December 18, 2021

SSH Lag on RPi...

On a new install, there was a strange lag in SSH, where it would repeatedly freeze...

The solution appears to be to update /etc/ssh/sshd_config to set:

   ClientAliveInterval 60
   ClientAliveCountMax 10

and or in /etc/ssh/ssh_config:
   ServerAliveInterval 60
   ServerAliveCountMax 10

The server is the host that receives the connection...

These are taken from here...

Sunday, March 21, 2021

Pi4j Releases

Note that Pi4j v1.4 relies on Java 11, whcih will cause issues with older models of Raspberry Pis.

Therefore, mosly best to stick to v1.3, and disable the repo in /etc/apt/sources.list.d/pi4j.list

Pi4j v2.0 is next..

Saturday, March 20, 2021

VS Code and Raspberry Pi Zero WH

VS Code Remote Development is fantastic, but it doesn't support the Raspberry Pi Zero as the armv6l isn't supported.

However, this it is possible to mount /home/pi as a Samba share and amend files locally, which will perform similarly (for Python development anyway).

This is described here. Install Samba with:

sudo apt install -y samba

Then add the following to /etc/samba/smb.conf as follows:

[PiShare]
 comment=Pi Share
 path=/home/pi
 browseable=yes
 writeable=yes
 only guest=no
 create mask=0740
 directory mask=0750
 public=no

Note that the Samba configuration file can be checked with the testparm command.

Finally, set a password with sudo smbpasswd -a pi. This will create the Samba user pi.

This can be accessed from another computer on the network as \\hostname\share

Friday, February 05, 2021

Raspberry Pi Package Management

APT (Advanced Packaging Tool) is a set of tools that was developed for Debian Linux platform as an easy command line interface for the dpkg utility

apt update
apt upgrade
apt install python3
apt install ./pi4j-1.3.deb # install local package
apt show python3
apt remove python3
apt list # lists all available packages
apt list --installed # lists installed packages
apt list python3 # also shows if package is installed
apt search python3

# list all files contained in the package
dpkg -L python3

# find which package contains a file
dpkg -S /usr/bin/python3

Sunday, January 31, 2021

Configuring a Headless RPi

  • Install the OS Using the Raspberry Pi Imager.
  • Mount the SD card again in the Windows environment
  • To enable SSH, create an empty file named 'ssh' in the root of the SD card
  • To configure WiFi, create the wpa_supplicant.conf file in the root of the SD card
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=GB
    
    network={
            ssid="ssid"
            psk="psk"
    }
    
  • Boot the RPi with the card and run raspi-config to set hostname, interfaces etc.
  • Install Java with:
    sudo apt install default-jdk
      
    # or for older RPi mmodels
    sudo apt install openjdk-8-jdk liblog4j2-java wiringpi libmysql-java
    

Edit: turns out these can now be set up with the Raspberry Pi Imager v1.6, which is a lot easier...

Saturday, December 26, 2020

Raspberry Pi USB to UART


Instructions on using it can be found here...

Putty is set up as a Serial Connection Type, with the speed set to 115200. The Serial Line can be identified from Device Manager in the ports tab, a the Prolific USB-To-Serial Comm Port.

Note that this doesn't appear to work with Windows 11...

Thursday, December 24, 2020

SQL Joins (MySQL)

Rows from two tables can be combined using joins.

Inner Joins

Inner joins return only the rows that meet the specified condition in both tables.

# keyword INNER is optional
SELECT * FROM toys
INNER JOIN bricks
ON toy_id = brick_id;

# Oracle syntax
SELECT * FROM toys, bricks WHERE toy_id = brick_id;

Outer Joins

Outer joins return all the rows from one table, along with the matching rows from the other. Rows without a matching entry in the outer table return null for the outer table's columns.

An outer join can either be left or right, which determines which side of the join the table returns all rows for.

# keyword OUTER is optional
SELECT * FROM toys
LEFT OUTER JOIN bricks
ON toy_id = brick_id;

SELECT * from toys
RIGHT JOIN bricks
ON toy_id = brick_id;

Full Joins

A full join includes unmatched rows from both tables. This is not supported directly by MariaDB.

SELECT * FROM toys
FULL JOIN bricks
ON toy_id = brick_id;

Cross Joins

A cross join returns every row from the first table matched to every row in the second. This will always return the Cartesian product of the two table's rows: i.e. the number of rows in the first table times the number in the second.

SELECT * FROM toys
CROSS JOIN bricks;

See also here

Wednesday, November 18, 2020

RPi Auto Reconnect

This should reconnect a Raspberry Pi if it drops from the network due to router issues...

*/5 * * * * /bin/ping -q -c10 192.168.1.254 > /dev/null 2>&1 || (sudo /sbin/ifconfig wlan0 down ;sleep 5 ;sudo /sbin/ifconfig wlan0 up ;/usr/bin/logger wifi on wlan0 restarted via crontab)

Monday, September 07, 2020

Photo Sizes


Canon EOS 40D and EOS 77D are both 4x6...

Saturday, August 08, 2020

New Raspberry Pi Set up

First, connect to the pi using the USB to UART cable, following the instructions at Adafruit, and enabling the connection in /boot/config.txt

Then set up wifi following the instructions at raspberrypi.org.

Then change the default password using:

sudo passwd pi

Then enable SSH, and update the hostname using:

sudo raspi-config
# Select Interfacing Options and enable SSH
# Select Network Options and change hostname 

Finally, update the software with:

sudo apt update
sudo apt upgrade

Saturday, May 30, 2020

Windows Terminal

Command Prompt isn't great, so Windows Terminal is welcome.

However, as with VSCode, it feels a little clunky to use and setup, primarily due to the use of a JSON file to hold the settings.This file is (unhelpfully) found at

%USERPROFILE%\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState

Settings are documented at Terminal Documentation, but the key settings are documented here:


{
    ...
 
    "initialCols": 100,
    "initialRows": 64,
    "initialPosition": "80,10",

    "profiles":
    {
        "defaults":
        {
           "fontSize": 9,
           // or consolas...
           "fontFace": "Cascadia Code",
           "useAcrylic" : true,
           "acrylicOpacity" : 0.85,
           "closeOnExit": true
        },
        "list":
        [
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false,
                "colorScheme": "One Half Dark"
            },
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl",
                "hidden": false,
                "colorScheme": "Solarized Dark",
                "startingDirectory":"//wsl$/Ubuntu/home/paul/"

            },
            {
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "Command Prompt",
                "commandline": "cmd.exe",
                "hidden": false,
                "fontFace": "consolas",
                "fontSize": "16"
            }
        ]
    }
}

Useful keys are:

  • ctrl+shift+f Search
  • alt+shift++ Create vertical pane
  • alt+shift+- Create horizontal pane
  • alt+arrow Navigate between panes
  • alt+shift+arrow Resize focused pane
  • ctrl+shift+w Close pane

Sunday, March 29, 2020

Stop Motion Animation

There is a great App for Chrome called Stop Motion Animation that is a very simple and straightforward way of creating stop motion videos.

It is straightforward and easy to use, and the kids love it.

However, it does produce files in webm format. These can be played in VLC Media Player but they can't be run in Windows Media Player.

However, they can be converted to mp4 using ffmpeg, which can be installed on either a Raspberry Pi or WSL.

# install if necessary...
sudo apt-get install ffmpeg

# then run
ffmpeg -fflags +genpts -i filename.webm -r 96 filename.mp4

Note sure about the correct frame rate, but this appears to work in this instance...

This article is probably also worth a read (though I haven't yet)...

Wednesday, November 27, 2019

Raspberry Pi NTP Time...

Some versions of the Raspberry Pi/ Raspbian have NTP disabled

# to check status
timedatectl status

# to enable NTP...
sudo timedatectl set-ntp True

Saturday, November 02, 2019

Formatting Code on Blogs...

Finally found at how to do this using prism.js from the excellent blog post here.

This is done by adding a link to the CSS in <head>, and a link to the JS before closing the <body> tag. The theme is specified with the css name, e.g. prism.min.css or prism-tomrrow.min.css. For Blogger, this has to be done by updating the Blog Theme.

<head>
  ...
  <link
    href='https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-tomorrow.min.css' 
    rel='stylesheet'/>
</head>
<body>
  ...
  <script
    src='https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.js'/>
  <script
    src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autoloader/prism-autoloader.min.js"/>
</body>

There is a full list of the CDN files here, and a full list of supported languages here.

Code is enclosed within the <pre> tag to preserve formatting; and within the <code> tags, also specifying the language for highlighting:

<pre><code class="language-java">   class App {
      public static void main(String[] args) {
         System.out.println("Hello World!");
      }
   }
</code></pre>

Formatting can also be done inline.

Note that to display HTML or PHP some of the symbols will need to be escaped so the browser doesn't try to parse the code. An online converter like Free Online HTML Escape Tool can do this.

Wednesday, October 09, 2019

Installing MicroPython on the ESP8266

Check the port it is attached to in Device Manager. Download the firmware from the MicroPython downloads page.
Open a Command Prompt and do the following:
pip install esptool

# erase the flash

esptool.py --chip esp8266 erase_flash

# For the HUZZAH ESP8266 breakout buttons for GPIO0 and RESET are built in to the board
# Hold GPIO0 down, then press and release RESET (while still holding GPIO0),
# and finally release GPIO0

# install the firmware
esptool.py --chip esp8266 --port COM3 write_flash --flash_mode dio \
   --flash_size detect 0x0 esp8266-20190529-v1.11.bin
Full info on the Adafruit HUZZAH ESP8266 breakout on the Adafruit website.
Full info on MicroPython here.
Connection to the REPL over the serial prompt is at baudrate 115200 using Putty.
Note that the USB to UART serial console cable is connected as follows:
  • n/a
  • White - Tx
  • Green - Rx
  • Red - V+
  • n/a
  • Black - GND