Lecture 16 - Rpi-Final PDF
Lecture 16 - Rpi-Final PDF
Lecture 16 - Rpi-Final PDF
5v micro
USBconnector
DSI
(display
interface) CSI
(camera
interface)
SOC(System On a Chip)
Broadcom BCM2835 700Mhz
EEE G627: Networked Embedded Applications (Dr. Vinay Chamola, BITS-Pilani)
Storage
SDCard Slot
(supports SDcards up to 32GB)
Rpi 3 Module B
Add-ons
Handle with care
• The Raspberry Pi was built to be used, but not abused.
Every P.C.B. should be handled with care.
• Handle the Pi only by the edges of the board itself. Avoid
touching or holding any of the components on the board.
• Rough Handling can cause solder points to fail and may result inshort
circuits, but be careful with the GPIO pins as well. Best practice: Use
the Rpi Case
• While connecting Hardware, double check the connections and then
power it up. Raspberry Pi GPIO’s are not 5V tolerant.
Ground
• The Ground pins on the Raspberry Pi are all electrically connected, so
it doesn't matter which one you use if you're wiring up a voltage
supply.
• Generally the one that's most convenient or closest to the rest of your
connections is tidier and easier, or alternatively the one closest to the
supply pin that you use.
WiringPi
• WiringPi is an attempt to bring Arduino-wiring-like simplicity tothe
Raspberry Pi.
• The goal is to have a single common platform and set of functions for
accessing the Raspberry Pi GPIO across multiple languages. WiringPi
is a Clibrary at heart, but it's available to both Ruby and Pythonusers
who can "gem install wiringpi" or "pip install wiringpi2" respectively.
• WiringPi uses its own pin numbering scheme.
Setting up Raspberry pi (NOOBssetup)
• How to get and installNOOBS?
• BUY PREINSTALLED SD CARD
1. SDcards with NOOBSpreinstalled are available from many distributors and independent
retailers, such asPimoroni, Adafruit and The Pi Hut. For older models of Raspberry Pi, you’ll
need a full-size SDcard; for the Pi Zero, A+, B+, Pi 2 and Pi 3 you’ll need a micro SDcard.
• DOWNLOAD
1. recommended to use an SDcard with a minimum capacity of 8GB.
2. Using a computer with an SDcard reader, visit the Downloads page.
3. Click on NOOBS, then click on the Download ZIPbutton under ‘NOOBS (offline and network
install)’, and select a folder to save it to.
4. Extract the files from thezip.
Contd…
• FORMAT YOUR SD CARD
1. It is best toformat your SDcard before copying the NOOBSfiles onto it.
To dothis:
2. Visit the SDAssociation’s website and download SDFormatter 4.0 for
either Windows or Mac.
3. Follow the instructions to install the software.
4. Insert your SDcard into the computer or laptop’s SDcard reader and
make a note of the drive letter allocated to it, e.g. G:/
5. In SDFormatter, select the drive letter for your SDcard and format it.
Contd…
• DRAG AND DROP NOOBSFILES
1. Once your SDcard has been formatted, drag all the files in the
extracted NOOBSfolder and drop them onto the SDcarddrive.
2. The necessary files will then be transferred to yourSDcard.
3. When this process has finished, safely remove the SDcard and
insert it into yourRaspberry Pi.
Contd…
• FIRST BOOT
1. Plug in your keyboard, mouse, and monitor cables.
2. Now plug the USBpower cable into your Pi.
3. Your Raspberry Pi will boot, and a window will appear with a list of different operating
systems that you can install. We recommend that you use Raspbian – tick the box next
to Raspbian and click on Install.
4. Raspbian willthen run through its installation process. Note that this can take a while.
5. When the install process has completed, the Raspberry Pi configuration menu (raspi-
config) will load. Here you are able to set the time and date for your region, enable a
Raspberry Pi camera board, or even create users. Youcan exit this menu by
using Tab on your keyboard to move to Finish.
EEE G627: Networked Embedded Applications (Dr. Vinay Chamola, BITS-Pilani)
Powering up the Rpi
SSH(Secure Shell)
• SSH,or Secure Shell, is a protocol used to securely log onto remote
systems. It is the most common way to access remote Linux andUnix-
like servers.
• ssh remote_host
• The remote_host in this example is the IP address or domain name
that you are trying to connectto.
IMP…(EnableSSH)
• As of the November 2016 release, Raspbian has the SSHserver disabled by
default. It can be enabled manually from the Raspberry pi desktop (must have a
keyboard, mouse, and a display attached to the RPI)
• Launch Raspberry Pi Configuration from the Preferencesmenu
• Navigate to the Interfacestab
• Select Enabled next to SSH
• Click OK
Enable SSHon a headless Raspberry Pi (add file to
SDcard on another machine)
• For headless setup, SSHcan be enabled by placing a file named ssh,
without any extension, onto the boot partition of the SDcard from
another computer. When the Pi boots, it looks for the ssh file. If it is
found, SSHis enabled and the file is deleted. The content of the file
does not matter; it could contain text, or nothing at all.
• If you have loaded Raspbian onto a blank SDcard, you will have two
partitions. The first one, which is the smaller one, is the boot
partition. Place the file into thisone.
Connect the Rpi by Ethernet to your PC
Finding IPaddress
• For own System
• Cmd prompt:
ipconfig
• FOR R-Pi
• Terminal
ifconfig
SSHusing Windows (putty)
• In Windows you will need to download an SSHclient. The most commonly used
client is called PuTTY. Look for putty.exe under the heading For Windows onIntel
x86.
• Type the IP address of the Pi into the Host Name field and click the Openbutton.
If nothing happens when you click the Open button, and you eventually see a
message saying Network error: Connection timed out, it is likely that you have
entered the wrong IP address for the Pi.
CONNECT
• When the connection works you will see the security warning shown
below. You can safely ignore it, and click the 'Yes' button. You will only
see this warning the first time PuTTYconnects to a Raspberry Pi that
it has not seenbefore.
Contd…
• You will now see the usual login prompt. Log in with the same username
and password you would use on the Pi itself. The default login for Raspbian
is
• Login: pi
• Password: raspberry.
• You should now have the Raspberry Pi prompt which will be identical to the
one found on the Raspberry Piitself.
• pi@raspberrypi ~ $
• Detailed instruction to set upputty.
• https://www.raspberrypi.org/documentation/remote-
access/ssh/windows.md
Type arp –a on your laptop cmd prompt
SSHusing MAC
• You can use SSHto connect to your Raspberry Pi from a Linux
computer, a Mac, or another Raspberry Pi, without installing
additional software
• “ssh pi@<IP>”
• Where IP refers to the IP address of raspberry pi found earlier.
VNCremote access toRpi
• VNC (Virtual Network Computing) is a great technology included with
Raspbian. With this tech, you can remotely control your Raspberry Pi
from another computer, such as a PCor Mac, or even another
Raspberry Pi board.
• Sometimes it’s not convenient to work directly on a Raspberry Pi.This
can be because it’s not easy to access, or because your keyboard and
monitor are being used on your main computer.
• Using remote networking, you can open the Raspbian desktop
interface from your Raspberry Pi inside a window on your computer.
Contd…
• By default, VNC Server from RealVNC gives you direct control over your Raspberry
Pi, just as though you were sitting in front of it.
• However, you will need to enable it yourself. From then on, Server will be loaded
every time you switch on your Raspberry Pi.(Just like we enabled SSH)
• raspi-config can be used in the terminal:
• Enter ”sudo raspi-config” in a terminal window (This is once we havealready
SSHed into theRpi)
• Select Interfacing Options
• Navigate to and select VNC
• Choose Yes
• Select Ok
• Choose Finish
Contd…
• Download and install Viewer on your computer from RealVNC.Open
the app and enter the IPAddress of the Rpi into the VNC Server field.
Ensure Encryption is set to “Let VNCServer choose” and click
Connect. OK. The first time you connect it will display a “VNC Server
not recognized” alert. ClickContinue.
• Enter Pi into the Username field, and “raspberry” (or yourRaspbian
password) in the Password field. The Raspbian PIXELinterface will
appear inside a window on your computer. You can click on the
Menu, open programs and run Terminal commands on your
Raspberry Pi. If you have your Raspberry Connected to a monitor,
you’ll see it move as you remote control it.
LEDBlink
(“Hello World” of Physical computing)
• The simplest thing you can do with an Raspberry Pi to see an actual
physical output is to blink an LED! It’s more like an electronicsversion
of the classical hello world program that we write when learning a
new software language.
• Raspberry Pi has 8 General Purpose Input/Output pins(
4,17,18,21,22,23,24,25) which can be configured as input/output
and turned on/off via software.
• RPi.GPIO Python library is used to control the LEDfrom RaspberryPi.
Only SSH With VNC
>> sudo nano Led.py See in the Rpi desktop
Python (RPi.GPIO)API
• In order to use RPi.GPIO throughout the rest of yourPython script,
you need to put this statement at the top of your file:
GPIO.setmode(GPIO.BOARD)
Setting a Pin Mode
• If you’ve used Arduino, you’re probably familiar with the fact that you
have to declare a “pin mode” before you can use it as either an input
or output.
• To set a pin mode, use the setup([pin], [GPIO.IN, GPIO.OUT] function.
So, if you want to set pin 18 as an output, for example,write:
GPIO.setup(18, GPIO.OUT)
Outputs
1. Digital Output
• Itwill read pin 17 and print whether it’s being read as HIGH or LOW.
Delays
• If you need to slow your Python script down, you can add delays.To
incorporate delays into your script, you’ll need to include another
module: time. This line, at the top of your script, will do it for you:
include time
• Save the file in “.py” format at the desktop or wherever you may wish.
PIN 14
PIN 11
PIN 1
Code
PWM
PIN 14
PIN 12
PIN 1
PWM