SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
Prepared by: Mohamed AbdAllah
Raspberry pi interfacing
Lecture 6: Working on raspberry pi
1
Lecture Agenda
 Installing Linux on the Pi.
 Setting a static IP address.
 Setting a local host name.
 Configuring the Wi-Fi dongle.
 Working with Pi GPIO.
 Working with Pi UART.
 Working with Pi PWM.
2
Lecture Agenda
3
Installing Linux on the Pi
4
 Downloading Linux image
• Download Linux image for raspberry pi, for example download the
Raspbian image from the following website:
http://raspberrypi.org/
 Image extracting
• Decompress the downloaded file, rename the decompressed file to any
name for easier access using command line, for example let the file
name be (assuming in home directory):
~/RaspberryImage.img
 Installing the image
• Put the SD Card in the computer and format it first (using disks utility
for example, you can type “disks” in the already installed applications).
Installing Linux on the Pi
5
• Then type the following command in the terminal to know the SD Card
name (Note the $ is just indication that this is a command, don’t write it
in your commands):
$ dmesg
• Then search in the last few lines for SD Card name, for example sdb
(Note we will ignore sdb0 and sdb1 and so on as those are just the SD
Card internal partitions if you didn’t format the card).
• Type on the terminal and wait about 5 minutes to finish:
$ sudo dd bs=4M if=~/RaspberryImage.img of=/dev/sdb
• Now the Pi is ready to boot, connect your SD Card, keyboard, mouse,
HDMI cable, LAN cable and WiFi dongle to the Pi and start working.
• Note that normally the HDMI cable will work automatically, but on
some cases if it didn’t work, we need to edit some configurations as we
will illustrate next.
Installing Linux on the Pi
6
 Configuring the HDMI
• In case that the HDMI didn’t work automatically, connect the SD Card to
the computer and open the file called config.txt inside the SD Card boot
partition.
• Note that you need to open it as root, in the command line type:
$ sudo gedit
And before hitting Enter key, drag the config.txt file from its place and drop
it beside your command to automatically paste its path, then hit Enter.
• The file after editing should look the same like this:
Installing Linux on the Pi
7
 Configuring the HDMI
Installing Linux on the Pi
8
 Configuring the HDMI
Installing Linux on the Pi
9
 Configuring the HDMI
• Now remove the SD Card from your computer and connect it to the Pi
and start it and it the HDMI now should work.
 First steps on the Pi
• At the first time the Pi boots it shows a configuration screen, you can
edit the configurations now or later after login by opening the same
screen by typing the command
$ sudo raspi-config
 Choose Expand File System option.
 Choose on advanced options to enable SSH, I2C, SPI.
 Choose update.
• After update, login by using “pi” as user name, and “raspberry” as
password
• Type the following commands
$ sudo apt-get update
$ sudo apt-get upgrade
Installing Linux on the Pi
10
 First steps on the Pi
• Now reboot the Pi
$ sudo reboot
• To connect remotely to the Pi using your PC inside the same network,
we need first to know the Pi IP address, so on the Pi type the command
$ ifconfig
• You will find the Pi IP address beside the interface “eth0” as now we are
connected to the network through LAN cable.
• Assuming that you found that the Pi IP is 192.168.1.2, now on your PC
while you are connected on the same network, type the following
$ sudo ssh pi@192.168.1.2
• Then if prompted, type yes and hit enter to confirm the connection
• Then type “pi” as user name, and “raspberry” as password, and now
you are one the Pi command line so any command you type is actually
executed on the Pi not on your PC.
Installing Linux on the Pi
11
Setting a static IP address
12
• The IP address we used to connect to the Pi may be changed by the
network router, so to make it static edit the following file on the Pi :
/etc/network/interfaces
• First we need to prepare the configurations, on the Pi type
$ ifconfig
You will se something like this, store those numbers as we will need them
Setting a static IP address
13
• Then type
$ netstat -nr
You will se something like this, store those numbers as we will need them
• Now type:
$ sudo nano /etc/network/interfaces
• Uncomment the following line to look like this:
• Add after that line the following lines
Setting a static IP address
14
• The file after editing should look like this, now close the file by hitting
CTRL+X and hit Enter:
• Now whenever the Pi boots, it will automatically take the IP 192.168.1.2
Setting a static IP address
15
Setting a local host name
16
• The problem of the static IP address is the when we move to another
network with other configurations it will not work, so we will give the Pi
a local host name that we can deal with the Pi using that name
whatever its IP.
• First type the following command to set password for root user as we
will need it
$ sudo passwd
• Then we need to undo the configurations of the static IP, open the same
file again /etc/network/interfaces and undo all changes again
Setting a local host name
17
• Then type
$ sudo apt-get install avahi-daemon
• Now inside any network you can connect to the Pi using the name
“raspberrypi.local”, and the root password
$ sudo ssh raspberrypi.local
*Note: You can switch to “pi” user by typing $ su pi
• To change the name, change “raspberrypi” in the following 2 files to the
name that you want (ex. “mynewname” or anything)
$ sudo nano /etc/hosts
$ sudo nano /etc/hostname
• Then to commit, run the command multiple times until it run
successfully without errors.
$ sudo /etc/init.d/hostname.sh
• Then reboot so you can use your new name
$ sudo ssh mynewname.local
Setting a local host name
18
Configuring the Wi-Fi dongle
19
• First to know the manufacturer of the WiFi dongle type:
$ dmesg | grep usb
• You will see something like this
• As we can see it is Realtek.
Configuring the Wi-Fi dongle
20
• Then type the following commands:
$ sudo apt-cache search firmware wireless
$ sudo apt-get install firmware-realtek
• Then edit the interfaces file
$ sudo nano /etc/network/interfaces
• Replace the following lines:
With the following lines:
Configuring the Wi-Fi dongle
21
• Then type the following command:
$ sudo nano /etc/wpa.conf
• Type the following lines, replace “networkname” with your WiFi
network name, and “network passkey” with your WiFi network pass
key:
*Note that there is no space after the = sign
• Now shutdown and remove the LAN cable then start the Pi with the
WiFi dongle only and it will automatically access the network, you can
access it remotely using the same name “raspberrypi.local” or the
name you gave to it.
Configuring the Wi-Fi dongle
22
Working with Pi GPIO
23
Working with Pi GPIO
24
• To interact with Pi GPIO (Make pi input or output, read pin value or
write to pin logic high or logic low value), first create empty file:
$ nano GPIO_python.py
• Write the following lines in the file, here we are making LED ON for 5
seconds then OFF on GPIO17:
Working with Pi GPIO
25
• Now close the file, then add execute permission to it:
$ sudo chmod u+x GPIO_python.py
• Now execute the script by typing:
$ sudo ./GPIO_python.py
Working with Pi GPIO
26
• To make LED Flasher each 1 second on GPIO17, create new script as
previous example:
Working with Pi GPIO
27
• To take input from GPIO4, if logic high the make the LED connected to
GPIO17 to be ON, else make LED OFF, create new script:
Working with Pi GPIO
28
Working with Pi UART
29
• To interact with Pi UART, first we need to prevent the kernel from
sending any messages to the UART port by editing these files:
 First backup the original file
$ sudo cp /boot/cmdline.txt /boot/cmdline_bp.txt
 Change this file configurations
$ sudo nano /boot/cmdline.txt
 Remove ttyAMA0,115200, final line should be something like this:
 Change this file configurations
$ sudo nano /etc/inittab
 Comment out the line that contains ttyAMA0 115200, by putting # in its
start
• Reboot and now the UART port is ready to be used.
$ sudo reboot
Working with Pi UART
30
• To send and receive bytes on UART port, create new script:
Working with Pi UART
31
• To observe what you receive on the serial port you can use a program
like minicom, to install it:
$ sudo apt-get install minicom
• To edit program configurations:
$ sudo minicom -s
• To edit port name press Shift+A, and change it to be /dev/ttyAMA0.
• To edit baud rate press Shift+E, then Shift+C for 9600.
• Now choose save as dfl to save this configurations as default, then Exit.
• To use the program at any time, type the following and observe what
you receive on the UART port:
$ sudo minicom
Working with Pi UART
32
Working with Pi PWM
33
• To output a soft PWM signal on any GPIO for example GPIO27, create
new script:
Working with Pi PWM
34
• Useful methods:
Working with Pi PWM
35
Mohamed AbdAllah
Embedded Systems Engineer
mohabdallah8@gmail.com
36

Más contenido relacionado

La actualidad más candente

Raspberry Pi presentation for Computer Architecture class
Raspberry Pi presentation for Computer Architecture classRaspberry Pi presentation for Computer Architecture class
Raspberry Pi presentation for Computer Architecture classMichael Gordon
 
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)Avansa Mid- en Zuidwest
 
Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014Mandeesh Singh
 
Raspberry pi technology
Raspberry pi technologyRaspberry pi technology
Raspberry pi technologyZeeshan Aslam
 
RaspberryPi + IoT - Lab to switch on and off a light bulb
RaspberryPi + IoT - Lab to switch on and off a light bulbRaspberryPi + IoT - Lab to switch on and off a light bulb
RaspberryPi + IoT - Lab to switch on and off a light bulbJeff Prestes
 
Raspberry Pi in Education (English)
Raspberry Pi in Education (English)Raspberry Pi in Education (English)
Raspberry Pi in Education (English)Beregszászi István
 
Raspberry Pi Technology
Raspberry Pi TechnologyRaspberry Pi Technology
Raspberry Pi TechnologyRavi Basil
 
Raspberry pi technical documentation
Raspberry pi technical documentationRaspberry pi technical documentation
Raspberry pi technical documentationGR Techno Solutions
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioKevin Hooke
 
Introduction to raspberry pi
Introduction to raspberry piIntroduction to raspberry pi
Introduction to raspberry pipraveen_23
 

La actualidad más candente (20)

Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 
Raspberry Pi presentation for Computer Architecture class
Raspberry Pi presentation for Computer Architecture classRaspberry Pi presentation for Computer Architecture class
Raspberry Pi presentation for Computer Architecture class
 
IPv6: A Digital Game Changer
IPv6: A Digital Game ChangerIPv6: A Digital Game Changer
IPv6: A Digital Game Changer
 
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
 
Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014
 
Raspberry pi technology
Raspberry pi technologyRaspberry pi technology
Raspberry pi technology
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Raspberry pi ppt
Raspberry pi pptRaspberry pi ppt
Raspberry pi ppt
 
RaspberryPi + IoT - Lab to switch on and off a light bulb
RaspberryPi + IoT - Lab to switch on and off a light bulbRaspberryPi + IoT - Lab to switch on and off a light bulb
RaspberryPi + IoT - Lab to switch on and off a light bulb
 
Raspberry Pi in Education (English)
Raspberry Pi in Education (English)Raspberry Pi in Education (English)
Raspberry Pi in Education (English)
 
Rasberry pi
 Rasberry pi Rasberry pi
Rasberry pi
 
Raspberry Pi Technology
Raspberry Pi TechnologyRaspberry Pi Technology
Raspberry Pi Technology
 
Pi Is For Python
Pi Is For PythonPi Is For Python
Pi Is For Python
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Raspberry pi technical documentation
Raspberry pi technical documentationRaspberry pi technical documentation
Raspberry pi technical documentation
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur Radio
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Introduction to raspberry pi
Introduction to raspberry piIntroduction to raspberry pi
Introduction to raspberry pi
 

Destacado

Raspberry Pi - Lecture 1 Introduction
Raspberry Pi - Lecture 1 IntroductionRaspberry Pi - Lecture 1 Introduction
Raspberry Pi - Lecture 1 IntroductionMohamed Abdallah
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSMohamed Abdallah
 
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry PiRaspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry PiMohamed Abdallah
 
Raspberry Pi - Lecture 4 Hardware Interfacing Special Cases
Raspberry Pi - Lecture 4 Hardware Interfacing Special CasesRaspberry Pi - Lecture 4 Hardware Interfacing Special Cases
Raspberry Pi - Lecture 4 Hardware Interfacing Special CasesMohamed Abdallah
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsMohamed Abdallah
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVRMohamed Abdallah
 
Linuxdd[1]
Linuxdd[1]Linuxdd[1]
Linuxdd[1]mcganesh
 
Device drivers Introduction
Device drivers IntroductionDevice drivers Introduction
Device drivers Introductionvijay selva
 
Linux kernel code
Linux kernel codeLinux kernel code
Linux kernel codeGanesh Naik
 
Gnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semGnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semSagun Baijal
 
Device Drivers in Linux
Device Drivers in LinuxDevice Drivers in Linux
Device Drivers in LinuxShreyas MM
 
Breaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success StoryBreaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success StorySage Sharp
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device driversAlexandre Moreno
 
Linux Kernel Introduction
Linux Kernel IntroductionLinux Kernel Introduction
Linux Kernel IntroductionSage Sharp
 

Destacado (20)

Raspberry Pi - Lecture 1 Introduction
Raspberry Pi - Lecture 1 IntroductionRaspberry Pi - Lecture 1 Introduction
Raspberry Pi - Lecture 1 Introduction
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OS
 
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry PiRaspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry Pi
 
Raspberry Pi - Lecture 4 Hardware Interfacing Special Cases
Raspberry Pi - Lecture 4 Hardware Interfacing Special CasesRaspberry Pi - Lecture 4 Hardware Interfacing Special Cases
Raspberry Pi - Lecture 4 Hardware Interfacing Special Cases
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication Protocols
 
Embedded C - Lecture 4
Embedded C - Lecture 4Embedded C - Lecture 4
Embedded C - Lecture 4
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVR
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Embedded C - Lecture 3
Embedded C - Lecture 3Embedded C - Lecture 3
Embedded C - Lecture 3
 
Embedded C - Lecture 2
Embedded C - Lecture 2Embedded C - Lecture 2
Embedded C - Lecture 2
 
Plc dasar
Plc dasarPlc dasar
Plc dasar
 
Linuxdd[1]
Linuxdd[1]Linuxdd[1]
Linuxdd[1]
 
Device drivers Introduction
Device drivers IntroductionDevice drivers Introduction
Device drivers Introduction
 
Linux kernel code
Linux kernel codeLinux kernel code
Linux kernel code
 
Gnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semGnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-sem
 
Device Drivers in Linux
Device Drivers in LinuxDevice Drivers in Linux
Device Drivers in Linux
 
Breaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success StoryBreaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success Story
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
Linux Device Driver’s
Linux Device Driver’sLinux Device Driver’s
Linux Device Driver’s
 
Linux Kernel Introduction
Linux Kernel IntroductionLinux Kernel Introduction
Linux Kernel Introduction
 

Similar a Raspberry Pi - Lecture 6 Working on Raspberry Pi

Raspi_TOR_Access_Point_BenMoore
Raspi_TOR_Access_Point_BenMooreRaspi_TOR_Access_Point_BenMoore
Raspi_TOR_Access_Point_BenMooreBenjamin Moore
 
Project-make a public website server using raspberry pi
Project-make a public website server using raspberry piProject-make a public website server using raspberry pi
Project-make a public website server using raspberry piFahim Hossain
 
manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfssuserc5ee4c
 
introduction to Raspberry pi
introduction to Raspberry pi introduction to Raspberry pi
introduction to Raspberry pi Mohamed Ali May
 
Hadoop on raspberry pi PART 1
Hadoop on raspberry pi PART 1Hadoop on raspberry pi PART 1
Hadoop on raspberry pi PART 1Aniket Maithani
 
Up and running with Raspberry Pi
Up and running with Raspberry PiUp and running with Raspberry Pi
Up and running with Raspberry PiShahed Mehbub
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry PiLloydMoore
 
Raspberry pi tutorial
Raspberry pi tutorialRaspberry pi tutorial
Raspberry pi tutorialImad Rhali
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218CAVEDU Education
 
Raw Iron to Enterprise Server: Installing Domino on Linux
Raw Iron to Enterprise Server: Installing Domino on LinuxRaw Iron to Enterprise Server: Installing Domino on Linux
Raw Iron to Enterprise Server: Installing Domino on LinuxDevin Olson
 
Rasperry pi Part 12
Rasperry pi Part 12Rasperry pi Part 12
Rasperry pi Part 12Techvilla
 
Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started동호 손
 
Wireshark OTG Extend your Wireshark with extcap.pdf
Wireshark OTG Extend your Wireshark with extcap.pdfWireshark OTG Extend your Wireshark with extcap.pdf
Wireshark OTG Extend your Wireshark with extcap.pdfMegumi Takeshita
 
Workshop Raspberry Pi NAS with Windows Share
Workshop Raspberry Pi NAS with Windows ShareWorkshop Raspberry Pi NAS with Windows Share
Workshop Raspberry Pi NAS with Windows ShareMichael Plate
 
Raspberry pi Board Hardware & Software Setup
Raspberry pi Board Hardware & Software SetupRaspberry pi Board Hardware & Software Setup
Raspberry pi Board Hardware & Software SetupRANAALIMAJEEDRAJPUT
 

Similar a Raspberry Pi - Lecture 6 Working on Raspberry Pi (20)

Raspi_TOR_Access_Point_BenMoore
Raspi_TOR_Access_Point_BenMooreRaspi_TOR_Access_Point_BenMoore
Raspi_TOR_Access_Point_BenMoore
 
Project-make a public website server using raspberry pi
Project-make a public website server using raspberry piProject-make a public website server using raspberry pi
Project-make a public website server using raspberry pi
 
manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdf
 
Ex.no1
Ex.no1Ex.no1
Ex.no1
 
introduction to Raspberry pi
introduction to Raspberry pi introduction to Raspberry pi
introduction to Raspberry pi
 
Lab manual
Lab manualLab manual
Lab manual
 
Hadoop on raspberry pi PART 1
Hadoop on raspberry pi PART 1Hadoop on raspberry pi PART 1
Hadoop on raspberry pi PART 1
 
Up and running with Raspberry Pi
Up and running with Raspberry PiUp and running with Raspberry Pi
Up and running with Raspberry Pi
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry Pi
 
Raspberry pi tutorial
Raspberry pi tutorialRaspberry pi tutorial
Raspberry pi tutorial
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 
Raspbery pi commands
Raspbery pi commandsRaspbery pi commands
Raspbery pi commands
 
Raw Iron to Enterprise Server: Installing Domino on Linux
Raw Iron to Enterprise Server: Installing Domino on LinuxRaw Iron to Enterprise Server: Installing Domino on Linux
Raw Iron to Enterprise Server: Installing Domino on Linux
 
Rasperry pi Part 12
Rasperry pi Part 12Rasperry pi Part 12
Rasperry pi Part 12
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 
Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started
 
Wireshark OTG Extend your Wireshark with extcap.pdf
Wireshark OTG Extend your Wireshark with extcap.pdfWireshark OTG Extend your Wireshark with extcap.pdf
Wireshark OTG Extend your Wireshark with extcap.pdf
 
Workshop Raspberry Pi NAS with Windows Share
Workshop Raspberry Pi NAS with Windows ShareWorkshop Raspberry Pi NAS with Windows Share
Workshop Raspberry Pi NAS with Windows Share
 
Raspberry pi Board Hardware & Software Setup
Raspberry pi Board Hardware & Software SetupRaspberry pi Board Hardware & Software Setup
Raspberry pi Board Hardware & Software Setup
 
main
mainmain
main
 

Último

Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfisabel213075
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Romil Mishra
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming languageSmritiSharma901052
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfPaper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfNainaShrivastava14
 

Último (20)

Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdf
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming language
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfPaper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
 

Raspberry Pi - Lecture 6 Working on Raspberry Pi

  • 1. Prepared by: Mohamed AbdAllah Raspberry pi interfacing Lecture 6: Working on raspberry pi 1
  • 2. Lecture Agenda  Installing Linux on the Pi.  Setting a static IP address.  Setting a local host name.  Configuring the Wi-Fi dongle.  Working with Pi GPIO.  Working with Pi UART.  Working with Pi PWM. 2
  • 5.  Downloading Linux image • Download Linux image for raspberry pi, for example download the Raspbian image from the following website: http://raspberrypi.org/  Image extracting • Decompress the downloaded file, rename the decompressed file to any name for easier access using command line, for example let the file name be (assuming in home directory): ~/RaspberryImage.img  Installing the image • Put the SD Card in the computer and format it first (using disks utility for example, you can type “disks” in the already installed applications). Installing Linux on the Pi 5
  • 6. • Then type the following command in the terminal to know the SD Card name (Note the $ is just indication that this is a command, don’t write it in your commands): $ dmesg • Then search in the last few lines for SD Card name, for example sdb (Note we will ignore sdb0 and sdb1 and so on as those are just the SD Card internal partitions if you didn’t format the card). • Type on the terminal and wait about 5 minutes to finish: $ sudo dd bs=4M if=~/RaspberryImage.img of=/dev/sdb • Now the Pi is ready to boot, connect your SD Card, keyboard, mouse, HDMI cable, LAN cable and WiFi dongle to the Pi and start working. • Note that normally the HDMI cable will work automatically, but on some cases if it didn’t work, we need to edit some configurations as we will illustrate next. Installing Linux on the Pi 6
  • 7.  Configuring the HDMI • In case that the HDMI didn’t work automatically, connect the SD Card to the computer and open the file called config.txt inside the SD Card boot partition. • Note that you need to open it as root, in the command line type: $ sudo gedit And before hitting Enter key, drag the config.txt file from its place and drop it beside your command to automatically paste its path, then hit Enter. • The file after editing should look the same like this: Installing Linux on the Pi 7
  • 8.  Configuring the HDMI Installing Linux on the Pi 8
  • 9.  Configuring the HDMI Installing Linux on the Pi 9
  • 10.  Configuring the HDMI • Now remove the SD Card from your computer and connect it to the Pi and start it and it the HDMI now should work.  First steps on the Pi • At the first time the Pi boots it shows a configuration screen, you can edit the configurations now or later after login by opening the same screen by typing the command $ sudo raspi-config  Choose Expand File System option.  Choose on advanced options to enable SSH, I2C, SPI.  Choose update. • After update, login by using “pi” as user name, and “raspberry” as password • Type the following commands $ sudo apt-get update $ sudo apt-get upgrade Installing Linux on the Pi 10
  • 11.  First steps on the Pi • Now reboot the Pi $ sudo reboot • To connect remotely to the Pi using your PC inside the same network, we need first to know the Pi IP address, so on the Pi type the command $ ifconfig • You will find the Pi IP address beside the interface “eth0” as now we are connected to the network through LAN cable. • Assuming that you found that the Pi IP is 192.168.1.2, now on your PC while you are connected on the same network, type the following $ sudo ssh pi@192.168.1.2 • Then if prompted, type yes and hit enter to confirm the connection • Then type “pi” as user name, and “raspberry” as password, and now you are one the Pi command line so any command you type is actually executed on the Pi not on your PC. Installing Linux on the Pi 11
  • 12. Setting a static IP address 12
  • 13. • The IP address we used to connect to the Pi may be changed by the network router, so to make it static edit the following file on the Pi : /etc/network/interfaces • First we need to prepare the configurations, on the Pi type $ ifconfig You will se something like this, store those numbers as we will need them Setting a static IP address 13
  • 14. • Then type $ netstat -nr You will se something like this, store those numbers as we will need them • Now type: $ sudo nano /etc/network/interfaces • Uncomment the following line to look like this: • Add after that line the following lines Setting a static IP address 14
  • 15. • The file after editing should look like this, now close the file by hitting CTRL+X and hit Enter: • Now whenever the Pi boots, it will automatically take the IP 192.168.1.2 Setting a static IP address 15
  • 16. Setting a local host name 16
  • 17. • The problem of the static IP address is the when we move to another network with other configurations it will not work, so we will give the Pi a local host name that we can deal with the Pi using that name whatever its IP. • First type the following command to set password for root user as we will need it $ sudo passwd • Then we need to undo the configurations of the static IP, open the same file again /etc/network/interfaces and undo all changes again Setting a local host name 17
  • 18. • Then type $ sudo apt-get install avahi-daemon • Now inside any network you can connect to the Pi using the name “raspberrypi.local”, and the root password $ sudo ssh raspberrypi.local *Note: You can switch to “pi” user by typing $ su pi • To change the name, change “raspberrypi” in the following 2 files to the name that you want (ex. “mynewname” or anything) $ sudo nano /etc/hosts $ sudo nano /etc/hostname • Then to commit, run the command multiple times until it run successfully without errors. $ sudo /etc/init.d/hostname.sh • Then reboot so you can use your new name $ sudo ssh mynewname.local Setting a local host name 18
  • 20. • First to know the manufacturer of the WiFi dongle type: $ dmesg | grep usb • You will see something like this • As we can see it is Realtek. Configuring the Wi-Fi dongle 20
  • 21. • Then type the following commands: $ sudo apt-cache search firmware wireless $ sudo apt-get install firmware-realtek • Then edit the interfaces file $ sudo nano /etc/network/interfaces • Replace the following lines: With the following lines: Configuring the Wi-Fi dongle 21
  • 22. • Then type the following command: $ sudo nano /etc/wpa.conf • Type the following lines, replace “networkname” with your WiFi network name, and “network passkey” with your WiFi network pass key: *Note that there is no space after the = sign • Now shutdown and remove the LAN cable then start the Pi with the WiFi dongle only and it will automatically access the network, you can access it remotely using the same name “raspberrypi.local” or the name you gave to it. Configuring the Wi-Fi dongle 22
  • 23. Working with Pi GPIO 23
  • 24. Working with Pi GPIO 24
  • 25. • To interact with Pi GPIO (Make pi input or output, read pin value or write to pin logic high or logic low value), first create empty file: $ nano GPIO_python.py • Write the following lines in the file, here we are making LED ON for 5 seconds then OFF on GPIO17: Working with Pi GPIO 25
  • 26. • Now close the file, then add execute permission to it: $ sudo chmod u+x GPIO_python.py • Now execute the script by typing: $ sudo ./GPIO_python.py Working with Pi GPIO 26
  • 27. • To make LED Flasher each 1 second on GPIO17, create new script as previous example: Working with Pi GPIO 27
  • 28. • To take input from GPIO4, if logic high the make the LED connected to GPIO17 to be ON, else make LED OFF, create new script: Working with Pi GPIO 28
  • 29. Working with Pi UART 29
  • 30. • To interact with Pi UART, first we need to prevent the kernel from sending any messages to the UART port by editing these files:  First backup the original file $ sudo cp /boot/cmdline.txt /boot/cmdline_bp.txt  Change this file configurations $ sudo nano /boot/cmdline.txt  Remove ttyAMA0,115200, final line should be something like this:  Change this file configurations $ sudo nano /etc/inittab  Comment out the line that contains ttyAMA0 115200, by putting # in its start • Reboot and now the UART port is ready to be used. $ sudo reboot Working with Pi UART 30
  • 31. • To send and receive bytes on UART port, create new script: Working with Pi UART 31
  • 32. • To observe what you receive on the serial port you can use a program like minicom, to install it: $ sudo apt-get install minicom • To edit program configurations: $ sudo minicom -s • To edit port name press Shift+A, and change it to be /dev/ttyAMA0. • To edit baud rate press Shift+E, then Shift+C for 9600. • Now choose save as dfl to save this configurations as default, then Exit. • To use the program at any time, type the following and observe what you receive on the UART port: $ sudo minicom Working with Pi UART 32
  • 33. Working with Pi PWM 33
  • 34. • To output a soft PWM signal on any GPIO for example GPIO27, create new script: Working with Pi PWM 34
  • 35. • Useful methods: Working with Pi PWM 35
  • 36. Mohamed AbdAllah Embedded Systems Engineer mohabdallah8@gmail.com 36