Enter your credentials to continue
Join our secure network
Reset your password via email
The Raspberry Pi 3 series introduced built-in WiFi and Bluetooth, making it the first truly wireless Raspberry Pi. It retains the 40-pin GPIO header, improving performance while maintaining backward compatibility with previous models.
Image: Wikimedia Commons, CC BY‑SA (replace with correct attribution)
More info: Raspberry Pi 3 Model B – Official Site
Compared to the Raspberry Pi 2:
The Raspberry Pi Compute Module 3 (CM3) and its updated version, Compute Module 3+ (CM3+), provide the processing power of the Raspberry Pi 3 in a compact SODIMM form factor. Designed for embedded applications where space and flexibility are critical.
Raspberry Pi Compute Module 3 – From the Raspberry Pi Foundation, CC BY‑SA 4.0
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.
To use I2C on the Raspberry Pi, you'll first need to enable it in the Raspberry Pi's configuration settings. Follow these steps:
sudo raspi-config.
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
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.
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.
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 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.
The following GPIO pins are used for I²S on Raspberry Pi:
Ground can be taken from any GND pin (e.g. Pin 6).
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 (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.
To enable SPI, activate it through the Raspberry Pi configuration settings:
sudo raspi-config.Check if SPI is enabled by running:
lsmod | grep spi
SPI communication on the Raspberry Pi uses the following pins:
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)
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.
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:
Pulse Width Modulation (PWM) allows control of power to devices like LEDs and motors. Raspberry Pi supports PWM on several GPIO pins.
RPi.GPIO to configure a GPIO pin for PWM.
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 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.
By default, the serial interface on the Raspberry Pi is disabled. To enable it:
sudo raspi-config.
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)
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.
RPi.GPIO Python library to configure GPIO pins for input or output.gpiozero Python library for higher-level control with simplified syntax.
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)
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.
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.
Interrupts require configuring a GPIO pin as input, selecting the interrupt edge type, and defining an ISR to handle the event.
WiringPi or RPi.GPIO.
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()
Mechanical switches can generate multiple false triggers. Debouncing prevents this by enforcing a delay between valid events.
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()
Multiple pins can be configured to trigger interrupts independently.
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 interrupts allow Raspberry Pi to respond instantly to external events, making them essential for buttons, sensors, and real-time signalling applications.
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.
Several Raspberry Pi models include integrated Wi-Fi, simplifying wireless networking without additional hardware. These models include:
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.
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.
raspi-config (headless).wpa_supplicant.conf file with network details.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 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.
These Raspberry Pi models include integrated Bluetooth hardware:
Most models provide Bluetooth 4.2 support, including BLE, suitable for wireless peripherals, audio devices, and sensors.
Bluetooth support is provided by the BlueZ stack, enabling interaction with Bluetooth devices through tools such as bluetoothctl.
bluetoothctl to pair and manage devices.bluez and pi-bluetooth for extended features.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.
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.
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.
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.
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.
The Raspberry Pi 2 Model B also supports the CSI interface, similar to the original Model B, but with improved processing power.
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.
The Raspberry Pi 4 Model B supports the CSI interface and is ideal for high-performance camera projects.
The Raspberry Pi 5 is expected to continue supporting the CSI camera interface with possible improvements.
All models support the raspistill and raspivid tools for image and video capture.
raspistill -o image.jpg
raspivid -o video.h264 -t 10000
sudo raspi-config
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.
The Raspberry Pi Zero does not have a native composite video jack. Video output is via HDMI or GPIO pins with an external adapter.
The original Raspberry Pi Model B (rev 1 and 2) includes a 3.5mm jack for analog audio and RCA socket for composite video.
The Raspberry Pi 2 Model B retains the 3.5mm jack for composite video and analog audio, like the original Model B.
The Raspberry Pi 3 Model B and B+ maintain the 3.5mm jack for composite video/audio alongside HDMI support.
The Raspberry Pi 4 Model B has a 3.5mm jack for composite video/audio, alongside HDMI for 4K digital output.
The Raspberry Pi 5 is expected to continue offering the 3.5mm jack for composite video/audio alongside HDMI digital output.
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.
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.
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.
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.
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.
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.
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.
The Raspberry Pi features multiple USB ports for connecting peripherals such as keyboards, mice, storage devices, and network adapters. The USB interface provides both data transfer and power to connected devices.
Different Raspberry Pi models support various USB versions. Most have USB 2.0 ports, while newer models like Raspberry Pi 4 and Raspberry Pi 400 offer USB 3.0 for faster data transfer.
Some Raspberry Pi models can power external devices through USB ports, such as keyboards, mice, or small external drives. High-power devices may require an external power source.
On micro-USB models (Pi Zero, Pi 3), the USB port supports OTG, allowing the Pi to act as a host or a device. Useful for creating USB gadgets or connecting the Pi to a smartphone or PC.
Plug the USB device into a Raspberry Pi port. Common devices work out of the box; specialized peripherals may require drivers or tools.
Plug the USB WiFi adapter into a port and install required drivers (usually included in Raspberry Pi OS):
sudo apt-get update
sudo apt-get install firmware-ralink
If a USB device is not working:
dmesg to check system logs for USB errors.lsusb: Lists all connected USB devices.dmesg | grep usb: Displays detailed USB logs.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.
sudo apt install rpi-imagerrpi-imagerAndroid allows Raspberry Pi to run Android apps. Installation uses a prebuilt image file and works on both Windows and Linux hosts.
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.
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.
These early Raspberry Pi models feature 10/100 Mbps Ethernet via a USB 2.0–connected LAN controller. Throughput is typically limited to around 90 Mbps due to the USB bus bottleneck.
Note: Performance is limited by USB 2.0; heavy network loads may saturate CPU usage.
The Pi 3 B+ offers Gigabit Ethernet hardware but limited via USB 2.0, providing practical throughput up to ~300 Mbps.
Note: Despite Gigabit capability on paper, USB 2.0 limits actual throughput.
These modern models feature true Gigabit Ethernet via a dedicated PHY. This allows full-speed wired connectivity (~940 Mbps practical) without USB bottleneck.
Note: True Gigabit Ethernet is supported; use Cat5e/Cat6 cabling to achieve maximum throughput.
Independent command blocks for managing Raspberry Pi Ethernet interfaces. Click to copy to clipboard.
# List all network interfaces
ip link show
# or
ifconfig -a
# Show IP address of Ethernet interface eth0
ip addr show eth0
# Show Ethernet link speed
sudo ethtool eth0 | grep Speed
# Enable DHCP on eth0
sudo dhclient eth0
# Edit dhcpcd.conf to assign static IP
sudo nano /etc/dhcpcd.conf
# Add lines:
# interface eth0
# static ip_address=192.168.1.100/24
# Restart networking service
sudo systemctl restart dhcpcd
# Bring interface up
sudo ifconfig eth0 up
# Bring interface down
sudo ifconfig eth0 down
# Show interface statistics
ifconfig eth0
# Or RX/TX byte counters
cat /sys/class/net/eth0/statistics/rx_bytes
cat /sys/class/net/eth0/statistics/tx_bytes