Here are some instructions about taking a brand new RaspberryPI 3B+ and bringing it to life.

The first thing to do is to get a micro SD card (these are cheap, like $5 for a 32G). The 3B+ is a 64bit machine so 32G seems like plenty, with no worries about needing more space later (famous last words). Take the microSD card and put it into a USB adapter and mount it on your PC or MAC (both work, you might have to format it if the OS makes you but that's fine). Then go to raspberry.com, click on the software tab and then download the installer (it's called "Raspberry Pi Imager v1.8.5). If you want to do exactly what I did and can't find that particular installer on the web site, you can find them here:

Once you have the installer, run it. It will bring up a window that looks like this:

Click on "CHOOSE DEVICE" (here you would choose "Raspberry Pi 3") and "CHOOSE OS" and select the top item, "Raspberry Pi OS (64-bit)". Then click on "CHOOSE STORAGE" and select the microSD card. You should then see "NEXT" at the lower right become available, so hit that. It will then pop up a window that asks "Use OS Customisation?". Hit "EDIT SETTINGS", and it brings up a window of settings. Click on the "GENERAL" tab. You can "Set username and password" for the username/pw to log into the Raspberry Pi (I used rpi as the username and put in a pw). If you have a way to get onto a wifi network, click "Configure wireless LAN". In many universities, you will need to set up something which requires you to know the MAC address, so if you know it, you can set it up in advance. If you don't know the MAC address and need it to set up something, then you'll have to leave this blank and do it later.

Then select "Set locale settings" and select the "Time zone:" and "Keyboard layout:". Note that if you don't have the wireless LAN configured, it might not be able to implement the time zone settings and you'll have to do that later.

If you click on the "SERVICES" tab, you can enable SSH, which would be good but you can also do that later. The "OPTIONS" tab is pretty generic

Then click the red "SAVE" at the bottom, which brings you back to the "Use OS customisation?" window. Click "YES". It then warns you that it will erase what's on the SD card, click "YES". On the MAC it asks you for your system password, so you will have to know it. It takes awhile to write and verify (maybe 5-10 minutes, depending). (When it got to the verify stage, I canceled it, since I doubt that what is written to the SD card has any errors.)

Note: if you are using Windows 11, and the microSD card already has something on it (like a previous Raspberry PI OS!), then Windows might not let you write to it. In that case, here is a prescription that works:

    o Plug your SD card into your Windows computer
    o Run the windows command app (Windows+R, type "cmd", hit return)
    o Type "diskpart" and press enter
    o Execute the following:

        list disk       (this will list the disks and tell you the disk number)
        select disk "x" (replace "x" with the appropriate disk number for your SD card)
        clean
        create partition primary
        format fx=exfat quick

When the program finishes, pop out the SD card and plug it into the RPI, and plug in the monitor, mouse, and keyboard (I used a wireless keyboard/mouse combo, so just plug in the USB dongle). Then plug in the power to the micro USB port on the RPI and it will boot up.

At UMD we will use the RPI on a WiFi network called 'umd-iot' that is for IOT devices. This network protects IOT devices from outside intrusions (you can get out to the internet from the device but nothing can get in). To use that umd-iot network you first have to register the RPI's MAC address with the helpdesk (I usually just email Aaron McQueen with the MAC address and he does the registering). Once they have the MAC address they can register it and send you the password to use the network. The catch here is that you need the MAC address to use the network, but you can't get the MAC address without booting it up and going to a terminal and typing:

ifconfig
and reading it off of the wlan0 device. However, in the initial bootup process, the RPI asks you the username and password to create, the network to use, and then does an update. But you can't update without the network, and you can't use the network without the password, and you can't get the password without the MAC address. So you could bypass the network and run a terminal and get the MAC and send it in, but then I'm not sure how to do the update in the same way that the Raspberry PI linux OS does (there's probably a command, like apt-get, but who knows what the OS is really doing). So, the best thing is to get a RPI that already has an installation, boot it up with that SD card, read off the MAC address, then register it and get a password, then put in the new SD card and go through the setup below. So that's what I am doing.

So, pop in the SD card, power up the RPI, and then When it's up, it will say a few things about generating keys and reboot a few times. Then it will take you to a screen that says "Welcome to the Raspberry Pi Desktop". Click "Next".

It will ask a few things about setting country and language (I used USA and American English), and set the timezone appropriately. It takes around 30 seconds.

Then it will asks for a username and password. I used this:

username: rpi
password: physics495   (at UMD)
password: cenpa        (at UW)
Then hit next, and where it says "Set Up Screen" hit next again. Then it shows you a screen to "Select WiFi Network". Select "umd-iot" and give it the password. It might take a few seconds to connect with the network but you should be good to go. If you aren't at UMD using umd-iot and want to use something else, you'll have to play it by ear.

Then it takes you to a screen called "Update Software". Or if it doesn't, you should see an update icon in the upper right corner. Hit "next", and it will synchronize the clock (make sure it's set correctly, necessary for updating), then it will spend a lot of time comparing versions, downloading files, installing, and then it will restart. Might take some time.

Note: the rpi account doesn't have root privs, so you have to use sudo for lots of stuff. I did NOT configure it so that sudo needs a password. To do this see this web site.

Once you have the thing booted into the RPI desktop, the first thing to do is to increase the page swap file. The default is 200MB, which is pretty small, and the SD cards we are using has 32G. So I increased mine to 1024MB, which makes the thing run a bit faster. To do this:

cd /etc/
sudo nano dphys-swapfile
and change "CONF_SWAPFILE=200" to "CONF_SWAPFILE=1024".  Exit (^x) and save.  Then
reboot using "sudo reboot".

Next, do all of the updates:

sudo apt-get install
sudo apt-get full-upgrade
This might take awhile, so go get a coffee.

Python is defaulted to version 3.11.2, and in the OS you are using, typing 'python' or 'python3' takes you to the same executable. To make sure you have the 3.11.2 version, do this:

python -V
It should return
Python 3.11.2
There is no need to update python (I left it at 3.9.2 even though it's a bit old). But for our purposes you will need to install this library by:
sudo pip3 install matplotlib

When you try to install matplotlib, you might get an error that starts with this:

error: externally-managed-environment

× This environment is externally managed

To fix this issue the following command:

    sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED
Note: "sudo" means "do this as superuser, or in other words, root". "rm" means "remove", same as "delete". "/usr/lib/python3.11" is the directory of the file you want to delete, and "EXTERNALLY-MANAGED" is the name of the file. That seems to fix the problem, so try
sudo pip3 install matplotlib
again. Should work.

You should also install the plot library extension for making plots in popup windows:

sudo apt-get install python3-pil.imagetk
and scipy, which has lots of good stuff like fourier transforms:
sudo python -m pip install scipy

Serial connections to the RPI are done by using the right GPIO pins, and using the python 'serial' library. But first you have to tell the OS that you will be using the serial UART (that's the name of the serial protocol we will be using) and let it configure it. See

configuring UARTs

for details but for now, just follow the instructions below. Note that for the primary UART (which I think this is), the documentation says that TX is GPIO 14 which is pin 8 on the the GPIO header, and RX is GPIO 15 which is pin 10. So to enable, I did this:

sudo raspi-config
Then click on "3 Interface Options", then "Serial Port", which might start with "I5" or it might start with "I6", apparently there are variations. After going into "Serial Port", then it asks if you want "Login shell enabled", say NO, but say YES to the next question about enabling the interface. Then exit and reboot (it asks you if you want to and say yes).

To check it worked:

sudo more /etc/group | grep gpio
It should return:
gpio:x:997:rpi
where rpi is the username.

About the GPIO and 40 pin header: here's some good documentation: GPIO

You can also type

pinout
in a terminal and it shows you the pinouts.

Here is an image of the rpi 3 b GPIO pinout:

Pins are labeled 1-40, pin 1 is upper left in the photo. To hook up the UART, you need a ground at pin 6, then the TX at 8 and the RX at 10.

Pi-Apps

Pi-Apps is a nice interface to get some standard RPi applications. To install, go to pi-apps.io, or just use this one:

wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/install | bash
and copy and paste the wget command in a terminal and run it. It then adds a "Pi-Apps" to the desktop. Click on that, it will ask you what you want to do with it, click on "Execute in Termina". It brings up a palette. What I installed is minimal: click on "Internet", then "Browsers", then "Puffin". It brings up another window, click on "Install". Puffin runs much faster than Chrome, which runs pretty slow actually. When that's done, click on "Back" twice, go back to the main window, then click on "Programming" and scroll down and click on "Sublime Text", which is a pretty good editory (although there's a built-in editor called geany that works fine, just not as good).
All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without prior written permission, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. Unless indicated otherwise, any lecture handouts, exams, homework and exam solutions, and the lectures themselves (including audio and video recordings) are copyrighted by me and may not be distributed or reproduced for anything other than your personal use without my written permission. Last updated September, 2024 Drew Baden