Introduction: A Raspberry Pi PC-PSU Desktop Computer With Hard Disk, Fan, PSU and On-Off Switch
January 2024: A Pimoroni NVME-base was added to the Pi5 with the OLED display. It was an easy install and the only change was to use 4 plastic standoffs with a 2mm shorter length - i.e. the same as the thickness of the Pimorononi base. A Samsung 980 500GB was installed on the nvme-base. Diagnostics are provided at the github page here and here - the Samsung 980 on the NVME-base runs at a very cool 10 degrees above room temperature, and about 10 degrees below the Pi5.
December 2023: A Raspberry Pi 5 8GB was installed in the case with the fan on top, but replacing the 5v 3A Buck Regulator with a 5v 5A regulator which is connected directly to the 40-pin GPIO connector through a socket which connects to two +5v pins and two of the earth pins on the Pi 5. For the maximum USB current output add the line usb_max_current_enable=1 to the config.txt file. The fan speed was also increased to from 700 rpm to about 1100 rpm which then makes a soft "whooosh" sound. The half-size WM8960 Sound hat was replaced with a full-sized IQAudio DacPlus Audio Hat. The Pi 5 temperature during normal use is about 40 to 45 degrees Celsius when the room temperature is 25 degrees Celsius. The 5v supply voltage can be displayed on the OLED display by using the new Pi 5 specific vcgencmd pmic_read_adc EXT5V_V command by changing the python script (refer to the github link below), used to display the temperature. The new python script is included below as oled-volt.py. Details of the touch-macropad can be found in the Pico section of the github as listed below:
To enable the WM8960 Waveshare hat with a Raspberry Pi 5:
Refer to the solved issue here: https://github.com/waveshare/WM8960-Audio-HAT/issues/51
And use the script here to install: https://github.com/ubopod/ubo-sdk/blob/main/system/setup/install_wm8960.sh
September 2020: A second Raspberry Pi housed inside a re-purposed PC power supply case, had been built. This uses a fan on top - and the arrangement of the components inside the PC-PSU case is therefore different. A modified (for 64x48 pixels), Adafruit SSD1306 driver or Luma Oled for Python will be used to display the song or video information on a small OLED display mounted in the front of the case. More details at this Github.
The i2s audio hat is the Wolfson WM8960 as discussed in two of my Github repositories. The SSD1306 display uses i2c for communication and therefore a four-wire ribbon cable is sufficient to connect it to the Raspberry Pi GPIO connector (Pins SCL, SDA, 3V3 and GND).
A modified python driver for SSD1306 in its 64x48 pixel version is used after adapting an Adafruit library based on comments from Mike Causer and Luma Oled driver comments.
Todo: A persistent second line of the display will be used to show the Raspberry Pi 5 volt supply voltage using either an ATtiny85 as ADC - communicating via i2c with the Raspberry Pi, or an MCP3002 dual channel 10-bit SPI ADC. The Raspberry Pi CPU temperature and the case fan RPM will be shown permanently on the third line of the display. Both these lines will be on for 1 second out of 5 to prevent OLED burn-in.
Previously 2018 and 2019: I grew tired of connecting all the peripherals to my Raspberry Pi 3 or 4 every time I wanted to use it. I decided I wanted a Raspberry Pi computer permanently connected to a power supply, hard disk or SSD for the root file system and data, a large fan that can rotate slowly and quietly, and a monitor and speakers.
In addition it is not a good idea to run a Pi for an extended period from an SD Card - these have a limited write cycle (about 10,000 times?) and I therefore decided to investigate two other ways to boot the Pi.
The photos show the completed Pi case connected to a small monitor, stereo speakers, and a wireless combo-keyboard trackpad, and Hayley Westenra singing Scarborough Fair using the Rasbian and omxplayer's video hardware acceleration.
More recently I acquired a Raspberry Pi 4 4GB and replaced the Raspberry Pi 3 with it in the same enclosure. For more details please see Section 6.
Attachments
Step 1: Parts List
Raspberry Pi 3
AC-DC PSU 12v 3A module
DC-DC PSU module Input 5 to 35v Output 5v 3A
DC-DC PSU module Input 5 to 35v Output 1A and voltage variable (set to about 7v for a fan speed of 900 rpm)
One AC 250v pushbutton latching switch
Three USB female sockets
Three USB male plugs
One USB Mini Male Plug
3 Digit Voltmeter Blue
Old PSU case
Hard Disk Drive of suitable size (2.5")
Circuit board from external 2.5" HDD
12 volt computer Fan
Connection wire etc.
Step 2: Construction and Connections
An old computer PSU case seemed to be a convenient size to house the Pi, its power supply, and a stripped external USB hard disk. There was not enough space in the PSU case to mount the external hdd with its case - I therefore opened it and only kept the small circuit board attached to the hdd. I also added a power switch plus USB sockets on the front and back, and it had space for a large fan to keep everything cool, and I made provision for a DAC hat to be fitted should I acquire one. I used a 12v 3A AC-DC power supply as the main PSU, and added two smaller adjustable 5v and 7v for the fan, DC-DC PSU's.
Photo 1 shows all the components when partially assembled in the PSU case. I made four short USB cables to connect the four Raspberry Pi USB ports to the hard disk, and the front and back panel usb connectors.
Photos 2 and 4 show the completed Pi case connected to a small monitor, stereo speakers, and a wireless combo keyboard track pad.
Photos 5 to 10 show the completed case from various angles.
If you look at Photo 10 carefully you can see that I have connected two wires (brown and white) directly to the raspberry Pi GPIO pins. In this case the Pi 3 is powered directly via its GPIO pins 2 or 4 are +5v, pin 6 (and others) for ground - but note that you must triple-check that you are supplying no more than about 5.2 volt to those pins as by doing this you're bypassing the poly-fuse protection. I used Pins 2 for +5v and the pin next to it for Ground. As I am supplying the Pi through two regulated power supplies - first 12v and then 5.1v, I was satisfied with the direct supply connection.
I was worried that the metal case would block the Raspberry Pi 3's ability to connect to my Wi-Fi router - in the end I made two 2 cm holes on the side panel next to the Pi board with the result that the number of bars on the Wi-Fi indicator on Raspbian stayed the same whether the case was closed or open.
Connection Details:
Connect the AC power to the 12v 3A AC-DC Module through the Power switch . Connect the 12v output of this module to the DC-DC 5v 3A module which will power the Raspberry Pi (if adjustable first set to about 5.1 volt - measure it) and to the smaller DC-DC adjustable module which will power the fan. Connect the 5v output of the 5v DC-DC module to the Rapsberry Pi GPIO Pins 4 (+5v) and Pin 6 (Ground). Connect the ouput of the smaller DC-DC module to the 12v fan and adjust its output so that the fan turns silently. Connect the ground of the 5v 3A DC-DC module to the PC PSU case. Connect the ground and 5v of the 5v DC-DC module to the 3 digit voltmeter display on the front panel.
Connect two of the Raspberry PI USB ports to the back USB sockets using the two male USB plugs, 4 core wiring and the two USB Female sockets mounted on the rear. Connect one of the Raspberry PI USB ports to the front USB socket using a male USB plug, 4 core wiring and the one USB Female socket mounted on the front.
Connect the hard disk to one of the Raspberry PI USB ports via a male USB plus and another mini USB male plug.
Step 3: Hard Drive Boot Setup
It is not a good idea to run a Pi for an extended period from an SD Card - these have a limited write cycle (about 10,000 times?) and I therefore decided to Investigate two other ways to boot the Pi:
(1) Putting the boot and root plus user partition on a hard-disk
(2) Leaving the small 50 MB Dos boot partition on the SD card (it a read-only during boot), and moving the root file system and user data to a hard disk.
It was very easy to get the Pi to boot from the hard disk - I copied the newest Raspian Stretch to an SD card using the Win32DiskImager utility. I also used it a second time to copy the same image to a 1 GB Toshiba 2.5" notebook drive, then I set the Pi's boot fuse as described in the link given at the end (you add the line program_usb_boot_mode=1 to /boot/config.txt, and the reboot the Pi), removed the SD card, and the Pi then booted from the hard disk and proceeded to resize its partitions.
To enable USB boot mode do the following:
echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt
This adds program_usb_boot_mode=1 to the end of /boot/config.txt. Reboot the Raspberry Pi. Check that the OTP has been programmed with:
vcgencmd otp_dump | grep 17:
Ensure the output 17:0x3020000a is shown which means that the OTP fuse has been successfully programmed.
You can also add the program_usb_boot_mode line from config.txt the nano editor using the command sudo nano /boot/config.txt.
However there was a problem during switch-off doing it this way, because I had to supply extra power to the hard disk via a second USB connector, the disk kept on running after the Pi switched off and I therefore had to switch off the hard disk by switching off via the power switch on the front panel. What I wanted is for the Pi to "park" the hard disk during switch-off. If I removed the extra power supply connection the Pi refused to boot from the hard disk.
There are two text configuration files (config.txt and cmdline.txt), in the boot folder on the Dos boot partition that one can edit in an attempt to supply either extra power to the hard disk during boot, or to wait longer for the disk to start spinning.
Add: rootdelay=5, and program_usb_timeout=1 and max_usb_current=1 to the long list in the /boot/config.txt file. (The rootdelay option may be deprecated).
Add: boot_delay=32 and again rootdelay=5 to the line in /boot/cmdline.txt should make the kernel wait for the root device before continuing the boot sequence. (Adding rootwait instead of rootdelay will mean it will wait indefinitely.)
After trying all the various combinations of SD card and hard disk partitions I settled on keeping the small dos boot partition on the SD Card and moving the root and user files to the hard disk. The procedure to do this is fairly long and is as described in the link at the end.
Photo 11 is a screendump of the result of df -h on my Pi, and shows that /dev/sda1 is the root file system, /dev/sda2 has my user data, and the boot partition remained on the SD Card.
I suggest that you instead first try to boot everything from the hard disk as this only involves making two images - one on the SD Card, one on the hard disk, and then setting the Pi's boot option fuse. Note that the Pi will still be able to boot from an SD card if the fuse has been set - the only difference is that it now first tries to boot from the USB disk drive. If you cannot boot at first from the hdd then boot from the SD card and attach and mount the hdd, then edit the two configuration files as described previously on the hdd boot partition and try to boot again.
Step 4: Source
Step 5: Keep the Dos Boot Partition on the SD Card and Move the Root and User Files to a Hard Disk
With the new June Rasbian Stretch setup at the first start routine it causes a root drive locked message after the rootfs has been copied to the hdd /dev/sda1
To prevent this do the following:
1. Make sd card with Stretch June 29 2018 image and boot Pi - say CANCEL when new setup procedure shows. Can now customize desktop and splashpage, and add wifi connection, add temperture meter, textfile editor to taskbar etc. Do not attach the hdd drive as yet.
2. Change config.txt sudo nano /boot/config.txt (Press Ctr-O to save and Ctr-X to exit) by adding at bottom: program_usb_timeout=1
max_usb_current=1
If a DAC is used then also:
Remove the driver for the onboard sound: Remove the line dtparam=audio=on from /boot/config.txt if it exists (can just add # in front)
Also in /boot/config.txt and add the following line: dtoverlay=hifiberry-dacplus
3. Switch off, plug in hdd, and boot - it is best to make a 100GB NTFS partition in front and leave rest unallocated using a windows PC.
4. Make a 100GB ext4 partition and copy the rootfs to it, and change fstab on the hdd and cmdline.txt on the sdcard boot partition:
sudo apt-get update && sudo apt-get install rsync gdisk
sudo apt-get install ntfs-3g
sudo apt-get install exfat-fuse exfat-utils
sudo gdisk /dev/sda
Enter n to create a new partition, and select number 1. Select the starting sector by hitting Return, then select +100G for the size. Now select the default filesystem ('Linux filesystem') by hitting Enter again.
Command (? for help): n Partition number (1-128, default 1): 1 First sector (34-61489118, default = 64) or {+-}size{KMGTP}: Last sector (64-61489118, default = 61489118) or {+-}size{KMGTP}: +100G Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'.
Hit w for write to make it permanent.
sudo mke2fs -t ext4 -L rootfs /dev/sda1
sudo mount /dev/sda1 /mnt
df -h
sudo rsync -axv / /mnt
sudo cp /boot/cmdline.txt /boot/cmdline.sd
sudo nano /boot/cmdline.txt
Change root=**** to root=/dev/sda1
sudo nano /mnt/etc/fstab
Change /dev/mmcblk0p2 / ext4 defaults,noatime 0 1 to
/dev/sda1 / ext4 defaults,noatime 0 1
sudo reboot
5. Then after rebooting check again with df -h if /dev/sda1 is now listed as the root /
You can then do the initial Raspberry Pi setup that was skipped at the start using the Raspberry Pi configuration Tool from the Settings Menu: Change Password, set Locale, WiFi country, Keyboard, Timezone - you will need to reboot
6. Then after rebooting check again with df -h
You can then do updates:
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove
If problem with missing pcakages try to re-run the first 2 commands and also try sudo apt-get update --fix-missing or sudo apt-get dist-upgrade --fix-missing
Reboot - you may then have to customize desktop again. Install additional software ( I use mc, smartctl, and audacious), using the software manager. Customize browser homepage and search.
7. Shut down and plug the hdd into a windows PC. Make an NTFS partition in the second unallocated space and copy music, videos etc. to that NTFS partition
8. Plug the hdd back into Raspberry Pi and switch it on. Then do:
sudo mkdir /mnt/data
sudo chown pi:pi /mnt/data
sudo nano /mnt/etc/fstab
Add: /dev/sda2 /mnt/data ntfs-3g rw,default 0 0
sudo mount -a
sudo chown pi:pi /mnt/data
df -h
Check if sda2 shows correctly.
9. If a DAC used create new asound.conf in etc/ (nano /etc/alsa.conf with the following lines:
pcm.!default { type hw card 0 }
ctl.!default { type hw card 0 }
10. Reboot then add DSP and analog sound to sound config in Raspberry Pi setting Make sure main volume click on speaker in panel is not 100% Open a console in sda2 folder with the video then:
If DAC Play with omxplayer: omxplayer -o alsa "File Name.mp4" On normal Pi with BCM audio just open terminal in Music folder and omxplayer name.mp4
Step 6: Raspberry Pi 4 4GB
I bought a Raspberry Pi 4 4GB and replaced the Raspberry Pi 3 with it in the same enclosure. The temperature stays between 40 and 50 degrees Celsius even under heavy CPU load conditions. I also acquired two different USB 3 HDD/SSD to SATA converters, and replaced the USB 2 version with that for testing purposes.
Firstly I tested the Raspberry Pi 4 with an Orico USB 3 enclosure circuit board and it works well - to remove the circuit board unclip the aluminum plate at the top and then you can remove the circuit board after unscrewing two small screws. A 10 cm long connection cable is looped once underneath the hard disk inside the PSU case which keeps it out of the way. For more detail please refer to:
http://www.orico.co.za/product/orico-usb3-0-2-5-enclosure-blue/
Secondly I tested a 5cm long open USB3 to SATA converter (please see picture), which also worked well but the shorter cable was too stiff to force it all the way inside the PSU case.
Using a USB 3 interface did result in faster boot and response times (such as when opening the Chromium browser or LibreOffice Writer, but it was not overwhelmingly faster. In addition the Raspberry Pi 3 and 4 supply a maximum of 1.2A spread over all 4 USB 2 and USB 3 ports, which is less than the USB 3 standard. I will therefore remove the Power connection on the front USB interface and connect it to a second identical variable 5v power supply module. This will enable me to run another HDD from the front USB interface.