Introduction: Build a Raspberry Pi PC for Less Than $140

March 2017 update: Create a Raspberry Pi-based PC with acceptable performance at a low price for use in high school student class.

Most people are familiar with Windows or MAC operating systems. Linux is a different OS. One goal of this instructable is to set up the Raspberry Pi so it has features similar to a MAC or PC. Once the student is comfortable with linux, the student can explore deeper into linux.

My son, Adam, teaches junior high and high school science at Weldon Valley. His science lab has 6 translucent blue iMAC computers. According to Wikipedia, Apple shipped iMac G3s between 1998 and 2003. iMac G3s used a single core 700Mhz PowerPC 750. My son said the iMacs were too slow for today.

A Raspberry Pi 3, model B has four ARM Cortex-A53 cores running at 1.2GHz or 7 times faster than the iMAC. This processor and on board Wi-Fi make it an ideal low-cost student computer.

He wanted his students to use the machines for scientific research. I offered to make a Raspberry Pi-based PC, which would help my son, help his students, and allow me an excuse to build a Raspberry Pi-based PC. The school is 1A, so the class size is usually 15 students or less.

Classroom PowerPoint slides from my Google drive.

The goals of this project are:

  • make high-performing, low-cost PCs using a Raspberry Pi 3, model B
  • provide the features expected on a PC (email, word, spreadsheet and so on)
  • the science lab only has Wi-Fi, so Wi-Fi download speeds must be reasonably fast
  • teach basic course on raspberry pi PC setup
  • target is comparable user experience to $180 HP Stream laptop with Intel Celeron N2840 2.16GHz processor

Notes:

  • Text enclosed in spades, such as, ♣replace-this♣, should be replaced with an actual value. Of course, remove the spades.
  • Instructables editor likes to autocorrect, so wlan turns to plan, and autoremove turns to auto remove. These changes are tough to spot when I am reviewing.

Step 1: Gather Parts

The parts below perform best for a Raspberry Pi PC. If you have suggestions for improvements or cost reductions, I would appreciate any input.

I attempted to find best performing lowest cost parts and bought 15 at a time.

While I used a MacBook for setup, a Windows PC can be used.

Parts list (prices in USD):

  • Raspberry Pi model 3 B complete starter kit from CanaKit $69.99 @ Amazon
    • includes Case, Heat Sinks, Power Adapter, micro to USB cable, 32GB micro SD card class 10, HDMI cable, USB micro SD card reader (very cool)
  • Wireless USB Keyboard and Mouse $21.99 @ Amazon
  • Display - 17" LCD Monitor $15.00 @ Discount Electronics (next time buy 19inch monitors for $2 more)
  • USB Speakers $5 @ Discount Electronics
  • HDMI female to VGA male adapter $14.99 at Amazon (direction is important)

Parts laying around:

  • MacBook Pro (a PC can be used)
  • CAT6 ethernet cable

Notes:

  • Discount Electronics sells used and refurbished Dell equipment. Its in-store prices are sometimes cheaper than those on the web site
  • Link to supported Raspberry Pi SD Cards

Step 2: Download Diet-Pi

Compared to a laptop or desktop PC using the latest Intel processor, the raspberry pi's processor is under powered. So, a dominant principle in maximizing performance is to eliminate unnecessary load on the processor.

Diet-Pi is a minimal installation of raspbian. Both dietpi and raspbian are based on the debian linux distribution.

Diet-Pi eliminates operating system processes that are not required allowing the processor to perform user tasks more quickly. Running the command top on one of my raspbian systems shows 126 tasks running, while diet-pi only has 91.

Diet-Pi also has a lightweight GUI and eliminates unnecessary I/O to the micro SD card. An SD Card has a limited number of write cycles before it wears out and needs to be replaced. Linux logs errors and messages about the system and its applications. DietPi writes these to a RAM disk, avoiding writes to the SD Card and prolonging its life.

Steps:

  • Download the latest version of Diet-Pi. When this was written the latest version was (145): DietPi_RPi-(Jessie).7z ... or ... download the finished image for 32GB micro SD Card from my Google Drive.
  • Drag the download from downloads to a directory where you store images. I like to keep downloaded images and backup images of raspberry pi projects in a directory on my Mac.
♣your-macbook-image-directory♣
  • Open a terminal window on the MacBook
  • Change to your image directory and list the files
$ cd ♣your-macbook-image-directory♣
$ ls 
2015-11-21-raspbian-jessie.img	SDCardBackupSetup.dmg
DietPi_RPi-(Jessie).7z		disk_test.dmg
  • I used The Unarchiver to decompress the zip file (.7z) on my MacBook.
  • And then deleted the compressed file (drag the zip file to the trash)
$ cd ♣your-macbook-image-directory♣
$ ls
2015-11-21-raspbian-jessie.img	SDCardBackupSetup.dmg
DietPi_v145_RPi-armv6(Jessie).img		disk_test.dmg
  • Later steps won't like the parentheses. So rename the image to: DietPi_v145_RPi-armv6-jessie.img

Step 3: Burn Diet-pi Image to Micro SD Card

IMPORTANT: make sure you type in the correct disk number – if you enter the wrong disk number, you will wipe out your hard disk!

Insert a micro SD card into USB micro SD card reader, and then insert the USB into MacBook.

On MacBook use these instructions from Raspberry Pi. Summarized here:

  • Open MacBook terminal window
  • Change to directory containing diet-pi image
$ cd ♣your-macbook-image-directory♣
  • Identify the disk (not partition) of your SD card
  • In this case, disk4 (not disk4s1) and = 4
  • To identify your micro SD card, run the command:
$ diskutil list
  • Unmount your SD card by using:
$ diskutil unmountDisk /dev/disk♣micro-SD-card-disk#♣
  • Copy an image to your SD card. Ensure the image name is correct.
$ sudo dd bs=4m if=DietPi_v145_RPi_armv6_Jessie.img of=/dev/rdisk
♣micro-SD-card-disk#♣
  • CTRL-t to see the status of the copying.
  • If there are errors, try different values for bs option, such as, 1m, 1M, or 4M. Larger Block Sizes (bs) are required for larger drives.
  • When complete, unmount the SD Card:
$ diskutil unmountDisk /dev/disk♣micro-SD-card-disk#♣
  • Remove USB micro SD card reader from MacBook and remove micro SD card from reader
  • Insert micro SD Card in Raspberry Pi

Step 4: Raspberry Pi Connections

Put the Raspberry Pi in its case

Take the case out of its box and carefully pry it apart, should be in three parts.

Slide the Raspberry Pi into the case

Attached the heat sinks by removing the sticky tape and firmly put gently attaching to the two square semiconductors.

Put the case back together

Insert Cables and Adapters

Insert the following into the Raspberry Pi

  • Micro SD card
  • Ethernet cable
  • USB for keyboard and mouse
  • HDMI cable
  • USB speaker

Insert other end of HDMI cable into HDMI to VGA adapter

Connect VGA Adapter to monitor

Plug in the monitor power cable.

Insert audio from speaker into HDMI to VGA adapter

Once the above are complete:

  • Insert power cable (micro USB power adapter)

Step 5: Setup Using Diet-Pi Config

Login to Raspberry Pi with username = root and password = dietpi

In DietPi Config:

  • Use up or down arrows to scroll and highlight selections
  • Use Tab to move to highlighted item, EXIT, GO or BACK
  • Use ENTER to accept item
  • When presented with a list, use space to select [ * ]

On first boot, DietPi config starts automatically

Because the downloads take a while, prior to the class set up all Micro SD cards with the same image.

Read and follow the directions in dietpi-config or dietpi-launcher. Here are my settings:

  • Display Options
    • Resolution: 1080p
    • GPU/RAM Split: Desktop
    • HDMI Boost: Enabled (important is display is black after shutdown / reboot)
  • Language and Regional Options
    • en_US.UTF-8 UTF-8
    • en_US.UTF-8
    • Timezone: US, Mountain
    • Keyboard: Dell, Other, English (US)
  • AutoStart: Desktops
  • Software Optimized:
    • 23 LXDE
    • 81 LLSP
    • 112 DXX-Rebirth
  • Software Additional:
    • OpenSSH
  • SSH Server
    • OpenSHSH

Be sure to run Install, which installs software and reboots. If a setting is missed, just run dietpi-launcher again.

In aterminal window on the Raspberry Pi, edit the configuration file. And change the lines below to look as shown. Comments start with #.

$ sudo /DietPi/config.txt

# hdmi_safe=1 


# hotplug allows HDMI to be plugged in and recognized while the Pi is running
hdmi_force_hotplug=1 

# hdmi_group=2 sets to DMT 
hdmi_group=2

# hdmi_mode=35 sets display to 1280x1024 @60Hz
hdmi_mode=35

# hdmi_drive=2 sets to normal HDMI with sound
hdmi_drive=2

# config_hdmi_boost=5 boosts signal. Can go as high as 9
config_hdmi_boost=5

CTRL-o, ENTER, CTRL-x to save and exit the editor

In an LXterminal window, on the Raspberry Pi run

$ sudo reboot<br>

Step 6: Always Update and Upgrade

On raspbian, always run apt-get update and upgrade before installing new software. However, on dietpi updates are done automatically.

Updates can also be done manually from the Tools menu.

The image above is the LXDE icon, on LXDE desktops it is shown in lower left corner on the taskbar.

Click on the LXDE icon in the lower left.

Select System Tools and then DietPi-Update.

Allow DietPi to do updates for you.

If there is an update follow the instructions, such as, open an LX Terminal and run

$ sudo reboot

If there are errors, check that an Ethernet cable is plugged in.

Step 7: Add the Best Linux Applications

In my opinion, this is the best desktop linux software, providing functionality similar to Windows or OSX.

Select the LXDE icon from the taskbar, System Tools and then LXTerminal

Run the following commands:

Add light-locker

$ sudo apt-get install light-locker -y

Add thunderbird (email client)

$ sudo apt-get install icedove<br>

Add scratch (programming language)

$ sudo apt-get install scratch -y

Add document reader, including PDF

$ sudo apt-get install evince -y

Add Wolfram and Mathematica (must install manually and accept license)

$ sudo apt-get install wolfram-engine 

Add gimp (image editor)

$ sudo apt-get install gimp -y

Add toolbar

$ sudo apt-get install wbar wbar-config -y 

Add system monitoring tool, called conky (Copy files from here). Instead of copying to /home/pi, copy to ~/.

conky-manager doesn't install.

$ sudo apt-get install conky
$ wget -O ~/.conkyrc https : //raw.githubusercontent.com/novaspirit/rpi_conky/master/rpi3_conkyrc

To autostart conky on bootcreate 2 files. The first file is a shell script to delay the boot process of conky.

$ sudo nano /usr/bin/conky.sh

#!/bin/sh
(sleep 4s && conky) &
exit 0

CTRL-o, ENTER, CTRL-x to save and exit

The second file is the conky.desktop file for the autostart process

sudo nano /etc/xdg/autostart/conky.desktop
[Desktop Entry]
Name=conky
Type=Application
Exec=sh /usr/bin/conky.sh
Terminal=false
Comment=system monitoring tool.
Categories=Utility;

CTRL-o, ENTER, CTRL-x to save and exit

$ sudo reboot

Install audio editor

$ sudo apt-get install audacity -y

Install photo editor

$ sudo apt-get install shotwell -y

Install Open Libre (similar to MS-Office)

$ sudo apt-get install libreoffice -y

Install clementine (music player)

$ sudo apt-get install clementine -y

Install streaming music player (optional step)

Follow the steps here to install mopidy a streaming music player for spotify, google music, etc.

Install 3d animation tool, blender

$ sudo apt-get install blender -y

Install video player

$ sudo apt-get vlc -y

Install screen recorder

$ sudo apt-get install kazaam -y

Install calendar and contact manager

$ sudo apt-get install korganizer -y<br>

Step 8: Are All Apps in Panel or Toolbar

wbar

To add icons, use findicons.com. The default icons can be used, and probably should be used, but I'd like to have the wow factor when the students first assemble their linux PCs.

To modify wbar, click on Config, scroll to icon and change (add, edit, delete. Use icons or right-click)

Change Audacious to clementine

Change claws to icedove

Change Image Viewer to Photos and shotwell

Change Terminal command to lxterminal

Add gimp and grab icon

Add librewriter and grab icon

Add audacity

Add blender

Add vlc and grab icon

Add korganizer and grab calendar icon

Add glaculator and grab calculator icon

Add dietpi-launcher and grab dietpi icon from github

Desktop Preferences

Add trash can and documents to desktop

Remove dietpi shortcuts

Step 9: Backup the Micro SD Card and Clone

Now that one computer is setup, clone 14 more

When Raspberry Pi is setup back up the image. Use this image to create the next PC.

Shutdown the Raspberry Pi

$ sudo shutdown –h 0

Wait until the card has shutdown, and then remove the power supply, and then remove micro SD Card

Insert micro SD card into USB micro SD card reader, and then insert the USB reader into MacBook

On MacBook use these instructions from The Pi Hut with modifications as follows:

Open terminal window

Change to directory containing diet-pi image

$ cd ♣your-macbook-image-directory♣

Identify the disk (not partition) of your SD card e.g. disk4 (not disk4s1). From diskutil output, = 4

$ diskutil list

IMPORTANT: make sure you use the correct – if you enter the wrong , you will end up wiping out your hard disk!

Copy the image from your SD card. Ensure the image name and are correct:


$ sudo dd if=/dev/disk♣micro-SD-card-disk#♣ of=weldon.dmg

CTRL-t to see the status of the copying.

When complete, unmount the SD Card:

$ diskutil unmountDisk /dev/disk♣micro-SD-card-disk#♣

Remove SD adapter from MacBook and remove micro SD card from adapter

Insert micro SD Card in Raspberry Pi and check that it works

Use this image to clone the next micro SD Cards and follow instructions in Step 3 using the new image.

And you are done!

Step 10: Packaging

There are 15 systems that I need to transport and the car has limited space.

A system includes: speakers, monitors, CanaKits HDMI to VGA adapters, and keyboards.

Cut down on the space required by merging the CanaKit, HDMI to VGA adapter and keyboard and mouse into one box.

This involved cutting some parts of the keyboard box and raising up the sides by refolding the box.

Step 11: Change Hostname, Root Password

Student Exercise:
Change hostname and root password

DietPi-Config, DietPi Security Options

Step 12: Add a User

Student Exercise:

By default, DietPi uses a login of username: root, while raspbian uses username: pi.

Many Raspberry Pi directions and my instructables assume a starting point of /home/pi and a login of pi, add a user called: pi

$ mkdir /home
$ useradd pi -m -G sudo
$ passwd pi
Password: ♣raspberry-pi-password♣
Password: ♣raspberry-pi-password♣

If you make a mistake, use the following command to remove the user:

$ userdel pi

Make a copy of the file /etc/sudoers

As user, root, edit the file, but be careful with this file. Be sure it correct before saving

$ sudo nano /etc/sudoers 

Without the following change you will have to enter a password each time sudo is used.

After the comment, #includedir ..., add the line that starts, pi ALL=:

#includedir /etc/sudoers.d
pi ALL=(ALL) NOPASSWD: ALL

CTRL-o, ENTER, CTRL-x to save and close the file

Check the new user works

$ logout

and login as pi with ♣raspberry-pi-password♣

$ ssh pi@♣ip-address♣

If logged in as pi, DietPi utilities are located in:

/DietPi/dietpi

dietpi scripts use a check for root UID = 0, which prevents the pi username from running the dietpi scripts. The script checks if $UID=0, which should be reserved for username root. Adding the directory to PATH doesn't help.

So to run dietpi-config or any of the dietpi utilities from pi, login as super user, and then run the command. To exit superuser, enter exit.

$ sudo su
$ sudo /DietPi/dietpi/dietpi-config
♣change-settings♣
$ exit

Of course, you could modify the script and add the pi username's UID or remove the check for root's UID. There might be additional changes required.

if (( $UID != 0 )); then

Optional Step

In general, root should not be used as a login. The root login should not be disabled, but should be blocked from normal login.

To prevent users from logging in directly as root, set the root account's shell to /sbin/nologin in the /etc/passwd file.

$ sudo nano /etc/passwd

Change

root:x:0:0:root:/root:/bin/bash

to

root:x:0:0:root:/root:/usr/sbin/nologin

Step 13: Setup Wi-Fi

Student Exercise:

Click the LXDE icon. Select System Tools, DietPi Config

Change Network Options: Adapters, enable Wi-Fi

When using DietPi, use the provided tools rather than editing them from command line tools.

From the funky icon, select System Tools, DietPi-Config, and then Network Options: Adapters

Enable onboard WiFi

Select WiFi

Select Manual: enter your home/school SSID and password

Unplug the ethernet cable and check if the you can browse the web

Disable wired ethernet: Ethernet Change Wired Network Settings

Change Country Code to US

Restart WiFi

Add WiFi icon to task bar (optional)

Right click on the task bar and select "Add/Remove Panel items"

Click "Add" button

Add Wireless and Wired Networks

Step 14: Email

Use a web-based email account, such as gmail, or whatever you prefer.

Step 15: Appendix: References

Step 16: Appendix: Updates

11MAR-01APR2017

  • Added place holders for appendices: References, Updates, Troubleshooting
  • Updated steps for DietPi v145
  • Start revised parts list for high school level project
    • Raspberry Pi model 3 B complete starter kit from CanaKit $69.99 @ Amazon
      • Case, Heat Sinks, Power Adapter, micro to USB cable, 32GB micro SD card class 10, HDMI Cable
    • Wireless USB Keyboard and Mouse $21.99 @ Amazon
    • Display - 17" LCD Monitor $15.00 @ Discount Electronics
    • USB Speakers $5 @ Discount Electronics
    • HDMI female to VGA male adapter $14.99 at Amazon
  • Old parts list
    • refurbished/used USB Keyboard $4
    • refurbished/used USB Mouse $6
    • 17” refurbished/used monitor (HDMI input preferred, but this one has DVI) $49
    • Raspberry Pi 2 Model B Element14 $35
    • Panda 300n WiFi Adapter Amazon $16.99
    • 5.2V 2.1A USB Power Adapter from Amazon $5.99
    • Micro USB to USB cable 3ft from Amazon $4.69
    • Case from Amazon $6.99
    • Should be 64GB or larger >>> SanDisk Ultra 16GB Ultra Micro SDHC UHS-I/Class 10 Card with Adapter (SDSQUNC-016G-GN6MA) from Amazon $8.49

Step 17: Appendix: Troubleshooting

Raspberry Pi Troubleshooting

If there are any issues with the Raspberry Pi, then this link is the best place to start

Black Screen

After installing all the apss, I shutdown using the LXDE shutdown menu option and the system was no longer usable. I had to reflash the micro SD card to get it to work.

When I rebooted again, the same thing happened.

I could ssh into the Raspberry Pi from my MacBook. So, I realized there was something wrong with the display.

To fix a black display issue, ssh into Raspberry Pi from another computer and un-comment some lines in DietPi's config file. The boost value is set in this instructable through the DietPi config tools

ssh root@192.168.1.115
login with password

$ sudo nano /DietPi/config.txt 

uncomment the lines: 
hdmi_force_hotplug=1
hdmi_drive=2
config_hdmi_boost=5

CTRL-o, ENTER and CTRL-x to save and exit the nano editor

HDMI Safe mode degrades resolution, but will allow the monitor to work.

Display or Monitor issues

On Raspberry pi:

$ /opt/vc/bin/tvservice -d edid.dat<br>$ /opt/vc/bin/edidparser edid.dat

buried deep in the output is a line that reads "... best score mode ..."

For my monitor, it returned "... best score mode is now DMT (35) 1280x1024 @ 60Hz ..."

The (35) indicates best setting for hdmi_mode=35


Editing config.txt on MacBook

I had already flashed all the micro SD cards with a standard image when I figured out how to fix the display resolution issue. So, I wanted to change the config.txt on all the micro SD cards.

The easiest way is:

Insert USB micro SD card reader into MacBook

Micro SD Card will automount and boot icon will appear on desktop

open boot drive on desktop

drag config.txt from boot drive to desktop

close boot window

In a terminal window, run

diskutil list

diskutil unmountDisk /dev/disk2♣micro-SD-card-disk#♣

and remove USB micro SD card reader

Then for each micro SD card:

Insert USB micro SD card reader into MacBook

open boot drive on desktop

drag config.txt from boot drive to desktop, click replace

close boot window

In a terminal window, run

diskutil list

diskutil unmount Disk /dev/disk2♣micro-SD-card-disk#♣

remove USB micro SD card reader

and repeat

Speaker

Check connections and run

$ speaker-test -c2<br>

CTRL-c to stop the test