Raspberry Pi Hardware List
Raspberry Pi 3 (required)
($36.94)
Micro SD Card 8 GB or higher (required) - 16 GB
($9.97)
USB TTL Serial Cable (required)
($6.99)
You can get a two pack version that is cheaper:
Two for ($8.99)
USB Power Cable with Switch (required)
https://www.amazon.com/JBtek-Raspberry-Micro-Cable-Switch/dp/B00JU24Z3W/ref=sr_1_4?s=electronics&ie=UTF8&qid=1503463394&sr=1-4&keywords=usb+power+cable+with+switch+raspberry+pi($3.62)
You can get a 6 pack, which results in a cheaper per item cost:
($8.90)
USB Hub plus Ethernet adaptor (optional)
($13.99)
Here is another one:
($12.99)
Case (optional but recommended)
There are many options. Here is the official Raspberry Pi Foundation case:
($7.70)
Note if you use the USB TTY Serial Cable you want case that allow you to access the GPIO pins to connect the cable. Some cases do not allow you to do this.
SD Card Reader/Writer USB 3.0
($8.69)
Rough total cost:
$35.69 + $9.95 + $6.99 + $6.49 + $3.62 + $13.99 + $7.70 = $84.43
Operating System and Software Installation
Overview
We are gong to install Raspbian Stretch Lite onto a micro SD card then we are going to perform some basic configuration. Our main goal is to get your OS configured to connect your RPi to your laptop and to the Internet.
Hardware Setup: Connect Cables
You should have 3 cables: USB TTL Serial cable, USB Power cable with Switch, and an Ethernet cable. You may also have a USB Hub with Ethernet port.
To connect the USB TTL Serial Cable see the picture below. Make sure you have the right color wires connected to the correct GPIO pins:
You also need to connect your USB power cable with switch and the Ethernet cable. You should have everything connect to your laptop (perhaps all through the USB Hub with Ethernet port or all directly to your computer).
Laptop/Computer Serial Driver Setup
You will need to do a little bit of software setup on your laptop so that we can access the RPi through the USB Serial cable.
macOS
For macOS you need to install serial communication drivers for the USB TTL cable:
Linux
You do not need to install serial drivers on Linux. Linux comes with driver support for the USB TTL cable.
Windows
You may not need USB TTL Serial drivers for Windows, but if you do, install the following:
Raspbian Stretch Lite
For this class we will be using Raspbian Stretch Lite. If you want to run a full GUI Desktop on your Raspberry Pi, then you can install Raspbian Stretch with Desktop. The Desktop image for the SD Card is bigger and will take longer to download and install compared to Raspbian Stretch Lite. That said, the Desktop version should work fine for our work.
You can find Raspbian Stretch here:
Download the ZIP version.
Once you have the image you will need to copy the image file to the SD Card. You will need a tool to do this. A very fast and easy to use tool is called Etcher:
There are versions of Etcher for macOS, Windows, and Linux. Download the version that matches the OS on your computer.
Once you have imaged the SD card, you will need to edit the config.txt file on the boot partition. You will need mount your SD card onto your computer, then use an editor to add the following line to the config.txt file:
enable_uart=1
Make sure you have a newline (CR) at the end of this line.
Laptop/Computer Terminal Setup
You will need a program that allows you to connect to the Raspbian serial console via the USB TTL cable.
On macOS and Linux I recommend you use a program called kermit.
On macOS, you can install kermit via Homebrew:
http://brew.sh
Follow the homebrew install instructions.
Once installed you can type:
$ brew install c-kermit
On Ubuntu Linux you can use apt-get to install c-kermit:
$ sudo apt-get install ckermit
Once installed, create a .kermrc file in your home directory (on your host computer/laptop):
$ cd
$ cat > .kermrc
set line /dev/cu.usbserial
set speed 115200
set carrier-watch off
connect
^D
$
(When you see ^D, type the CTRL key and D at the same time, do not type the characters "^D".)
Note on Linux you will use a different device name for the set line. It is often something like /dev/ttyS0.
Now you can use kermit to connect to your RPi via the USB Serial cable.
Type:
$ kermit
Now turn on your RPi.
You should see the boot squence.
To exit kermit, type
CTRL-\ then q
You can start and stop kermit multiple times with out the terminal hanging.
On Windows you can use the Putty Program:
Also see more information for using Windows and Putty to connect to the serial console on a Raspberry Pi:
Raspbian Configuration
Using your serial connection and kermit or Putty, you can access the Raspbian console.
The default username and password are:
username: pi
password: raspberry
Use these credentials to log in.
Once logged in you should do some basic configuration using the raspi-config program:
$ sudo raspi-config
You should do the following:
- Change the default password
- Change the hostname (optional)
- In Localization Options change the locale (add en_US.UTF-8 UTF-8 and make this your default locale)
- In Interfacing Options enable SSH
After you make these changes, restart you RPi:
$ sudo shutdown -r now
Networking Configuration
The best way to connect to your RPi is through the Ethernet cable using ssh. You will need to setup Internet Sharing on your laptop to enable this and to allow your RPi to access the Internet. You need your Raspberry Pi to access the internet to update software and to use GitHub.
macOS
You can turn on Internet Sharing in System Preferences under the Sharing option. You will need to enable Internet Sharing on the Ethernet Device you are connecting to. For the USB Hub with Ethernet this will show up as "USB 10/100/1000 LAN."
To ensure that you get the same IP address every time you connect your RPi, you should add the following file to your Mac: /etc/bootptab
# Bootptab file
# Section 1 -- ignored
%%
# Section 2 -- used
# Hardware types: 1=Ethernet, 6=Wireless
# See http://www.ietf.org/rfc/rfc1700.txt
#
# machine entries have the following format:
#
# hostname hwtype hwaddr ipaddr bootfile
rpi 1 b8:27:eb:39:e1:2d 192.168.2.2 boot
Replace the hwaddr with the hwaddr of you Ethernet device on your RPi. To find this, on your RPi, type:
$ ifconfig
Look for the "ether" device. This is the "MAC" address of your ethernet device on the RPi.
enxb827eb39e12d: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.4 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::3edf:94a3:9457:9779 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:39:e1:2d txqueuelen 1000 (Ethernet)
RX packets 661 bytes 100666 (98.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 122 bytes 20203 (19.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
My RPi Ethernet Mac address is:
b8:27:eb:39:e1:2d
Linux
For Ubuntu see:
Windows
See:
With Internet Sharing your RPi should be accessible from your laptop and you should be able to access the Internet on your RPi:
For example, on my mac I can type:
$ ssh pi@raspberrypi.local
or
$ ssh pi@192.168.2.2
Once on your RPi, you can see if you can access the Internet:
$ ping google.com
PING google.com (216.58.194.206) 56(84) bytes of data.
64 bytes from sfo03s01-in-f206.1e100.net (216.58.194.206): icmp_seq=1 ttl=52 time=14.1 ms
64 bytes from sfo03s01-in-f206.1e100.net (216.58.194.206): icmp_seq=2 ttl=52 time=17.1 ms
Command Line Editors
nano (standard)
vi (standard)
vim (optional)
sudo apt-get install vim
emacs (optional)
sudo apt-get install emacs
ne (optional)
sudo apt-get install ne