0% found this document useful (0 votes)
4 views4 pages

Raspberry Pi Detailed Notes

Raspberry Pi is a compact, affordable single-board computer designed for education and DIY projects, featuring an ARM-based processor and various interfacing options through GPIO pins. It operates primarily on Raspberry Pi OS, supports multiple communication protocols like UART, SPI, and I2C, and is commonly programmed using Python. The document also includes examples of controlling LEDs and sensors using Python code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Raspberry Pi Detailed Notes

Raspberry Pi is a compact, affordable single-board computer designed for education and DIY projects, featuring an ARM-based processor and various interfacing options through GPIO pins. It operates primarily on Raspberry Pi OS, supports multiple communication protocols like UART, SPI, and I2C, and is commonly programmed using Python. The document also includes examples of controlling LEDs and sensors using Python code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Raspberry Pi Detailed Notes

Open Platform: Raspberry Pi Architecture

Definition:
Raspberry Pi is a small, affordable, single-board computer developed to promote computer
science education and DIY projects. It is open platform hardware, meaning users can
develop, program, and interface with external devices using its General Purpose
Input/Output (GPIO) pins.

Architecture:
Raspberry Pi uses an ARM-based processor (usually Broadcom SoC - System on Chip). The
architecture includes:
- ARM CPU
- RAM (varies from 512MB to 8GB)
- GPIO pins for interfacing
- USB ports for input devices
- HDMI port for display
- Ethernet or Wi-Fi for networking
- CSI (Camera Serial Interface)
- DSI (Display Serial Interface)
- SD card slot for storage and operating system

About the Board:


The Raspberry Pi board is designed to be compact and efficient. It features:
- GPIO: Used for connecting sensors, LEDs, switches, etc.
- Power Supply: 5V micro USB or USB-C
- Video Output: HDMI and composite video
- Audio Output: 3.5mm jack or HDMI
- USB Ports: For keyboard, mouse, USB devices
- Ethernet/Wi-Fi: For network connectivity
- Camera and Display Ports: For interfacing Pi camera and official display

Linux on Raspberry Pi:


The default operating system for Raspberry Pi is Raspberry Pi OS (formerly Raspbian), a
Debian-based Linux distribution.

Logging in:
- Default username: pi
- Default password: raspberry
- Login through connected monitor or SSH (if enabled)
Starting the Raspbian GUI:
- Command to start GUI: startx
- The GUI provides a desktop-like interface to access files, programs, and settings

Difference Between Raspberry Pi and Desktop Computer:

| Feature | Raspberry Pi | Desktop Computer |


|---------------------|-------------------------------|----------------------------------|
| Size | Small (credit card size) | Large CPU and monitor |
| Cost | Very low | High |
| Power | Low power consumption | High power consumption |
| Ports | Limited | Multiple, full-sized |
| Expansion | GPIO for electronics | PCIe/USB slots for hardware |
| Use Case | Education, IoT, DIY | Office, gaming, productivity |
| Operating System | Linux-based (Raspberry Pi OS) | Windows, Linux, macOS |

Raspberry Pi Interfacing:
Interfacing is how external components communicate with the Raspberry Pi using GPIO and
communication protocols.

1. Serial Communication (UART):


- Uses two pins: TX (Transmit), RX (Receive)
- Used for communicating with devices like GPS, GSM modules
- Baud rate defines speed of communication

2. Serial Peripheral Interface (SPI):


- High-speed synchronous communication protocol
- Uses 4 lines:
- MOSI (Master Out Slave In)
- MISO (Master In Slave Out)
- SCLK (Serial Clock)
- SS/CE (Slave Select / Chip Enable)
- Raspberry Pi is Master; devices like ADC, displays act as slaves

3. Master-Slave Configuration of SPI:


- Master (Raspberry Pi) generates clock and controls communication
- Each slave is connected via separate SS line
- Only one slave communicates at a time

4. I2C (Inter-Integrated Circuit):


- Two-wire communication: SDA (Data), SCL (Clock)
- Each device has a unique address
- Used to connect multiple sensors (temperature, accelerometers)
- Supports multiple masters and multiple slaves

Raspberry Pi Programming:
- Programming language: Mostly Python
- Libraries:
- RPi.GPIO: Basic GPIO control
- gpiozero: Simplified interface for common tasks
- Python code can control sensors, actuators, LEDs, switches, and more

Controlling LED with Raspberry Pi:


1. Connect LED to a GPIO pin via resistor
2. Use Python to control GPIO output

Python Code:
import RPi.GPIO as GPIO
import time

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

GPIO.output(18, GPIO.HIGH) # Turn LED ON


time.sleep(2)
GPIO.output(18, GPIO.LOW) # Turn LED OFF

GPIO.cleanup()

Interfacing an LED and Switch with Raspberry Pi:


- LED is connected to an output pin
- Switch is connected to an input pin with pull-down resistor

Python Code:
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT) # LED
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Switch

while True:
if GPIO.input(17) == GPIO.HIGH:
GPIO.output(18, GPIO.HIGH)
else:
GPIO.output(18, GPIO.LOW)

Interfacing Light Sensor (LDR) with Raspberry Pi:


- LDR and resistor form a voltage divider
- Since Pi has no analog input, use ADC like MCP3008
- Connect LDR to MCP3008, read analog value using SPI

Python Code:
import spidev
import time

spi = spidev.SpiDev()
spi.open(0, 0)

def read_channel(channel):
adc = spi.xfer2([1, (8+channel)<<4, 0])
data = ((adc[1]&3) << 8) + adc[2]
return data

while True:
light_level = read_channel(0)
print("Light Level:", light_level)
time.sleep(1)

You might also like