Raspberry Pi setup

Raspberry Pi setup #

Video omission

Warning! The video above leaves out the step explained below where you enable SSH and set the password. If you get to the login prompt successfully, but the (obsolete) default password doesn’t work, that’s probably why.

Stuff you need (all in your kit) #

  • Raspberry Pi 4
  • micro SD card
  • USB-C power supply
  • USB-serial adapter, AKA a console cable

You may also need a USB card reader, if you don’t have a card slot built into your computer. We have extra adapters that you can borrow to write data to your SD card if needed.

To connect the console cable, look at this diagram.

RPi console cable connection

There are more details about the console cable if you need them in Adafruit’s console cable tutorial. If you want to go deeper on how console cables and terminals work, try the Sparkfun tutorial.

Setup checklist #

  • Install the Raspberry Pi Imager from the Raspberry Pi Software page
  • Plug your microSD card into your computer.
  • In the Imager, set "Raspberry Pi Device" to "Raspberry Pi 4".
  • Choose the image "Raspberry Pi OS (other)" --> "Raspberry Pi OS Lite (64-bit)"
  • Set "Storage" to be your microSD card. You can identify it by its size, which is probably 32 GB.
  • Click "Next" and then "Edit Settings" in the "Use OS Customisation?" pop-up.
  • Enable SSH and set the password for the user pi
  • The moment of truth! Erase the card and write the new OS to the card.
  • Edit config.txt on the microSD card to include on the last line: enable_uart=1
  • Install the SiLabs CP210X USB driver for the console cable. (You won't need this on a newish Mac.
  • Connect the Pi to your laptop with the console cable
  • Put the microSD card in slot of Pi
  • Install PuTTY (Windows) or open Applications > Utilities > Terminal (macOS) or install Serial (macOS)
  • (macOS only) In Terminal, run ls /dev and find the entry that says tty.usbserial-XXYYZZ. Record the numbers you see instead of XXYYZZ. Then run screen /dev/tty.usbserial-XXYYZ 115200
  • (macOS only) If using Serial instead of Terminal, simply open Serial and double click on the USB-serial device that appears
  • (Windows only) In PuTTY, start a serial session at 115200 bps to the Pi
  • Connect USB-C power cable. Wait a minute or so for the Pi to boot up
  • Log in with username pi and password you set using the Imager
  • Follow the steps below for connecting to the Tufts_Wireless network.

Checklist for Tufts_Wireless #

  • Figure out the Pi's MAC address with ifconfig. Be sure you get the MAC for wlan0, not eth0. The MAC address is something like e4:5f:01:3b:33:fb and appears after the word ether.
  • Register that MAC address with Tufts IT at the Tufts registration page. If using Chrome, you'll probably need to use an Incognito window
  • Wait a few minutes for MAC address permissions to propagate to local wireless access point
  • Use sudo raspi-config to list Tufts_Wireless as the network.
  • In raspi-config, pick System Options > Wireless LAN
  • Enter Tufts_Wireless for the SSID and leave the passphrase blank.
  • Exit raspi-config. Use the `ifconfig` or `hostname -I` command to find the IP address assigned to your Pi by Tufts_Wireless.
  • Type `logout` to disconnect your Terminal from your Pi so that you can switch to logging in via SSH.

Connecting to your Pi via SSH instead of serial #

Once you have your Pi connected to the wireless network, you can log into it through SSH instead of through a USB-serial cable.

  • Have your Pi’s IP address handy (do that when still connected by serial cable; use the ifconfig or hostname -I command).
  • Make sure your Pi is plugged into power. Do not attach the serial console cable.
  • Open a new terminal window.
  • Type ssh your_Pi_username@ip_address_of_your_Pi
  • You should be prompted for your Pi’s password, and then you should be logged in! No serial cable necessary!

Setup for Tufts_Secure #

Not needed if your Pi is already connected to Tufts_Wireless

Use the Nano text editor (opened within the Terminal window) to edit the file at /etc/wpa_supplicant/wpa_supplicant.conf.

  • To open this file in the Nano text editor, type the command sudo nano /etc/wpa_supplicant/wpa_supplicant.conf into the Terminal window where you’ve logged into your Pi.
  • The sudo part sets you as a “super user” with permission to edit the file. Add the text from the gray box below - with the password inserted - to the wpa_supplicant.conf file.
  • Ask an instructor or LA or friend for the Nolop_IOT password; we try to avoid publishing passwords on the internet.
  • The purpose of the text below is to tell your Raspberry Pi to log into the Tufts_Secure network under the username “Nolop_IOT,” which the Tufts IT department created just for class purposes like this one. It is okay for many users to be logged in under this Tufts_Secure account.
  • After you’ve edited the wpa_supplicant.conf file, when you next boot up your Pi, it should log in to Tufts_Secure and be given an IP address. Type hostname -I to print the IP address of your Pi.

Network settings for Tufts_Secure #


What the Imager should look like #

Raspberry Pi Imager OS selection

The OS customization options you should pick #

Make sure you set the password for the user pi. You should probably write it down somewhere else too.

You should also enable SSH, but you could also do that later with the command sudo raspi-config.

Raspberry Pi Imager options


How do I turn off my Pi? #

Type the command sudo shutdown

Is there a way to change my login password when I’m already logged in to my Pi? #

You can change some of your Pi’s settings, including its password, with the Raspi-Config application. To run it, type the command sudo raspi-config

What operating system should I use on my Pi? #

Unless you have a good reason not to, you should start with the Lite version of Raspberry Pi OS. The Raspberry Pi imager will download it for you. Previously called Raspbian, the OS should be based on Debian Buster or newer (as older versions will not work with a Pi 4).

How do I figure out what name is assigned to the USB-serial adapter when I plug it in? #

On Windows 10, it’s usually COM3 (but it is not uncommon to have a different number). You can check for sure in the Device Manager control panel under Ports (COM & LPT)

On macOS, it’s called /dev/tty.usbserial-123456, but the numbers at the end change. You can check it by running ls /dev in Terminal.

On Linux it’s called /dev/ttyACM0, but the number will depend on how many USB devices are plugged in. As with macOS, you can check by running ls /dev in Terminal.

When I open config.txt with Notepad, the lines all run together. How do I fix this? #

Use a better text editor, like Sublime Text, Textmate, or Notepad++. You could also try Wordpad.

What do the pin numbers correspond to? #

All the most recent Pi’s share a standard pin format. Below is a handy guide. This site is also an excellent resource for reference.

RPi pinout

Tutorials from the Raspberry Pi Foundation on using the GPIO pins: