Raspberry Pi Basics
Raspberry Pi Basics
Raspberry Pi Basics
programmable processor
on-chip memory
accelerating function hardware (e.g. GPU)
both hardware and software
analog components
Benefits of SoC
GPU
Broadcom Video IV
Specialized graphical instruction sets
RAM
512MB (Model B rev.2)
256 MB (Model A, Model B rev.1)
Digital signal
Video and audio signal
DVI cannot carry audio signal
Up to 1920x1200 resolution
Composite RCA
Analog signal
480i, 576i resolution
3.5mm jack
http://pihw.wordpress.com/guides/direct-network-connection/
Passive models are cheaper and smaller, but lack the ability to run currenthungry devices like CD drives and external hard drives.
Types of Card
SDSC (SD): 1MB to 2GB
SDHC: 4GB to 32 GB
SDXD up to 2TB
Storage: Continue
SD Formatter:
https://www.sdcard.org/downloads/formatter_4/
Networking
Ethernet (IEEE 802.3)
Wi-Fi Adapter
Networking - wireless
IEEE 802.11 Wi-Fi
Protocols
802.11 b, up to 11Mbps
802.11 g, up to 54Mbps
802.11 n, up to 300Mbps
802.11 ac (draft), up to
1Gbps
Frequency band
2.4GHz, 5GHz
Writing output to dc
motors, LEDs for status.
Power Consumption
microUSB power connector
2.5W (model A)
3.5W (model B)
Useful links
Raspberry Pi official website
http://www.raspberrypi.org/
Raspberry Pi wiki
http://elinux.org/RaspberryPiBoard
The MagPi
http://www.themagpi.com
Raspberry Pi Setup
1. Download the Raspberry Pi operating system
Linux releases compatible with the Pi:
http://www.raspberrypi.org/downloads
The recommended OS is Raspbian:
http://downloads.raspberrypi.org/raspbian_latest
Re-mapping Keyboard:
sudo vi /etc/default/keyboard
XKBLAYOUT=gb
Change gb to us
(This assumes you want a us mapping, if not
replace the gb with the two letter code for
your country)
Install SSH:
sudo apt-get install ssh
Install Java
1. JDK 8 (with JavaFX) for ARM Early Access
http://jdk8.java.net/fxarmpreview/
Download from Raspberry pi
Download from your own PC and copy it (scp) to
Raspberry pi
29
30
31
Software
LXTerminal and Root Terminal: use the Linux command line in a window without
leaving the GUI.
Midori & NetSurf: Lightweight web browser
IDLE and IDLE 3: IDE for Python 2.7 and 3
Task Manager: Checks the available memory, processor workload, closes crashed
or unresponsive programs
Music player at the console: moc
OpenOffice.org: sudo apt-get install openoffice.org
Image Editing: Gimp
LAMP (Linux, Apache, MySQL and PHP) stack
Sudo apt-get install apache2 php5 php5-mysql mysql-server
34
Uninstalling software:
apt-get update
Finding software:
GUI for apt, Synaptic Package Manager doesnt work well on Pi due to the
lack of memory
Upgrading software:
Troubleshooting
Keyboard and Mouse Diagnostics
Power Diagnostics
Display Diagnostics
Network Diagnostics
Emergency Kernel
36
39
41
42
45
Electronic Equipment
Breadboard
Components in the same row are connected together without wires
Jumper Wires
Try to use different colors to differentiate different purposes
Resistors
Push-Buttons
LEDs
46
47
https://pypi.python.org/pypi/RPi.GPIO
Install commands:
sudo apt-get update
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
48
GPIO as Output
Experiment 1: Controlling LED
LED
Breadboard
Jumper wire
49
Breadboard
Build circuit easily without soldering
50
51
52
Multimeter
53
54
55
GPIO as Input
When the switch is
not pushed: GPIO
detects Vcc (HIGH)
When the switch is
pushed: GPIO
detects GND (LOW)
Pull up resistor
56
57
58
59
60
61
62
Using I2C:
Control 4 digit 7-segment display
How to do multiple 7segment display?
Multiplexing
64
Configure I2C
Add modules
Add two modules to the end of file /etc/modules :
i2c-bcm2708
i2c-dev
67
68
DS18B20+ Features
Unique 1-Wire Interface Requires Only One
Port Pin for Communication
Each Device has a Unique 64-Bit Serial Code
Stored on an On-Board ROM
Requires No External Components
Thermometer Resolution is User Selectable
from 9 to 12 Bits
Convert temperature to 12-Bit Digital Word in
750ms (max)
69
Read temperature
We do not need to implement the 1-wire
protocol ourselves.
We can read temperature from a file
sudo modprobe w1-gpio
sudo modprobe w1-therm
cd /sys/bus/w1/devices
ls
cd 28-xxxx (may need change to match serial no.)
cat w1_slave
72
Read temperature
In Python, we can read the temperature by
parsing that file:
import os
import glob
import time
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'
73
74
75
Experiment:
LED controlled by remote sensor
1st Raspberry Pi board houses temperature
sensor
2nd Raspberry Pi board houses an LED.
The sensor reports the temperature to the 2nd
Raspberry Pi board. LED will be turned on
when the temperature is higher than a
threshold.
77
IP Camera Setup
Turn a USB-based camera to an IP camera
Install motion package
sudo apt-get install motion
IP Camera Setup
Let the motion service start automatically:
sudo vi /etc/default/motion:
start_motion_daemon=no to yes
References
http://en.wikipedia.org/wiki/Breadboard
http://robig.net/blog/
http://www.societyofrobots.com/electronics_led_tutor
ial.shtml
http://macao.communications.museum/eng/exhibitio
n/secondfloor/moreinfo/Displays.html
See http://en.wikipedia.org/wiki/1-Wire for details
http://datasheets.maximintegrated.com/en/ds/DS18B
20.pdf
http://learn.adafruit.com/category/raspberry-pi
80