Raspberry Pi Workshop
Burning Raspbian to an (micro)SD Card
For Mac:
For Windows:
Download and install Etcher: https://etcher.io/
Flash the image
- Open Etcher
- Select the Raspbian image
- Select the drive to which you want to burn
- Double check your selections
- This is critical, as you run the risk of overwriting the wrong drive (including your primary hard drive)
- Click “Flash!” and wait until Etcher writes and validates the image. This can take around 10 minutes.
- Once finished, eject your SD card
Ports
![](https://i2.wp.com/2.bp.blogspot.com/-GOPkwrpFMBk/VtRkngTJWEI/AAAAAAAAm_U/AFN47w1rb2s/s1600/raspberry-pi-3-microcomputer.png?w=840&ssl=1)
Plugging in your peripherals
- HDMI
- Keyboard and Mouse
- MicroUSB Power Supply (5V/2.1A)
Boot for the First Time
Get your MAC Address
- In the Raspberry Pi GUI, click the Terminal icon in the top left toolbar
- Run the command
ifconfig
- Locate the
wlan0
section and find and write down the HWaddr
; it should look something like: b8:27:eb:00:00:00
- This is the MAC Address for your wireless adapter on the Raspberry Pi; you will use it to register the Pi on the network
Register with the CMU Legacy Network
- Go to https://netreg.net.cmu.edu/
- Enter and select the link to “Register New Machine”
Select the “Legacy Wireless Network” and click the in-line “Continue” button.
![](https://i2.wp.com/courses.ideate.cmu.edu/48-739/s2017/wp-content/uploads/2017/02/Screen-Shot-2017-02-18-at-12.13.52-PM.png?w=840&ssl=1)
Enter a name for your Raspberry Pi
Enter the wlan0
MAC address from the raspberry pi
![](https://i0.wp.com/courses.ideate.cmu.edu/48-739/s2017/wp-content/uploads/2017/02/Screen-Shot-2017-02-18-at-12.06.06-PM.png?w=840&ssl=1)
Now we wait…
Changing the Default Settings
- Open Raspberry Pi Menu > Preferences > Raspberry Pi Configuration
![](https://i0.wp.com/courses.ideate.cmu.edu/48-739/s2017/wp-content/uploads/2017/02/2016-11-25-185241_1280x800_scrot.png?w=840&ssl=1)
System
- Change Password
- Change Hostname
- Boot to CLI
![](https://i1.wp.com/courses.ideate.cmu.edu/48-739/s2017/wp-content/uploads/2017/02/2016-11-25-184949_1280x800_scrot.png?w=840&ssl=1)
Interfaces
- Set everything to enabled, except VNC
![](https://i0.wp.com/courses.ideate.cmu.edu/48-739/s2017/wp-content/uploads/2017/02/2016-11-25-185044_1280x800_scrot.png?w=840&ssl=1)
Reboot
Open Terminal and type
CRON
- Cron is a task scheduler
- You can add tasks to cron using the
crontab
The command
will take you to the root crontab, meaning your tasks will run regardless of which user is logged in
![](https://i2.wp.com/media.lifehacker.foxtrot.future.net.uk/wp-content/uploads/sites/55/2015/11/pi-schedule.chrontab.png?w=840)
You can also use special signifiers
A common example is to start a program a few seconds after startup:
|
@reboot sleep 10 && /usr/bin/nodejs /path/to/nodescript.js |
Connecting to WiFi
- This is easiest to do in the GUI
- To enter the GUI from commandline mode, run the command
startx
- Find the WiFi icon and select CMU
We are going to test to see if our connection has propagated by running the command
If it returns with a list similar to this:
|
PING google.com (68.65.124.44): 56 data bytes 64 bytes from 68.65.124.44: icmp_seq=0 ttl=60 time=12.702 ms 64 bytes from 68.65.124.44: icmp_seq=1 ttl=60 time=13.478 ms 64 bytes from 68.65.124.44: icmp_seq=2 ttl=60 time=13.880 ms 64 bytes from 68.65.124.44: icmp_seq=3 ttl=60 time=12.818 ms |
then you are connected. If not, keep waiting.
SSH
- Once your pi is on the CMU network, you should be able to SSH into the device from your laptop
- Run the command (but fill in your own info)
ssh $USER@$URL
for example ssh pi@hostname.wv.cc.cmu.edu
It will ask if you want to add this to the list of known hosts, type Yes
Updating Packages
Linux has a built-in package manager called apt-get
We need to update the list of package repositories:
Next, we want to get the newest versions of all our packages:
(this may take a while and require some user confirmation)
Installing Packages
Raspbian comes with Node.js installed, but the version is very old.
We need to add a new repository to our package manager:
|
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - |
Now, install Node.js:
|
sudo apt-get install nodejs |
Install and Configure Samba
Install Samba with:
|
sudo apt-get install samba |
Go to the Samba configuration folder:
Rename the configuration file (so we have a backup):
|
sudo mv smb.conf smb.conf.original |
Make and edit a new one:
- Copy this into new file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
[global] workgroup = WORKGROUP netbios name = SAMBA server string = Samba Server %v map to guest = Bad User log file = /var/log/samba/log.%m max log size = 50 socket options = TCP_NODELAY SO_RCVBUF=819SO_SNDBUF=8192 preferred master = No local master = No dns proxy = No security = User # Share [Data] path = / valid users = pi read only = No create ma19 = 0755 directory mask = 0755 |
Set up a new password:
Restart the Samba service:
|
sudo service smbd restart |
- On your Mac laptop, you can now mount the Raspberry Pi filesystem on your computer by going to Finder and typing
⌘+k
- Enter smb://pi@$yourIPAddress
![](https://i1.wp.com/courses.ideate.cmu.edu/48-739/s2017/wp-content/uploads/2017/02/Screen-Shot-2017-02-18-at-1.38.52-PM.png?w=840&ssl=1)
Getting the example code
- Clone the repo to your Pi by running
git clone https://github.com/Making-Things-Interactive/button-twitter.git
Raspberry Pi 3 Pinout
![](https://i2.wp.com/www.myelectronicslab.com/wp-content/uploads/2016/06/raspbery-pi-3-gpio-pinout-40-pin-header-block-connector-.png?w=840&ssl=1)