🔐 Login
📝 Sign Up
🔑 Forgot Password

Welcome Back!

Enter your credentials to continue

Create Account

Join our secure network

Recovery

Reset your password via email

Raspberry Pi 5 Overview

The Raspberry Pi 5 is the next-generation flagship single-board computer from the Raspberry Pi Foundation, offering enhanced performance, more connectivity options, and improved power efficiency compared to the Pi 4.

Key Specifications
  • Processor: Broadcom BCM2712 (Quad-core ARM Cortex-A76 @ 2.5 GHz)
  • RAM: 4GB, 8GB LPDDR5
  • Storage: microSD slot (supports faster UHS-I cards)
  • Video Output: 2 × micro-HDMI (up to 8K at 60Hz)
  • USB Ports: 2 × USB 3.0, 2 × USB 2.0
  • Networking: Gigabit Ethernet
  • Wireless: WiFi 6 (802.11ax), Bluetooth 5.0
  • GPIO: 40-pin header, with more I/O pins on Pi 5 variant
  • Power: USB-C (5V, 3A)
  • Additional Features: Enhanced camera interface, PCIe support, dual-camera support
Raspberry Pi 5 Images
Raspberry Pi 5 board top view

Image: Simon Waldherr / Wikimedia Commons, CC BY‑SA 4.0

Raspberry Pi 5 board back view

Image: Simon Waldherr / Wikimedia Commons, CC BY‑SA 4.0

More info: Raspberry Pi 5 – Official Site

Raspberry Pi 500 Overview

The Raspberry Pi 500 is an integrated all-in-one keyboard computer featuring similar core performance as the Pi 4 but in a compact keyboard form factor, designed for office, industrial, and educational use.

Key Specifications
  • Processor: Broadcom BCM2711 (Quad-core ARM Cortex-A72 @ 2.0 GHz)
  • RAM: 4GB, 8GB LPDDR4
  • Storage: microSD slot or eMMC
  • Video Output: Dual 4K via HDMI
  • USB Ports: 2 × USB 3.0, 2 × USB 2.0
  • Networking: Gigabit Ethernet
  • Wireless: WiFi 5 (802.11ac), Bluetooth 5.0
  • GPIO: 40-pin header
  • Power: USB-C (5V, 3A)
Raspberry Pi 500 Images
Raspberry Pi 500 keyboard‑computer

Image attribution: ensure proper license

More info: Raspberry Pi 500 – Official Site

Performance Enhancements
  • Faster ARM Cortex-A76 processor, up to 50% faster than Pi 4.
  • WiFi 6 and Bluetooth 5.0 support.
  • Improved GPU supporting 8K video output.
Applications
  • AI, machine learning, and deep learning.
  • 4K and 8K video streaming.
  • Edge computing and industrial IoT solutions.
  • Media and entertainment systems.
Related Links
Raspberry Pi 5 Compute Module Overview

The Raspberry Pi 5 Compute Module is designed for embedded and industrial applications, offering enhanced flexibility, processing power, and more GPIO pins than the standard Pi 5.

Key Specifications
  • Processor: Broadcom BCM2712 (Quad-core ARM Cortex-A76 @ 2.5 GHz)
  • RAM: 4GB, 8GB LPDDR5
  • Storage: eMMC (8GB, 16GB, 32GB) or Lite with microSD
  • Networking: Gigabit Ethernet via carrier board
  • USB: USB 2.0 (expandable via carrier board)
  • PCIe: 1 × PCIe Gen 2 lane
  • GPIO: 200-pin connector with extra GPIO pins
  • Power: 5V DC via carrier board
Raspberry Pi 5 Compute Module Image
Raspberry Pi 5 Compute Module

Raspberry Pi 5 Compute Module

Raspberry Pi 5 Compute Module I/O board Image
Raspberry Pi 5 Compute Module

Raspberry Pi 5 Compute Module I/O board

Key Features
  • Enhanced flexibility and I/O options
  • RAM up to 8GB and faster CPU
  • PCIe for peripherals
  • Ideal for industrial automation and robotics
Applications
  • Embedded industrial systems
  • Custom electronics and robotics
  • High-performance field data processing
Related Links
I2C on Raspberry Pi

Overview

I2C (Inter-Integrated Circuit) is a popular communication protocol for connecting low-speed devices like sensors, displays, and EEPROMs. The Raspberry Pi provides native support for I2C communication, which can be easily enabled and used for a variety of projects.

Enabling I2C on Raspberry Pi

To use I2C on the Raspberry Pi, you'll first need to enable it in the Raspberry Pi's configuration settings. Follow these steps:

  • Open the terminal on your Raspberry Pi and run: sudo raspi-config.
  • Navigate to Interfacing Options > I2C and enable it.
  • Reboot your Raspberry Pi for the changes to take effect.

Once I2C is enabled, you can use the i2c-tools package to interact with I2C devices. To install it, run:

sudo apt-get install i2c-tools
Connecting I2C Devices

Raspberry Pi has two I2C bus interfaces available. The default I2C bus is typically on the GPIO pins 3 (SDA) and 5 (SCL). Connect any I2C-enabled device to these pins, ensuring correct voltage levels and pull-up resistors.

  • SDA (Data) - GPIO Pin 3
  • SCL (Clock) - GPIO Pin 5
  • GND - Ground

After connecting an I2C device, detect it with:

sudo i2cdetect -y 1

This will show a map of I2C devices connected to your Raspberry Pi.

Using I2C with Python

To communicate with I2C devices, you can use Python libraries such as smbus. Here's an example of how to use I2C with Python to read data from an I2C sensor:

import smbus
bus = smbus.SMBus(1)  # Initialize I2C bus 1
address = 0x48        # I2C address of the device

# Reading a byte from a register (example)
data = bus.read_byte_data(address, 0x00)
print(data)
I²S (Inter-IC Sound) on Raspberry Pi

I²S is a synchronous digital audio interface used to connect external DACs, ADCs, and audio codecs. On Raspberry Pi, I²S is provided by the SoC PCM peripheral and is routed to the GPIO header for external use.

Raspberry Pi Models with External I²S
  • Raspberry Pi Zero / Zero W / Zero 2 W
  • Raspberry Pi 1 Model A+ / B+
  • Raspberry Pi 2 Model B
  • Raspberry Pi 3 Model B / B+
  • Raspberry Pi 4 Model B
  • Raspberry Pi 5
  • Compute Module 1 / 3 / 3+ / 4 (via carrier board)
I²S GPIO Pins (40-pin Header)

The following GPIO pins are used for I²S on Raspberry Pi:

  • GPIO18 (Pin 12) — Bit Clock (BCLK / PCM_CLK)
  • GPIO19 (Pin 35) — Word Select (LRCLK / PCM_FS)
  • GPIO20 (Pin 38) — Data In (DIN)
  • GPIO21 (Pin 40) — Data Out (DOUT)

Ground can be taken from any GND pin (e.g. Pin 6).

Enabling I²S in Raspberry Pi OS

Edit /boot/config.txt and add the following lines:


# Disable onboard analog audio
dtparam=audio=off

# Enable I2S / PCM interface
dtparam=i2s=on

# Optional: load an I2S DAC overlay
# dtoverlay=hifiberry-dac
      

Reboot after saving. The I²S device will then be available via ALSA.

SPI on Raspberry Pi

SPI (Serial Peripheral Interface) is a high-speed communication protocol used for connecting peripherals like sensors, displays, and memory chips. Raspberry Pi supports SPI communication for fast data transfer.

Enabling SPI on Raspberry Pi

To enable SPI, activate it through the Raspberry Pi configuration settings:

  • Open the terminal and run: sudo raspi-config.
  • Navigate to Interfacing Options > SPI and enable it.
  • Reboot your Raspberry Pi for the settings to take effect.

Check if SPI is enabled by running:

lsmod | grep spi
SPI Pinout

SPI communication on the Raspberry Pi uses the following pins:

  • CE0 (Chip Enable) - GPIO Pin 8
  • CE1 (Chip Enable) - GPIO Pin 7
  • CLK (Clock) - GPIO Pin 11
  • MISO (Master In Slave Out) - GPIO Pin 9
  • MOSI (Master Out Slave In) - GPIO Pin 10
  • GND - Ground
Using SPI with Python

The spidev library in Python allows communication with SPI devices. Example usage:


import spidev

spi = spidev.SpiDev()
spi.open(0, 0)  # Open SPI bus 0, device 0
spi.max_speed_hz = 50000  # Set the clock speed

# Send and receive data
response = spi.xfer2([0x01, 0x02, 0x03])
print(response)
        
Timers & PWM on Raspberry Pi

Raspberry Pi supports hardware timers and Pulse Width Modulation (PWM), essential for controlling motors, LEDs, and other components that require precise timing or signal modulation.

Timers on Raspberry Pi

The Raspberry Pi has multiple timers for precise time management, accessible via Python libraries like RPi.GPIO or pigpio. They are useful for scheduling tasks or triggering events at regular intervals.

Common uses include:

  • Generating periodic interrupts.
  • Running time-sensitive tasks like data logging or event-based actions.

PWM on Raspberry Pi

Pulse Width Modulation (PWM) allows control of power to devices like LEDs and motors. Raspberry Pi supports PWM on several GPIO pins.

  • Use RPi.GPIO to configure a GPIO pin for PWM.
  • Set the frequency of the PWM signal.
  • Adjust the duty cycle to control power output.

Example: Generate PWM with Python


import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)

pwm = GPIO.PWM(18, 1000)  # Pin 18, frequency 1 kHz
pwm.start(50)  # 50% duty cycle

# Change duty cycle after 5 seconds
pwm.ChangeDutyCycle(75)
      
Serial Communication on Raspberry Pi

Serial communication allows the Raspberry Pi to communicate with other devices like sensors, modules, and microcontrollers over a serial link. It is commonly used for debugging, interfacing with peripherals, or controlling other systems.

Enabling Serial on Raspberry Pi

By default, the serial interface on the Raspberry Pi is disabled. To enable it:

  • Open the terminal and run: sudo raspi-config.
  • Navigate to Interfacing Options > Serial and disable the shell interface, but enable the serial port hardware.
  • Reboot your Raspberry Pi.
Using Serial with Python

The pyserial library is commonly used for serial communication in Python. Install it using:

sudo apt-get install python3-serial

Example of using serial communication:


import serial

ser = serial.Serial('/dev/ttyAMA0', 9600)  # Open serial port at 9600 baud rate

# Write to serial
ser.write(b'Hello, Raspberry Pi!')

# Read from serial
data = ser.readline()
print(data)
        
GPIO (General Purpose Input/Output) on Raspberry Pi

The GPIO pins on the Raspberry Pi provide a versatile interface for connecting sensors, actuators, and other external components. With up to 40 GPIO pins available on various models, you can interact with the physical world, controlling LEDs, motors, buttons, and more.

The GPIO pins are connected to the Broadcom SoC and can be configured in software for digital input, digital output, PWM, and communication protocols such as I2C and SPI.

Configuring GPIO Pins
  • Use the RPi.GPIO Python library to configure GPIO pins for input or output.
  • Use the gpiozero Python library for higher-level control with simplified syntax.
Example Code to Blink an LED

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)

while True:
    GPIO.output(17, GPIO.HIGH)
    time.sleep(1)
    GPIO.output(17, GPIO.LOW)
    time.sleep(1)
        
GPIO Interrupts on Raspberry Pi — Overview

Interrupts are a powerful feature of Raspberry Pi's GPIO (General Purpose Input/Output) pins, allowing the Pi to react to events such as changes in input signals. Interrupts enable efficient event handling, letting the Pi act only when needed instead of polling continuously.

What are GPIO Interrupts?

A GPIO interrupt occurs when a GPIO pin changes state. When the trigger condition is met, the Raspberry Pi executes an ISR (interrupt service routine), allowing immediate reaction without wasting CPU time polling.

GPIO Interrupt Types
  • Rising Edge: LOW → HIGH transition
  • Falling Edge: HIGH → LOW transition
  • Both Edges: triggers on any change
  • Level Change: requires software handling
Setting Up GPIO Interrupts

Interrupts require configuring a GPIO pin as input, selecting the interrupt edge type, and defining an ISR to handle the event.

Step-by-Step Setup

  1. Install WiringPi or RPi.GPIO.
  2. Configure the GPIO pin as input.
  3. Specify the interrupt type (rising, falling, or both).
  4. Write the ISR callback.
  5. Enable the interrupt listener.
Python Example Code

Example using RPi.GPIO to configure an interrupt on GPIO 17:


import RPi.GPIO as GPIO
import time

# Set the GPIO mode
GPIO.setmode(GPIO.BCM)

# Define the pin to listen for interrupts
pin = 17

# Setup the pin as an input with a pull-up resistor
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Define the callback function that will be triggered by the interrupt
def gpio_callback(channel):
    print("Interrupt detected on GPIO pin", channel)

# Add an interrupt to GPIO pin 17, looking for a rising edge
GPIO.add_event_detect(pin, GPIO.RISING, callback=gpio_callback)

# Keep the program running to listen for interrupts
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    print("Program terminated")
finally:
    GPIO.cleanup()
        
Using Interrupts for Debouncing

Mechanical switches can generate multiple false triggers. Debouncing prevents this by enforcing a delay between valid events.

Debouncing Example


import RPi.GPIO as GPIO
import time

# Set the GPIO mode
GPIO.setmode(GPIO.BCM)

# Define the pin for the button
button_pin = 17

# Setup the button pin as an input with a pull-up resistor
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Define a debounce delay (in seconds)
debounce_delay = 0.2

# Define the callback function with debounce
def gpio_callback(channel):
    print("Button pressed!")
    time.sleep(debounce_delay)

# Add an event detection on the button pin with a falling edge (button press)
GPIO.add_event_detect(button_pin, GPIO.FALLING, callback=gpio_callback, bouncetime=int(debounce_delay * 1000))

# Keep the program running to listen for interrupts
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    print("Program terminated")
finally:
    GPIO.cleanup()
        
Using Multiple GPIO Interrupts

Multiple pins can be configured to trigger interrupts independently.

Example for Multiple GPIO Interrupts


import RPi.GPIO as GPIO
import time

# Set the GPIO mode
GPIO.setmode(GPIO.BCM)

# Define pins for input
pin1 = 17
pin2 = 18

# Setup the pins as inputs with pull-up resistors
GPIO.setup(pin1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(pin2, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Define the callback function for pin interrupts
def gpio_callback(channel):
    print(f"Interrupt detected on GPIO pin {channel}")

# Add events for multiple pins
GPIO.add_event_detect(pin1, GPIO.RISING, callback=gpio_callback)
GPIO.add_event_detect(pin2, GPIO.RISING, callback=gpio_callback)

# Keep the program running to listen for interrupts
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    print("Program terminated")
finally:
    GPIO.cleanup()
        
GPIO Interrupt Limitations
  • Interrupt Handling Time: CPU load can delay ISR execution.
  • Number of Interrupts: Limited hardware interrupt lines.
  • Timing Accuracy: Not real-time precise; use MCU for hard-timing applications.
Conclusion

GPIO interrupts allow Raspberry Pi to respond instantly to external events, making them essential for buttons, sensors, and real-time signalling applications.

Wi-Fi on Raspberry Pi Boards

Wi-Fi functionality on Raspberry Pi boards enables wireless network connectivity, ideal for IoT, web servers, remote control systems, and other projects requiring internet or local network access. Many Raspberry Pi models come with built-in Wi-Fi, while others can use a USB adapter.

Raspberry Pi Models with Built-in Wi-Fi

Several Raspberry Pi models include integrated Wi-Fi, simplifying wireless networking without additional hardware. These models include:

  • Raspberry Pi 3 Model B/B+
  • Raspberry Pi 4 Model B
  • Raspberry Pi Zero W
  • Raspberry Pi Zero 2 W

These models feature Wi-Fi 802.11n (Wi-Fi 4) for reliable connectivity. The Raspberry Pi 4 supports dual-band 2.4GHz and 5GHz Wi-Fi for faster speeds and better performance in congested networks.

Enabling and Using Wi-Fi on Raspberry Pi

Wi-Fi on Raspberry Pi boards is easy to configure and supported by the wpa_supplicant tool, which handles wireless connections on Linux-based systems.

Getting Started with Wi-Fi

  • Ensure your Raspberry Pi runs a compatible OS like Raspberry Pi OS.
  • Configure Wi-Fi using the GUI (desktop) or via terminal using raspi-config (headless).
  • For headless setups, edit the wpa_supplicant.conf file with network details.

Wi-Fi Use Cases

  • Internet access for web browsing or server connectivity.
  • Running headless projects remotely via SSH or VNC.
  • IoT systems needing internet for data exchange.
  • Setting up wireless hotspots or wireless printers.
Using USB Wi-Fi Adapters

For Raspberry Pi models without built-in Wi-Fi (e.g., Pi 2 or earlier), you can add Wi-Fi functionality with a compatible USB Wi-Fi adapter. These adapters are supported by Raspberry Pi OS and widely available.

Bluetooth on Raspberry Pi Boards

Bluetooth functionality on Raspberry Pi boards enables wireless communication for IoT projects, remote control, and peripheral connectivity. Many Raspberry Pi models have Bluetooth built-in, while others can use USB Bluetooth adapters.

Raspberry Pi Models with Built-in Bluetooth

These Raspberry Pi models include integrated Bluetooth hardware:

  • Raspberry Pi 3 Model B/B+
  • Raspberry Pi 4 Model B
  • Raspberry Pi Zero W
  • Raspberry Pi Zero 2 W

Most models provide Bluetooth 4.2 support, including BLE, suitable for wireless peripherals, audio devices, and sensors.

Enabling and Using Bluetooth on Raspberry Pi

Bluetooth support is provided by the BlueZ stack, enabling interaction with Bluetooth devices through tools such as bluetoothctl.

Getting Started with Bluetooth

  • Verify Bluetooth is enabled in Raspberry Pi Configuration.
  • Use bluetoothctl to pair and manage devices.
  • Install packages such as bluez and pi-bluetooth for extended features.

Common Use Cases

  • Connecting Bluetooth keyboards and mice.
  • Using Bluetooth speakers or audio peripherals.
  • Interfacing with BLE sensors in IoT applications.
Using Bluetooth with Raspberry Pi Zero and Zero W

The Raspberry Pi Zero W and Zero 2 W include integrated Bluetooth 4.2 support, making them ideal for compact IoT and low-power wireless communication projects.

Using USB Bluetooth Adapters

Older Raspberry Pi boards without built-in Bluetooth (such as the Raspberry Pi 2) can use USB Bluetooth adapters. These work with the BlueZ stack and provide the same functionality as integrated Bluetooth.

Camera Support on Raspberry Pi Models

The Raspberry Pi models support various camera modules through the CSI (Camera Serial Interface) port. Below is a description of the camera compatibility for each model.

Raspberry Pi Zero

The Raspberry Pi Zero supports the official Raspberry Pi camera modules through its CSI interface. The camera can be connected using a small ribbon cable. The Zero uses a mini version of the standard CSI connector found on other models.

  • Camera Port: CSI connector (smaller than the standard connector).
  • Camera Compatibility: Official Raspberry Pi Camera Module V1, V2, and HQ Camera.
  • Maximum Resolution: Up to 12MP (HQ Camera).
Raspberry Pi Model B (Original)

The original Raspberry Pi Model B (rev 1 and rev 2) supports the CSI interface for connecting a camera. It was the first model to introduce camera support.

  • Camera Port: Full-size CSI connector (standard 15-pin).
  • Camera Compatibility: Official Raspberry Pi Camera Module V1 and V2.
  • Maximum Resolution: Up to 8MP (Camera Module V2).
Raspberry Pi 2 Model B

The Raspberry Pi 2 Model B also supports the CSI interface, similar to the original Model B, but with improved processing power.

  • Camera Port: Full-size CSI connector (standard 15-pin).
  • Camera Compatibility: Official Raspberry Pi Camera Module V1, V2, and HQ Camera.
  • Maximum Resolution: Up to 12MP (HQ Camera).
Raspberry Pi 3 Model B and B+

The Raspberry Pi 3 Model B and B+ continue to support the CSI interface, and the improved performance allows higher frame rates and more advanced camera uses.

  • Camera Port: Full-size CSI connector (standard 15-pin).
  • Camera Compatibility: Official Camera Module V1, V2, HQ, and supported third-party cameras.
  • Maximum Resolution: Up to 12MP (HQ Camera).
Raspberry Pi 4 Model B

The Raspberry Pi 4 Model B supports the CSI interface and is ideal for high-performance camera projects.

  • Camera Port: Full-size CSI connector (standard 15-pin).
  • Camera Compatibility: Official Camera Module V1, V2, HQ, and some third-party options.
  • Maximum Resolution: Up to 12MP (HQ Camera).
  • Video Capabilities: 4K output via HDMI; suitable for high-definition camera applications.
Raspberry Pi 5 (Upcoming)

The Raspberry Pi 5 is expected to continue supporting the CSI camera interface with possible improvements.

  • Camera Port: Full-size CSI (or improved high-throughput variant).
  • Camera Compatibility: Expected support for Camera Module V1, V2, HQ, and others.
  • Maximum Resolution: Likely 12MP or higher.
  • Video Capabilities: Possibly improved 4K handling.
Camera Software and Commands

All models support the raspistill and raspivid tools for image and video capture.

  • Capture an Image (still photo):
    raspistill -o image.jpg
    This captures an image as "image.jpg".
  • Record Video:
    raspivid -o video.h264 -t 10000
    This records a 10-second video.
  • Enable Camera Module:
    sudo raspi-config
    Enable the camera in “Interface Options”.
Video Connectors (Non-HDMI) on Raspberry Pi Models

Raspberry Pi models support video output through various interfaces, including composite video and the CSI camera interface. HDMI is most common, but alternative outputs exist for legacy or specialized setups.

Raspberry Pi Zero

The Raspberry Pi Zero does not have a native composite video jack. Video output is via HDMI or GPIO pins with an external adapter.

  • Video Output: HDMI (micro-HDMI adapter) or GPIO (requires adapter).
  • Composite Video: Not available natively.
Raspberry Pi Model B (Original)

The original Raspberry Pi Model B (rev 1 and 2) includes a 3.5mm jack for analog audio and RCA socket for composite video.

  • Video Output: Composite RCA.
  • Audio Output: 3.5mm analog stereo.
Raspberry Pi 2 Model B

The Raspberry Pi 2 Model B retains the 3.5mm jack for composite video and analog audio, like the original Model B.

  • Video Output: Composite via 3.5mm jack (shared with audio).
  • Audio Output: 3.5mm analog stereo (shared with composite video).
Raspberry Pi 3 Model B and B+

The Raspberry Pi 3 Model B and B+ maintain the 3.5mm jack for composite video/audio alongside HDMI support.

  • Video Output: Composite via 3.5mm jack (shared with audio).
  • Audio Output: 3.5mm analog stereo (shared with composite video).
Raspberry Pi 4 Model B

The Raspberry Pi 4 Model B has a 3.5mm jack for composite video/audio, alongside HDMI for 4K digital output.

  • Video Output: Composite via 3.5mm jack (shared with audio).
  • Audio Output: 3.5mm analog stereo (shared with composite video).
Raspberry Pi 5 (Upcoming)

The Raspberry Pi 5 is expected to continue offering the 3.5mm jack for composite video/audio alongside HDMI digital output.

  • Video Output: Composite via 3.5mm jack (shared with audio).
  • Audio Output: 3.5mm analog stereo (shared with composite video).
Audio Connectors on Raspberry Pi Models

Raspberry Pi models with audio output support 3.5mm audio jacks or HDMI audio through adapters. The audio connectors vary depending on the model, with some models featuring a dedicated audio jack, while others rely on HDMI or other digital interfaces.

Raspberry Pi Zero

The Raspberry Pi Zero does not have a dedicated 3.5mm audio jack. Audio is available through the HDMI interface or via a GPIO pin using a DAC HAT or external module.

  • Audio Output: HDMI or GPIO (requires DAC HAT).
  • Analog Audio: Not available natively.
Raspberry Pi Model B (Original)

The Raspberry Pi Model B (rev 1 and rev 2) features a 3.5mm audio jack for analog audio output. It supports both audio and composite video output through this jack.

  • Audio Output: 3.5mm audio jack (analog audio and composite video).
  • Supported Formats: Analog stereo output (3.5mm jack).
Raspberry Pi 2 Model B

The Raspberry Pi 2 Model B features a 3.5mm audio jack for analog output along with composite video. HDMI provides digital audio output as well.

  • Audio Output: 3.5mm audio jack (analog) and HDMI (digital audio).
  • Supported Formats: Analog stereo and HDMI digital audio.
Raspberry Pi 3 Model B and B+

The Raspberry Pi 3 Model B and B+ continue to offer the 3.5mm audio jack for analog audio, alongside HDMI digital audio output. Improved processing power allows better handling of digital audio.

  • Audio Output: 3.5mm audio jack (analog) and HDMI (digital audio).
  • Supported Formats: Analog stereo and HDMI digital audio.
Raspberry Pi 4 Model B

The Raspberry Pi 4 Model B includes a 3.5mm audio jack for analog output and digital audio via HDMI. Audio quality is improved, supporting better digital audio output.

  • Audio Output: 3.5mm audio jack (analog) and HDMI (digital audio).
  • Supported Formats: Analog stereo and HDMI digital audio.
Raspberry Pi 5 (Upcoming)

The Raspberry Pi 5 is expected to provide a 3.5mm audio jack for analog output and digital audio via HDMI, with potential improvements in quality and formats.

  • Audio Output: 3.5mm audio jack (analog) and HDMI (digital audio).
  • Supported Formats: Analog stereo and HDMI digital audio.
USB OTG and Gadget Mode on Raspberry Pi

USB On-The-Go (OTG) and Gadget Mode allow Raspberry Pi boards to act as USB devices, enabling them to function as network adapters, mass storage devices, serial devices, and even multiple devices at once. This is particularly useful for Raspberry Pi models that have USB OTG support, such as the Pi Zero and Pi Zero 2, but it also works on other Pi models under specific configurations.

By enabling USB OTG and Gadget Mode, you can turn your Raspberry Pi into a USB device such as:

  • USB Network Device: Transform your Pi into a network device, allowing it to be used as a network interface between a PC and the Raspberry Pi.
  • Mass Storage Device: Use your Pi to emulate a USB disk drive, allowing files to be transferred between your Pi and a host PC.
  • Serial Device: Use the Pi as a serial device for communication with a host computer, similar to a USB-to-serial adapter.
  • Audio Device: Raspberry Pi can also emulate an audio device, such as a USB sound card.
Models That Support USB OTG and Gadget Mode
  • Raspberry Pi Zero: Micro-USB OTG port for USB device functionality.
  • Raspberry Pi Zero W: Supports USB OTG and includes Wi-Fi.
  • Raspberry Pi Zero 2 W: USB OTG and gadget mode capable.
  • Raspberry Pi 4 (USB-C OTG mode): Requires configuration via USB-C port.
  • Raspberry Pi 400: USB gadget mode via USB-C with configuration.
Setting Up USB Gadget Mode for Multiple Gadgets

Enable multiple USB gadgets simultaneously to serve as network adapter, mass storage, serial, and optionally audio devices.

  1. Insert SD card and navigate to
    /boot
  2. Edit
    /boot/config.txt
    to add:
    dtoverlay=dwc2,dr_mode=peripheral
  3. Edit
    /boot/cmdline.txt
    to load gadget modules:
    modules-load=dwc2,g_ether,g_mass_storage,g_serial
  4. Optional audio gadget module:
    modules-load=dwc2,g_audio
  5. Reboot the Raspberry Pi.
Configuring Each Gadget
  • USB Network Device (Ethernet over USB): Load
    g_ether
    module; Pi appears as network interface.
  • USB Mass Storage Device: Use
    g_mass_storage
    and specify file/partition:
    g_mass_storage.file=/path/to/your/disk.img
  • USB Serial Device: Load
    g_serial
    for serial interface.
  • USB Audio Device: Load
    g_audio
    to emulate USB sound card.
Using the Multiple Gadgets
  • Network Device: SSH or network protocols via USB.
  • Mass Storage: Transfer files through emulated USB drive.
  • Serial Device: Interact with Pi via serial communication.
  • Audio Device: USB sound card functionality for host.

Multiple USB gadgets require sufficient processing power. Zero models are ideal; Pi 4 and 400 provide more capability for complex setups. Host drivers/software may be needed for full functionality.

Raspberry Pi USB Gadget with DHCP & Internet Sharing

Turn your Raspberry Pi into a USB gadget that provides:

  • Network Interface (RNDIS/NCM)
  • Serial Console (ACM)
  • Mass Storage (Any USB Drive)
  • DHCP Server (Automatically assigns IP to host)
  • Internet Sharing (Host accesses Pi’s Wi-Fi)

Step 1: Enable USB OTG Mode by editing

/boot/config.txt
and add
dtoverlay=dwc2

Edit

/boot/cmdline.txt
to include
modules-load=dwc2
after
rootwait

sudo reboot

Step 2: Create the USB Gadget script:

sudo nano /root/usb-gadget.sh

Add the provided bash script to configure network, serial, mass storage, and optional audio.

Step 3: Install and configure DHCP server:

sudo apt install isc-dhcp-server

Edit DHCP config

/etc/dhcp/dhcpd.conf
and set interface to
usb0
. Restart DHCP with
sudo systemctl restart isc-dhcp-server

Step 4: Enable Internet sharing with iptables:

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i usb0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o usb0 -j ACCEPT
sudo apt install iptables-persistent

Step 5: Run the USB Gadget on boot by editing

/etc/rc.local
and add
/root/usb-gadget.sh
before
exit 0

Step 6: Reboot and test:

sudo reboot

Host computer should get IP automatically and access the internet via Pi.

Operating Systems on Raspberry Pi

Overview

Raspberry Pi supports a wide range of operating systems, including Linux distributions, Android, Ultibo, and various real-time operating systems (RTOS). This guide covers installation on SD cards for Raspberry Pi with instructions for Windows and Linux hosts.

Installing Linux on Raspberry Pi

Windows Host

  1. Download the Raspberry Pi Imager from the official website.
  2. Install the Imager on your Windows PC.
  3. Insert the SD card (8GB or larger) into your computer.
  4. Launch Raspberry Pi Imager.
  5. Select the desired OS (e.g., Raspberry Pi OS or Ubuntu).
  6. Select your SD card as the target.
  7. Click "Write" to install the OS.
  8. Once complete, safely eject the SD card and insert it into the Raspberry Pi.

Linux Host

  1. Install Raspberry Pi Imager:
    sudo apt install rpi-imager
  2. Insert the SD card into your Linux computer.
  3. Launch the Imager:
    rpi-imager
  4. Select the desired OS.
  5. Choose the SD card as the target.
  6. Click "Write" to install the OS.
  7. Once complete, safely eject the SD card and insert it into the Raspberry Pi.
Installing Android on Raspberry Pi

Android allows Raspberry Pi to run Android apps. Installation uses a prebuilt image file and works on both Windows and Linux hosts.

  1. Download a compatible Android image from sources like KonstaKANG or AndroidPi.
  2. Use Balena Etcher or Raspberry Pi Imager to write the image to the SD card.
  3. Insert the SD card into the Raspberry Pi.
  4. Power on the Pi to boot into Android and follow the setup instructions.
Installing Ultibo on Raspberry Pi

Overview

Ultibo is a bare-metal OS for Raspberry Pi, allowing programs to be written in Pascal with direct hardware access. It provides real-time performance and is ideal for embedded systems.

Steps to Install Ultibo

  1. Download the Ultibo image from the official Ultibo website.
  2. Write the image to the SD card using Balena Etcher or Raspberry Pi Imager.
  3. Install the Ultibo Pascal IDE on your host computer (Windows, macOS, Linux).
  4. Develop and compile your Pascal program in the Ultibo IDE.
  5. Transfer the compiled binary to the SD card.
  6. Insert the SD card into the Raspberry Pi and power it on; your program will run directly on the hardware.

Examples of Projects

  • GPIO control for sensors and actuators.
  • Embedded systems with real-time constraints.
  • Real-time data processing from sensors.
  • Custom display drivers for LCD or OLED screens.
Other Real-Time Operating Systems

Overview

Several real-time operating systems (RTOS) are available for Raspberry Pi, providing precise timing, fast response, and low-latency performance for embedded or IoT applications.

Popular RTOS for Raspberry Pi

  • FreeRTOS: Widely used for real-time embedded applications. Supports low-latency tasks and microcontroller-like operations.
  • ChibiOS: Lightweight RTOS with small footprint, suitable for embedded systems.
  • RIOT OS: Low-power RTOS designed for IoT devices, supporting real-time applications on Raspberry Pi.