A Raspberry Pi PC-PSU Desktop Computer With Hard Disk, Fan, PSU and On-Off Switch

Published

Introduction: A Raspberry Pi PC-PSU Desktop Computer With Hard Disk, Fan, PSU and On-Off Switch

I grew tired of connecting all the peripherals to my Raspberry Pi 3 every time I wanted to use it. I decided I wanted a Raspberry Pi computer permanently connected to a power supply, hard disk 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.

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

Share

    Recommendations

    • Water Contest

      Water Contest
    • Oil Contest

      Oil Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    4 Discussions

    0
    user
    deki

    4 months ago

    Would an SSD drive be better, they are fairly reasonable theses days. Amazon has a SanDisk 240GB for less than $70. Still need the the SATA to USB adaptor.

    2 replies

    Yes definitely it will be much faster and will use less than half the power as well.

    Yes definitely besides being much faster it also uses less than half te power

    0
    user
    Droxz

    5 months ago

    Nice, thanks for sharing :)