Raspberry Pi Introduction

Repository for the raspberry lessons

Raspberry Pi Introduction

Welcome! The Raspberry Pi (RPi) is a great tool to empower your creativity. Discover the multiple possibilities this single board computer brings to you.

Interactive link https://doc.clickup.com/36177258/d/h/12g1ba-160/beb602325a60716

Compare boards

You could use the following table to quickly compare two versions of the RPi.

Raspberry Pi 3 Model B Raspberry Pi 4 Model B
Broadcom BCM2837 Broadcom BCM2711
Quad-Core 64bit @ 1.2GHz Quad-core 64bit @ 1.5GHz
Cortex A53 (ARM v8) Cortex A72 (ARM v8)
1GB LPDDR2 SDRAM 2GB, 4GB or 8GB LPDDR4
100 Base Ethernet Gigabit Ethernet
Official page Official page

Terminology

Pin-out

A great advantage about RPi is that you can interact with the hardware. Also, consider using a hat for this purpose.

Friendly orientation

The image is of the RPi 3, but it applies to the RPi 4. More details https://medium.com/youngwonks/raspberry-pi-3-pinout-50b904ed41f0

Interactive guide

More details https://pinout.xyz/

# https://gpiozero.readthedocs.io/en/stable/installing.html
sudo apt update
sudo apt install python3-gpiozero
pinout

Other considerations

Take note of the white pins. More details https://projects.raspberrypi.org/en/projects/physical-computing/1

For older versions

Setup

Requirements

Basic elements

There are two options; please make sure to have one of the following options.

  1. External monitor option
    1. HDMI monitor
    2. HDMI cable
    3. USB keyboard
  2. Ethernet cable option
    1. Ethernet Cable
    2. A computer with an RJ45 port

Installation Steps

  1. Download Raspberry Pi Imager

  1. Install the application. Use default options
  2. Open Raspberry Pi Imager
  3. Choose Raspberry Pi OS (other) > Raspberry Pi OS Lite(64-bit)

  1. Select your SD as storage

  1. Click on Gear Icon ⚙️
  2. Use the following values.
    • Disable overscan
    • Set hostname
    • Enable SSH
      • Use password authentication
      • Allow public-key authentication only
    • Set username and password
      • Username: pi
      • Password: raspberry
    • Configure wifi
    • Set locale settings
    • Play sound when finished
    • Eject media when finished
    • Enable telemetry
  3. Click on WRITE > YES

Login instructions

Get the ip of the raspberry from the powershell ping raspberrypi.local -4

  1. Connect the external devices
    1. Option A: Connect a keyboard, power, and monitor
    2. Option B: Connect ethernet to your computer and power
      1. Open a PowerShell
      2. Install 64-but x86 PuTTY with default options
      3. Open PuTTY
      4. Set Host Name raspberrypi.local
      5. Connection type ssh
      6. Click on Save and then Open
      7. Click on Accept in the Security Alert
  2. Set credentials
    1. raspberrypi login (login as): pi
    2. Password: raspberry
  3. Optional, turn off the RPi shutdown now

You can also connect via ssh pi@raspberrypi.local

Wi-Fi instructions

  1. Set country code ISO 3166-1
sudo raspi-config nonint do_wifi_country MX
  1. Open the wpa_supplicant.conf, the purpose is to use this file to configure your Wi-Fi connections. This process is similar when you put the connections on your smartphone
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
  1. f

  2. Add network configuration

Wireless network wpa_passphrase "network_name"

network={
  ssid="network_name"
  scan_ssid=1
  psk=e647e6a0df46537ad98c7687fa75fa33f0e0489f80fec9ed0180058647724073
}

PEAP network echo -n "plaintext_password" | iconv -t utf16le | openssl md4

network={
  ssid="<<network_name>>"
  priority=1
  proto=RSN
  key_mgmt=WPA-EAP
  pairwise=CCMP
  auth_alg=OPEN
  eap=PEAP
  identity="<<user_name>>"
  password=hash:<<the_hash>>
  phase1="peaplabel=0"
  phase2="auth=MSCHAPV2"
}
  1. Apply changes
sudo reboot

Switch a LED

  1. Open a python shell
python
  1. Declare LED
from gpiozero import LED
led = LED(14)
  1. Turn on LED
led.on()
  1. Turn off LED
led.off()
  1. Exit
exit()

VSCode setup

  1. Download VS Code
  2. Install Remote SSH Extension
  3. Add ssh project
  4. Open workspace folder
  5. Run python scripts as python blink_simple.py

Node-RED installation

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Then you can start the service with

node-red-start

More details at https://nodered.org/docs/getting-started/raspberrypi

Other resources

https://github.com/raspberrypilearning/physical-computing-guide/blob/master/pull_up_down.md

https://gpiozero.readthedocs.io/en/stable/

System monitor

htop