SlideShare a Scribd company logo
1 of 48
Introduction to
Raspberry Pi and Linux
workshop
By: Yeo Kheng Meng (yeokm1@gmail.com)
https://github.com/yeokm1/intro-to-rpi
At SUTD
14 March 2015
Components check
• Raspberry Pi Model B
• Micro-SD card
• Micro-USB cable ( with power adapter)
• Small Breadboard
• LED
• Push button
• 220-ohm Resistor
• 4 male-female jumper wires
• LAN cable
Download SSH client
• Windows: Download Putty
• Linux/Mac: Includes SSH client by default
About me
• Year 4 NUS Computer Science student
• My Hardware projects with Arduino and Raspberry Pi
What is a Raspberry Pi (RPi)?
• “The Raspberry Pi is a low cost, credit-card sized computer that plugs into a
computer monitor or TV, and uses a standard keyboard and mouse. It is a
capable little device that enables people of all ages to explore computing, and to
learn how to program in languages like Scratch and Python. It’s capable of doing
everything you’d expect a desktop computer to do, from browsing the internet
and playing high-definition video, to making spreadsheets, word-processing, and
playing games.” http://www.raspberrypi.org/help/what-is-a-raspberry-pi/
Common Rpi types today
Model A+ Model B+ 2 Model B
700Mhz single-core ARMv6
256MB Ram
1 USB port
No Ethernet port
700Mhz single-core ARMv6
512MB RAM
4 USB ports
Ethernet port
900Mhz quad-core ARMv7
1024MB Ram
4 USB ports
Ethernet port
Power use:
Source: http://raspi.tv/2015/raspberry-pi2-power-and-performance-measurement
Arduino vs Raspberry Pi
Specs Arduino Uno Raspberry Pi Model B+
CPU type Microcontroller Microprocessor
Operating System None Linux (usually Raspbian)
Speed 16 Mhz 700 Mhz
RAM 2KB 512MB
GPU/Display None VideoCore IV GPU
Disk 32KB Depends on SD card
GPIO pins 14 digital pins (includes 6 analog) 26 digital pins
Other connectivity None USB, Ethernet, HDMI, audio
Power consumption 0.25W 3.5W
What is an Operating System (OS)?
• An operating system (OS) is software that manages computer hardware and
software resources and provides common services for computer programs.
• Source: http://en.wikipedia.org/wiki/Operating_system
• My definition:
• A giant piece of software that gives programs you download/write hardware
features in a standardised manner.
• Closed-source vs open-source
• Closed: Windows, Mac OS X
• Open: Linux, FreeBSD, FreeDOS
• Unix(-like) vs non-Unix
• Unix: Linux, Mac OS X
• Non-Unix: Windows
Powering up your Raspberry Pi
• Connect the following first
• SD card
• HDMI cable
• Keyboard/mouse
• Connect this last
• Micro-USB cable
First boot/Setup with raspi-config
Enlarge root partition
Boot desktop options
Select graphical option
Internationalisation options
Change timezone
Select Asia/Singapore timezone
Change keyboard layout
Change to English (US) layout
• We don’t want the default UK layout
1. -> Generic 105-key (intl) PC
2. -> Other
3. -> English (US)
4. -> English (US)
5. -> The default keyboard layout
6. -> No compose key
7. -> “Yes” to terminate X server
Enable camera (optional)
Advanced Options
Enable SSH (remote access)
Reboot when complete
Initial setup complete!
SSH connection and terminal
• Use “ifconfig” to get IP address
• ifconfig
• Look under “eth0”
• Windows
• Putty: Hostname: x.x.x.x, Port: 22
• Mac/Linux
• Open terminal
• ssh pi@x.x.x.x
Raspbian default username/password
• Username: pi
• Password: raspberry
Unix basics
• Show directory contents:
• (Do this after every command below to see what has changed)
• ls or ls -l
• Make directory:
• mkdir lesson
• Change directory:
• cd lesson
• Create an empty file:
• touch myfile
• Edit file with nano:
• nano myfile
• Type something random inside the text editor then press Ctrl+X to save and quit.
• View file quickly:
• cat myfile
• Copy file
• cp myfile myfile2
• Remove file:
• rm myfile
• Move file
• mv myfile2 myfile
Other useful commands
Command Purpose
man Get information about a particular
command. Eg: man ls
ifconfig Get network information like IP
address
adduser Create user
passwd Change password
uname –a, uname -r Show OS information
history Shows past commands you ran
chmod Change permissions of a file/directory
Multi-user environment:
Root vs non-root vs sudo
• root (privileges)
• One administrative user that can do anything
• Most Linux distributions have root by default except for
Ubuntu, Raspbian
• Required for hardware access, package installation etc
• non-root
• Only restricted to activities in home (~) directory
• sudo
• Command to let certain non-root users temporarily get root
privileges
• Prepend in front of command that needs root
• Eg: sudo apt-get install java
Package management
• Install software from online repositories
• Maintains dependencies for you
• All these software come as packages
• Firefox, nano, sudo
Using a package manager
-installing htop
• Always run before package installation
• Update local repository index
• sudo apt-get update
• Upgrade all out-of-date packages
• sudo apt-get upgrade
• Install htop
• sudo apt-get install htop
• Htop:
• Process information viewer like Windows Task Manager
*Skip this slide if no internet connection
Header pins
• 26 Digital-only General Purpose Input Output pins
• Includes i2C and SPI
• 3.3V logic levels
• No analog-digital-converter
• Use external ADC like MCP3008
Using the GPIO pins
• Python programming language
• LED
• Button
Before handling GPIO
• Always shut down the Rpi
• sudo poweroff
• Side note: Unlike the Arduino, Rpi needs to be
shutdown properly before pulling the power.
LED and Button Connection
LED code
1. Open command line text editor:
nano gpio.py
2. Type the code on the left
3. Quit nano with Ctrl+X
4. Run code: sudo python gpio.py
Result:
LED should blink at 1 second
intervals
Watch your indentation. Python is indentation-sensitive
LED and button code 1
1. Quit the previous program using Ctrl+C
2. Modify your previous code:
nano gpio.py
3. Run again:
sudo python gpio.py
Now try pressing the button a few times.
What do you notice? Why?
LED and button code 2 (Debouncing)
Does it work properly now?
Now lets use the process viewer
• Keep the previous code running
• Open another terminal or SSH connection
• Run the process viewer
• htop
• If you did not install htop: “ps aux | grep python”
• What do you notice about Python’s CPU usage?
Why?
LED and button code 3
(Avoid high CPU consumption)
What is Python’s
CPU usage now?
Camera hardware connection
1. Lift up the top connector
Camera hardware connection
2. Insert the Flexible Flat Cable (FFC), note the position of the blue strip.
Camera hardware connection
3. Lock the connector back
Python camera code
Some useful addons
• Cobbler
• Case
• USB-TTL cable
3.3V USB-TTL cable
• An alternative way of interacting with your Rpi without keyboard
and HDMI screen
• https://www.adafruit.com/product/954
• Windows
1. Check COM number n from Device Manager
2. Putty, Serial COMn, Speed 115200
• Mac/Linux
1. Install screen
2. Linux: screen /dev/ttyUSB0 115200
3. Mac: screen /dev/tty.usbserial 115200
Sharing SD cards between Rpi 2
and others
• May not always be swappable
• Some distributions like Arch Linux have ARMv7
specific packages
• No issue with Raspbian as of now
Further reading
• GPIO interrupts
• Other RPi operating systems like Arch Linux ARM
• Read-only file system if you need unsafe poweroff
• Mini-UPS for unsafe power off
Q&A

More Related Content

More from yeokm1

Reflections on Trusting Trust for Go
Reflections on Trusting Trust for GoReflections on Trusting Trust for Go
Reflections on Trusting Trust for Goyeokm1
 
Meltdown and Spectre
Meltdown and SpectreMeltdown and Spectre
Meltdown and Spectreyeokm1
 
Gentoo on a 486
Gentoo on a 486Gentoo on a 486
Gentoo on a 486yeokm1
 
BLE Localiser (Full) for iOS Dev Scout
BLE Localiser (Full) for iOS Dev ScoutBLE Localiser (Full) for iOS Dev Scout
BLE Localiser (Full) for iOS Dev Scoutyeokm1
 
BLE Localiser for iOS Conf SG 2017
BLE Localiser for iOS Conf SG 2017BLE Localiser for iOS Conf SG 2017
BLE Localiser for iOS Conf SG 2017yeokm1
 
Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter
 Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter
Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiteryeokm1
 
PCB Business Card (Singapore Power)
PCB Business Card (Singapore Power)PCB Business Card (Singapore Power)
PCB Business Card (Singapore Power)yeokm1
 
SP Auto Door Unlocker
SP Auto Door UnlockerSP Auto Door Unlocker
SP Auto Door Unlockeryeokm1
 
SP IoT Doorbell
SP IoT DoorbellSP IoT Doorbell
SP IoT Doorbellyeokm1
 
Distance Machine Locker
Distance Machine LockerDistance Machine Locker
Distance Machine Lockeryeokm1
 
A Science Project: Building a sound card based on the Covox Speech Thing
A Science Project: Building a sound card based on the Covox Speech ThingA Science Project: Building a sound card based on the Covox Speech Thing
A Science Project: Building a sound card based on the Covox Speech Thingyeokm1
 
A Science Project: Swift Serial Chat
A Science Project: Swift Serial ChatA Science Project: Swift Serial Chat
A Science Project: Swift Serial Chatyeokm1
 
The slide rule
The slide ruleThe slide rule
The slide ruleyeokm1
 
Windows 3.1 (WFW) on vintage and modern hardware
Windows 3.1 (WFW) on vintage and modern hardwareWindows 3.1 (WFW) on vintage and modern hardware
Windows 3.1 (WFW) on vintage and modern hardwareyeokm1
 
Repair Kopitiam Circuit Breaker Training
Repair Kopitiam Circuit Breaker TrainingRepair Kopitiam Circuit Breaker Training
Repair Kopitiam Circuit Breaker Trainingyeokm1
 
A2: Analog Malicious Hardware
A2: Analog Malicious HardwareA2: Analog Malicious Hardware
A2: Analog Malicious Hardwareyeokm1
 
Getting Started with Raspberry Pi
Getting Started with Raspberry PiGetting Started with Raspberry Pi
Getting Started with Raspberry Piyeokm1
 
My Life as a Maker
My Life as a MakerMy Life as a Maker
My Life as a Makeryeokm1
 
Talk on The Essential Guide to Electronics in Shenzhen by Andrew 'Bunnie' Huang
Talk on The Essential Guide to Electronics in Shenzhen by Andrew 'Bunnie' HuangTalk on The Essential Guide to Electronics in Shenzhen by Andrew 'Bunnie' Huang
Talk on The Essential Guide to Electronics in Shenzhen by Andrew 'Bunnie' Huangyeokm1
 
Repair Kopitiam Specialty Electrical Equipment
Repair Kopitiam Specialty Electrical EquipmentRepair Kopitiam Specialty Electrical Equipment
Repair Kopitiam Specialty Electrical Equipmentyeokm1
 

More from yeokm1 (20)

Reflections on Trusting Trust for Go
Reflections on Trusting Trust for GoReflections on Trusting Trust for Go
Reflections on Trusting Trust for Go
 
Meltdown and Spectre
Meltdown and SpectreMeltdown and Spectre
Meltdown and Spectre
 
Gentoo on a 486
Gentoo on a 486Gentoo on a 486
Gentoo on a 486
 
BLE Localiser (Full) for iOS Dev Scout
BLE Localiser (Full) for iOS Dev ScoutBLE Localiser (Full) for iOS Dev Scout
BLE Localiser (Full) for iOS Dev Scout
 
BLE Localiser for iOS Conf SG 2017
BLE Localiser for iOS Conf SG 2017BLE Localiser for iOS Conf SG 2017
BLE Localiser for iOS Conf SG 2017
 
Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter
 Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter
Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter
 
PCB Business Card (Singapore Power)
PCB Business Card (Singapore Power)PCB Business Card (Singapore Power)
PCB Business Card (Singapore Power)
 
SP Auto Door Unlocker
SP Auto Door UnlockerSP Auto Door Unlocker
SP Auto Door Unlocker
 
SP IoT Doorbell
SP IoT DoorbellSP IoT Doorbell
SP IoT Doorbell
 
Distance Machine Locker
Distance Machine LockerDistance Machine Locker
Distance Machine Locker
 
A Science Project: Building a sound card based on the Covox Speech Thing
A Science Project: Building a sound card based on the Covox Speech ThingA Science Project: Building a sound card based on the Covox Speech Thing
A Science Project: Building a sound card based on the Covox Speech Thing
 
A Science Project: Swift Serial Chat
A Science Project: Swift Serial ChatA Science Project: Swift Serial Chat
A Science Project: Swift Serial Chat
 
The slide rule
The slide ruleThe slide rule
The slide rule
 
Windows 3.1 (WFW) on vintage and modern hardware
Windows 3.1 (WFW) on vintage and modern hardwareWindows 3.1 (WFW) on vintage and modern hardware
Windows 3.1 (WFW) on vintage and modern hardware
 
Repair Kopitiam Circuit Breaker Training
Repair Kopitiam Circuit Breaker TrainingRepair Kopitiam Circuit Breaker Training
Repair Kopitiam Circuit Breaker Training
 
A2: Analog Malicious Hardware
A2: Analog Malicious HardwareA2: Analog Malicious Hardware
A2: Analog Malicious Hardware
 
Getting Started with Raspberry Pi
Getting Started with Raspberry PiGetting Started with Raspberry Pi
Getting Started with Raspberry Pi
 
My Life as a Maker
My Life as a MakerMy Life as a Maker
My Life as a Maker
 
Talk on The Essential Guide to Electronics in Shenzhen by Andrew 'Bunnie' Huang
Talk on The Essential Guide to Electronics in Shenzhen by Andrew 'Bunnie' HuangTalk on The Essential Guide to Electronics in Shenzhen by Andrew 'Bunnie' Huang
Talk on The Essential Guide to Electronics in Shenzhen by Andrew 'Bunnie' Huang
 
Repair Kopitiam Specialty Electrical Equipment
Repair Kopitiam Specialty Electrical EquipmentRepair Kopitiam Specialty Electrical Equipment
Repair Kopitiam Specialty Electrical Equipment
 

Recently uploaded

(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...srsj9000
 
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...ur8mqw8e
 
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查awo24iot
 
Russian Call Girls Kolkata Chhaya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls Kolkata Chhaya 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls Kolkata Chhaya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls Kolkata Chhaya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...nagunakhan
 
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...Amil baba
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一ss ss
 
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service LucknowAlambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service Lucknowmakika9823
 
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一ga6c6bdl
 
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一ga6c6bdl
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsappssapnasaifi408
 
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfPresentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfchapmanellie27
 
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...ranjana rawat
 
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一C SSS
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
萨斯喀彻温大学毕业证学位证成绩单-购买流程
萨斯喀彻温大学毕业证学位证成绩单-购买流程萨斯喀彻温大学毕业证学位证成绩单-购买流程
萨斯喀彻温大学毕业证学位证成绩单-购买流程1k98h0e1
 
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311  Call Girls in Thane , Independent Escort Service ThanePallawi 9167673311  Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service ThanePooja Nehwal
 

Recently uploaded (20)

(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
 
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
 
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
 
Russian Call Girls Kolkata Chhaya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls Kolkata Chhaya 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls Kolkata Chhaya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls Kolkata Chhaya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
 
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
 
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service LucknowAlambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
 
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
 
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
 
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfPresentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
 
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
 
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
萨斯喀彻温大学毕业证学位证成绩单-购买流程
萨斯喀彻温大学毕业证学位证成绩单-购买流程萨斯喀彻温大学毕业证学位证成绩单-购买流程
萨斯喀彻温大学毕业证学位证成绩单-购买流程
 
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311  Call Girls in Thane , Independent Escort Service ThanePallawi 9167673311  Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
 

Introduction to Raspberry Pi and Linux

  • 1. Introduction to Raspberry Pi and Linux workshop By: Yeo Kheng Meng (yeokm1@gmail.com) https://github.com/yeokm1/intro-to-rpi At SUTD 14 March 2015
  • 2. Components check • Raspberry Pi Model B • Micro-SD card • Micro-USB cable ( with power adapter) • Small Breadboard • LED • Push button • 220-ohm Resistor • 4 male-female jumper wires • LAN cable
  • 3. Download SSH client • Windows: Download Putty • Linux/Mac: Includes SSH client by default
  • 4. About me • Year 4 NUS Computer Science student • My Hardware projects with Arduino and Raspberry Pi
  • 5. What is a Raspberry Pi (RPi)? • “The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. It’s capable of doing everything you’d expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games.” http://www.raspberrypi.org/help/what-is-a-raspberry-pi/
  • 6. Common Rpi types today Model A+ Model B+ 2 Model B 700Mhz single-core ARMv6 256MB Ram 1 USB port No Ethernet port 700Mhz single-core ARMv6 512MB RAM 4 USB ports Ethernet port 900Mhz quad-core ARMv7 1024MB Ram 4 USB ports Ethernet port Power use: Source: http://raspi.tv/2015/raspberry-pi2-power-and-performance-measurement
  • 7. Arduino vs Raspberry Pi Specs Arduino Uno Raspberry Pi Model B+ CPU type Microcontroller Microprocessor Operating System None Linux (usually Raspbian) Speed 16 Mhz 700 Mhz RAM 2KB 512MB GPU/Display None VideoCore IV GPU Disk 32KB Depends on SD card GPIO pins 14 digital pins (includes 6 analog) 26 digital pins Other connectivity None USB, Ethernet, HDMI, audio Power consumption 0.25W 3.5W
  • 8. What is an Operating System (OS)? • An operating system (OS) is software that manages computer hardware and software resources and provides common services for computer programs. • Source: http://en.wikipedia.org/wiki/Operating_system • My definition: • A giant piece of software that gives programs you download/write hardware features in a standardised manner. • Closed-source vs open-source • Closed: Windows, Mac OS X • Open: Linux, FreeBSD, FreeDOS • Unix(-like) vs non-Unix • Unix: Linux, Mac OS X • Non-Unix: Windows
  • 9. Powering up your Raspberry Pi • Connect the following first • SD card • HDMI cable • Keyboard/mouse • Connect this last • Micro-USB cable
  • 10. First boot/Setup with raspi-config
  • 18. Change to English (US) layout • We don’t want the default UK layout 1. -> Generic 105-key (intl) PC 2. -> Other 3. -> English (US) 4. -> English (US) 5. -> The default keyboard layout 6. -> No compose key 7. -> “Yes” to terminate X server
  • 24. SSH connection and terminal • Use “ifconfig” to get IP address • ifconfig • Look under “eth0” • Windows • Putty: Hostname: x.x.x.x, Port: 22 • Mac/Linux • Open terminal • ssh pi@x.x.x.x
  • 25. Raspbian default username/password • Username: pi • Password: raspberry
  • 26. Unix basics • Show directory contents: • (Do this after every command below to see what has changed) • ls or ls -l • Make directory: • mkdir lesson • Change directory: • cd lesson • Create an empty file: • touch myfile • Edit file with nano: • nano myfile • Type something random inside the text editor then press Ctrl+X to save and quit. • View file quickly: • cat myfile • Copy file • cp myfile myfile2 • Remove file: • rm myfile • Move file • mv myfile2 myfile
  • 27. Other useful commands Command Purpose man Get information about a particular command. Eg: man ls ifconfig Get network information like IP address adduser Create user passwd Change password uname –a, uname -r Show OS information history Shows past commands you ran chmod Change permissions of a file/directory
  • 28. Multi-user environment: Root vs non-root vs sudo • root (privileges) • One administrative user that can do anything • Most Linux distributions have root by default except for Ubuntu, Raspbian • Required for hardware access, package installation etc • non-root • Only restricted to activities in home (~) directory • sudo • Command to let certain non-root users temporarily get root privileges • Prepend in front of command that needs root • Eg: sudo apt-get install java
  • 29. Package management • Install software from online repositories • Maintains dependencies for you • All these software come as packages • Firefox, nano, sudo
  • 30. Using a package manager -installing htop • Always run before package installation • Update local repository index • sudo apt-get update • Upgrade all out-of-date packages • sudo apt-get upgrade • Install htop • sudo apt-get install htop • Htop: • Process information viewer like Windows Task Manager *Skip this slide if no internet connection
  • 31. Header pins • 26 Digital-only General Purpose Input Output pins • Includes i2C and SPI • 3.3V logic levels • No analog-digital-converter • Use external ADC like MCP3008
  • 32. Using the GPIO pins • Python programming language • LED • Button
  • 33. Before handling GPIO • Always shut down the Rpi • sudo poweroff • Side note: Unlike the Arduino, Rpi needs to be shutdown properly before pulling the power.
  • 34. LED and Button Connection
  • 35. LED code 1. Open command line text editor: nano gpio.py 2. Type the code on the left 3. Quit nano with Ctrl+X 4. Run code: sudo python gpio.py Result: LED should blink at 1 second intervals Watch your indentation. Python is indentation-sensitive
  • 36. LED and button code 1 1. Quit the previous program using Ctrl+C 2. Modify your previous code: nano gpio.py 3. Run again: sudo python gpio.py Now try pressing the button a few times. What do you notice? Why?
  • 37. LED and button code 2 (Debouncing) Does it work properly now?
  • 38. Now lets use the process viewer • Keep the previous code running • Open another terminal or SSH connection • Run the process viewer • htop • If you did not install htop: “ps aux | grep python” • What do you notice about Python’s CPU usage? Why?
  • 39. LED and button code 3 (Avoid high CPU consumption) What is Python’s CPU usage now?
  • 40. Camera hardware connection 1. Lift up the top connector
  • 41. Camera hardware connection 2. Insert the Flexible Flat Cable (FFC), note the position of the blue strip.
  • 42. Camera hardware connection 3. Lock the connector back
  • 44. Some useful addons • Cobbler • Case • USB-TTL cable
  • 45. 3.3V USB-TTL cable • An alternative way of interacting with your Rpi without keyboard and HDMI screen • https://www.adafruit.com/product/954 • Windows 1. Check COM number n from Device Manager 2. Putty, Serial COMn, Speed 115200 • Mac/Linux 1. Install screen 2. Linux: screen /dev/ttyUSB0 115200 3. Mac: screen /dev/tty.usbserial 115200
  • 46. Sharing SD cards between Rpi 2 and others • May not always be swappable • Some distributions like Arch Linux have ARMv7 specific packages • No issue with Raspbian as of now
  • 47. Further reading • GPIO interrupts • Other RPi operating systems like Arch Linux ARM • Read-only file system if you need unsafe poweroff • Mini-UPS for unsafe power off
  • 48. Q&A