0% found this document useful (0 votes)
2 views11 pages

Raspberry Pi Notes

The document provides a comprehensive overview of the Raspberry Pi, detailing its history, key features, models, operating systems, applications, and programming capabilities. It highlights the versatility of the Raspberry Pi in educational, industrial, and DIY projects, as well as its hardware specifications and community support. Additionally, it includes practical examples, such as a Python program for blinking an LED and popular Raspberry Pi commands for system management.

Uploaded by

moonswings04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views11 pages

Raspberry Pi Notes

The document provides a comprehensive overview of the Raspberry Pi, detailing its history, key features, models, operating systems, applications, and programming capabilities. It highlights the versatility of the Raspberry Pi in educational, industrial, and DIY projects, as well as its hardware specifications and community support. Additionally, it includes practical examples, such as a Python program for blinking an LED and popular Raspberry Pi commands for system management.

Uploaded by

moonswings04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIT-III Raspberry PI

Raspberry Pi: An In-Depth Overview

The Raspberry Pi is a small, affordable, single board computer developed by the Raspberry
Pi Foundation. It was designed to promote the teaching of computer science and
programming in schools and developing countries. Over time, it has evolved from a tool for
educational use to a versatile platform for DIY projects, industrial applications, and much
more.

Here’s a detailed breakdown of the Raspberry Pi:

1. History and Purpose

The Raspberry Pi was first released in 2012 with the goal of making computer science more
accessible and affordable to people around the world. The Pi aimed to provide a low cost,
basic computer to teach programming and computational thinking. It has since gained
popularity among hobbyists, engineers, and developers for a wide range of applications.

BLOCK DIAGRAM OF RASPBERRY pi

2. Key Features

Each Raspberry Pi board typically includes the following features (varies depending on the
model):

 CPU: ARMbased processors (e.g., Broadcom BCM2837, BCM2711, etc.)


 RAM: Typically 1GB to 8GB depending on the model.
 GPIO Pins: General Purpose Input/Output pins for hardware interfacing, such as
controlling LEDs, motors, or sensors.
 Video Output: HDMI port (with support for up to 4K resolution on newer models
like the Raspberry Pi 4).
 USB Ports: Typically 2 or 4 USB ports, used to connect peripherals like a keyboard,
mouse, or USB storage.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

 Networking: Ethernet port for wired networking (Gigabit on newer models) and
builtin WiFi (starting with Raspberry Pi 3).
 Storage: MicroSD card slot for storing the operating system and files (although newer
models also have eMMC support).
 Camera Interface: Camera Serial Interface (CSI) for connecting a camera module.
 Display Interface: Display Serial Interface (DSI) for connecting a compatible
display.
 Audio Output: 3.5mm audio jack and support for HDMI audio.
 Power Supply: Typically powered by a 5V USBC or microUSB power supply.

3. Models and Versions

The Raspberry Pi Foundation has released multiple models since 2012, each with different
features and performance:

 Raspberry Pi 1: The first version, released in 2012. It had 256MB or 512MB of


RAM.
 Raspberry Pi 2: Released in 2015, it came with 1GB of RAM and a quad-core ARM
CortexA7 CPU.
 Raspberry Pi 3: Released in 2016 with Wi-Fi and Bluetooth built-in, and 1GB RAM.
 Raspberry Pi 4: Released in 2019 with up to 8GB of RAM, USB 3.0 ports, and 4K
video output.
 Raspberry Pi Zero: A smaller, more affordable variant, often used in compact
projects.
 Raspberry Pi 400: A complete computer built into a keyboard, similar to an all-in-
one PC, powered by a Pi 4.

4. Operating System (OS)

The Raspberry Pi supports various operating systems, the most popular being Raspberry Pi
OS (formerly Raspbian), which is a Debian based Linux distribution designed specifically for
the Pi. However, the Pi can also run other operating systems like:

 Ubuntu: Another popular Linux distro.


 Windows 10 IoT Core: A version of Windows 10 for embedded devices.
 LibreELEC: A lightweight OS for running Kodi, a popular media center software.
 RetroPie: For gaming enthusiasts, RetroPie transforms the Pi into a retro gaming
console.

Operating systems are typically loaded onto a microSD card, which serves as the primary
storage for the system.

5. Uses and Applications

The Raspberry Pi is extremely versatile and has found its way into countless applications:

 Educational Tool: Teaching programming (Python, Scratch, etc.), electronics, and


basic computing skills.
 Home Automation: Control smart home devices like lights, security cameras, and
more.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

 Robotics: Use the GPIO pins and various sensors to build robots.
 Media Center: Use it as a lowcost media center to stream music and videos.
 Web Server: Host a website or web application on the Pi.
 Networking Projects: Pi can be used as a network server, VPN, or firewall.
 IoT Projects: Create Internet of Things (IoT) devices for monitoring or automation.
 Gaming: Set up retro gaming emulators (RetroPie) or even run lightweight games.

6. Software and Development

Programming on the Raspberry Pi can be done in several languages, with Python being the
most commonly used due to its simplicity and the large number of libraries available for
interacting with the Pi's hardware.

Some tools and environments to use with the Raspberry Pi:

 Thonny IDE: A Python editor that is beginnerfriendly.


 Scratch: A visual programming language for beginners.
 Pi GPIO Library: A Python library to interact with the GPIO pins.
 NodeRED: A flowbased development tool for wiring together hardware devices,
APIs, and online services.

7. Networking and Connectivity

 WiFi: The Raspberry Pi 3 and 4 have builtin WiFi, allowing for easy wireless
networking.
 Ethernet: For reliable, fast networking, particularly with the Raspberry Pi 4, which
has Gigabit Ethernet.
 Bluetooth: Supported in the Raspberry Pi 3 and 4, useful for connecting devices like
headphones, keyboards, or even controlling other hardware wirelessly.

8. Community and Ecosystem

The Raspberry Pi has a large, active community that contributes tutorials, software, and
hardware projects. Resources for the Pi are readily available, from official documentation to
forums, YouTube tutorials, and books. The ecosystem includes accessories like:

 HATs (Hardware Attached on Top): Expansion boards that provide additional


functionality, such as motor control or additional sensors.
 Cameras: Official Raspberry Pi Camera Modules for photography or video
streaming.
 Displays: Small LCD or touchscreen displays.
 Cases: Protective cases to house the Raspberry Pi.

9. Power Supply

The Pi typically requires a stable 5V power supply, with newer models using USBC (for
Raspberry Pi 4) or microUSB (for earlier models). Powering the Pi is crucial, as unstable or
underpowered conditions can lead to system crashes or instability.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

10. Challenges and Limitations

 Performance: While powerful for its size, the Raspberry Pi is not as fast as a desktop
PC. Tasks like video editing or highperformance gaming are generally not suitable for
the Pi.
 Storage: Dependent on the microSD card for storage, which is slower compared to
solidstate drives (SSD) or hard drives.
 Limited I/O: Although it has GPIO pins for hardware interfacing, the Pi’s number of
USB ports, network connectivity, and video outputs is limited compared to a
fullfledged PC.

Blinking of an LED program using Raspberry Pi


Below is a Python program for blinking an LED on a Raspberry Pi using the GPIO pins. This
example assumes you're using a Raspberry Pi (e.g., Model 4) with Raspberry Pi OS, an LED
connected to a GPIO pin (e.g., GPIO 18), and a resistor (e.g., 220–330 ohms) to limit current.
The program uses the `RPi.GPIO` library to control the LED, making it blink on and off
every second.
Prerequisites:
Hardware Setup:
 Connect the LED’s anode (longer leg) to GPIO 18 (pin 12 on the 40pin header).
 Connect the cathode (shorter leg) to ground (e.g., pin 6) via a resistor.
 Ensure the Raspberry Pi is powered and running Raspberry Pi OS.
Software:
 Install `RPi.GPIO` if not already present: `sudo pip3 install RPi.GPIO`.
 Run the script with `sudo` since GPIO access requires root privileges.

Program Explanation:
 The script sets up GPIO 18 as an output pin.
 It enters a loop to turn the LED on and off every second.
 A `try`/`except` block handles graceful exit (e.g., Ctrl+C) and cleans up GPIO
settings.

How to Run:
1. Save the code to a file, e.g., `blink_led.py`.
2. Open a terminal on the Raspberry Pi.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

3. Navigate to the file’s directory.


4. Run the script: `sudo python3 blink_led.py`.
5. The LED should blink every second, and the terminal will print "LED ON" and "LED
OFF".
6. Press Ctrl+C to stop the program, which will clean up GPIO settings.

PROGRAM
import RPi.GPIO as GPIO

import time

# Set up GPIO mode to BCM numbering


#General purpose Input/Output
GPIO.setmode(GPIO.BCM)

# Define the GPIO pin connected to the LED


LED_PIN = 18

# Set up the GPIO pin as output


GPIO.setup(LED_PIN, GPIO.OUT)

try:
while True:
# Turn LED on
GPIO.output(LED_PIN, GPIO.HIGH)
print("LED ON")
time.sleep(1) # Wait for 1 second

# Turn LED off


GPIO.output(LED_PIN, GPIO.LOW)
print("LED OFF")
time.sleep(1) # Wait for 1 second

except KeyboardInterrupt:
print("\nProgram terminated by user")
finally:
# Clean up GPIO settings
GPIO.cleanup()
print("GPIO cleaned up")
Notes:
 GPIO Mode: The script uses BCM numbering (GPIO 18). If you prefer BOARD
numbering (pin 12), change `GPIO.setmode(GPIO.BCM)` to
`GPIO.setmode(GPIO.BOARD)` and adjust `LED_PIN = 12`.
 Safety: Always use a resistor with the LED to prevent damage. Check your LED’s
forward voltage and current rating.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

Troubleshooting:
 If the LED doesn’t blink, verify connections, ensure the LED is oriented correctly,
and confirm `RPi.GPIO` is installed.
 Run `sudo raspigpio get 18` to check the pin’s state.
 Customization: Adjust `time.sleep(1)` to change the blink rate (e.g., `0.5` for faster
blinking).
 If you want a different GPIO pin or additional features (e.g., multiple LEDs), let me
know, and I can modify the code.

Popular commands of Raspberry PI:


Below is a list of popular Raspberry Pi commands, commonly used in the Raspberry Pi OS
(based on Debian Linux), along with their descriptions. These commands are executed in the
terminal and are essential for managing and configuring a Raspberry Pi system.

System Information and Monitoring


1. uname -a
- Description: Displays detailed system information, including the kernel version,
hostname, and architecture (e.g., arm for Raspberry Pi).
- Example: `uname -a` might output `Linux raspberrypi 5.15.32-v7l+ #1538 SMP Tue Mar
15 15:27:01 GMT 2022 armv7l GNU/Linux`.
2. cat /proc/cpuinfo
- Description: Shows processor details, such as model, number of cores, and hardware
revision of the Raspberry Pi.
- Example: Use to identify the specific Raspberry Pi model (e.g., Raspberry Pi 4 Model B).
3. vcgencmd measure_temp
- Description: Displays the CPU/GPU temperature of the Raspberry Pi in Celsius.
- Example: `vcgencmd measure_temp` might output `temp=45.2'C`.
4. free -h
- Description: Shows memory usage (RAM) in a human-readable format, including total,
used, and free memory.
- Example: `free -h` displays memory stats like `total: 3.8GiB, used: 1.2GiB, free: 2.6GiB`.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

5. df -h
- Description: Displays disk space usage for mounted filesystems in a human-readable
format.
- Example: `df -h` shows available and used space on the SD card or external drives.
Package Management
6. sudo apt update
- Description: Updates the package lists for upgrades and new package installations from
the repositories.
- Example: Run before installing or upgrading software to ensure the latest package
information.

7. sudo apt upgrade


- Description: Upgrades all installed packages to their latest versions.
- Example: `sudo apt upgrade` installs available updates for the system and applications.
8. sudo apt install <package_name>
- Description: Installs a specified package and its dependencies.
- Example: `sudo apt install vim` installs the Vim text editor.
9. sudo apt remove <package_name>
- Description: Removes a specified package but leaves configuration files behind.
- Example: `sudo apt remove vim` uninstalls Vim.

File and Directory Management


10. ls
- Description: Lists files and directories in the current directory.
- Example: `ls -l` provides a detailed list with permissions, ownership, and timestamps.
11. cd <directory>
- Description: Changes the current working directory.
- Example: `cd /home/pi/Documents` navigates to the Documents folder.
12. mkdir <directory_name>
- Description: Creates a new directory.
- Example: `mkdir my_project` creates a directory named `my_project`.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

13. rm <file_or_directory>
- Description: Deletes files or directories. Use `-r` for recursive deletion of directories.
- Example: `rm -r old_project` deletes the `old_project` directory and its contents.
14. cp <source> <destination>
- Description: Copies files or directories. Use `-r` for recursive copying of directories.
- Example: `cp file.txt /home/pi/backup/` copies `file.txt` to the backup folder.
15. mv <source> <destination>
- Description: Moves or renames files or directories.
- Example: `mv file.txt new_file.txt` renames `file.txt` to `new_file.txt`.

System Configuration
16. sudo raspi-config
- Description: Opens the Raspberry Pi configuration tool to set up system options like boot
settings, network, and overclocking.
- Example: Use to enable SSH, VNC, or expand the filesystem.
17. sudo passwd
- Description: Changes the password for the current user (default is `pi`).
- Example: Run to secure the default user account.
18. sudo hostnamectl set-hostname <new_hostname>
- Description: Changes the hostname of the Raspberry Pi.
- Example: `sudo hostnamectl set-hostname mypi` sets the hostname to `mypi`.

Network Management
19. ifconfig or ip a
- Description: Displays network interface information, such as IP addresses for Ethernet
(`eth0`) or Wi-Fi (`wlan0`).
- Example: `ip a` shows active network interfaces and their configurations.
20. ping <hostname_or_ip>
- Description: Tests network connectivity to a host or IP address.
- Example: `ping 8.8.8.8` checks connectivity to Google’s DNS server.
21. sudo systemctl restart networking

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

- Description: Restarts network services to apply changes to network settings.


- Example: Used after modifying Wi-Fi settings in
`/etc/wpa_supplicant/wpa_supplicant.conf`.

Process Management
22. top or htop
- Description: Displays real-time system processes, CPU, and memory usage. (`htop` is
more user-friendly but may need installation via `sudo apt install htop`).
- Example: Use to monitor running applications and system load.

23. ps aux
- Description: Lists all running processes with detailed information.
- Example: `ps aux | grep python` finds all Python processes.
24. kill <pid> or killall <process_name>
- Description: Terminates a process by its process ID (`pid`) or name. Use `sudo` if
needed.
- Example: `kill 1234` stops the process with PID 1234; `killall python` stops all Python
processes.

System Control
25. sudo reboot
- Description: Reboots the Raspberry Pi.
- Example: Used after installing updates or changing system settings.
26. sudo shutdown -h now
- Description: Shuts down the Raspberry Pi immediately.
- Example: Safely powers off the system to avoid SD card corruption.
27. sudo systemctl <start|stop|restart> <service>
- Description: Manages system services (e.g., SSH, Apache).
- Example: `sudo systemctl start ssh` starts the SSH service.

GPIO and Hardware Control

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

28. gpio readall


- Description: Displays the status of all GPIO pins (requires `wiringpi` package, install via
`sudo apt install wiringpi`).
- Example: Useful for debugging GPIO-based projects like LED circuits.
29. vcgencmd display_power 0|1
- Description: Turns the HDMI display output off (`0`) or on (`1`).
- Example: `vcgencmd display_power 0` disables HDMI to save power.

File Editing
30. nano <filename>
- Description: Opens a file in the Nano text editor for editing.
- Example: `nano /etc/wpa_supplicant/wpa_supplicant.conf` to edit Wi-Fi settings.
31. cat <filename>
- Description: Displays the contents of a file.
- Example: `cat /etc/hostname` shows the current hostname.

Permissions and Ownership


32. chmod <permissions> <file_or_directory>
- Description: Changes file or directory permissions (e.g., read, write, execute).
- Example: `chmod 755 script.sh` makes `script.sh` executable by the owner and readable
by others.
33. chown <user>:<group> <file_or_directory>
- Description: Changes the owner and group of a file or directory.
- Example: `sudo chown pi:pi /home/pi/myfile` sets `pi` as the owner and group.

Miscellaneous
34. man <command>
- Description: Displays the manual page for a specified command.
- Example: `man ls` shows detailed documentation for the `ls` command.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things


UNIT-III Raspberry PI

35. history
- Description: Lists previously executed commands in the terminal.
- Example: Use to recall and reuse commands.

Notes
- sudo: Many commands require super user privileges, so prepend `sudo` to run them as an
administrator.
- Raspberry Pi OS: These commands assume Raspberry Pi OS (Debian-based). Some may
differ in other Linux distributions.
- Contextual Usage: Commands like `vcgencmd` and `raspi-config` are specific to Raspberry
Pi hardware.

B.Shanmukha Priya, Dept. of AI & ML Fundamentals of internet of Things

You might also like