Raspberry Pi Essentials


Powering Your RPi

You can power your RPi via the provided power supply or via a USB cable from your laptop. If you use an USB cable, make sure that it has a Micro-USB connector for the RPi (the "regular" USB-A ports cannot be used to power on the RPi). Also make sure you can connect the USB cable to your laptop (e.g., on recent Mac laptops, you will need a USB-C connector).

Connecting Your RPi to Your Laptop

The RPi comes with an HDMI cable and you can connect your RPi directly to a monitor (and a USB keyboard and mouse to the USB ports). As a first step, in order to properly set up your RPi, connect it to a monitor (using the HDMI port), a keyboard (a USB port), a mouse (a USB port), and the power supply. Make sure the MicroSD card is correctly inserted into the card slot before powering up the RPi. Follow the instructions on the screen to finalize the configuration of your RPi and Raspbian. Once complete, open a terminal (the terminal icon will be in the menu bar on top) and type the following:
sudo su
raspi-config
Go to "interfacing options" and enable "ssh". This will be important to set move files onto your RPi (see below). When we work with the RPi, we will not have monitors, etc., to connect to your RPi and we therefore have to set up an Ethernet connection between your laptop and the RPi (we may also be able to use Wi-Fi, but at the minimum, the Ethernet connection should be set up correctly). Connect the provided Ethernet cable to the RPi and your laptop; not that depending on your laptop type, you may need a USB-to-Ethernet adapter (not provided). On a Mac, go into Settings (Systems Preferences) and activate "Internet Sharing" via the "Thunderbold Bridge" (older models may use different terminology or ports). When you power up the RPi with the Ethernet cable connected between your Mac and the RPi, the connection should activate itself. You should see a connection in your Network settings (e.g., USB 10/100/1000 LAN or Thunderbold Ethernet", etc.) with an orange dot, indicating that your Mac has a self-assigned IP address. If not, make sure that "Using DHCP" is selected under "Configure IPv4". On a Windows, it should ideally go a bit smoother, you may not have to do any configurations at all if lucky.

Copying Python Files

Moving files to and from your RPi can be achieved using a secure shell (ssh). On a Mac, ssh (secure shell) and scp (secure copy) are already installed. You just open a terminal and use ssh pi@raspberrypi.local to log into the RPi, scp filename pi@raspberrypi.local:~/ to copy "filename" into your home directory on the RPi (replace ~ with a pathname if desired), and scp pi@raspberrypi.local:~/filename . to copy "filename" from your home directory on the RPi to the current directory on your laptop. Again, you can replace ~ and . with any pathname you want to use. This will allow you to move python scripts and data files between your laptop and the RPi. The first time you should see a security prompt (just answer "Yes") and you will be asked for the password (the default password is "raspberry"). On a Windows computer, you will probably have to install an SSH client, e.g., you can use Bitvise (Putty is another good option). With Bitvise (or Putty) you simply use the GUI to navigate to the directory where your file sits on the left panel and to the destination folder on the RPi on the right panel and then upload the file (and vice versa).

To test if everything is working properly, copy a random file onto the RPi, then ssh into the RPi and delete the file (using the rm filename command). If you have difficulties with any of the steps above, you can consult your colleagues in class, Google Search, Youtube videos, and if all fails, your instructor or TA. If you are not able to get all steps completed before classes begin, don't worry, we'll spend the first lecture time to make sure everybody is able to connect with their RPis.