0% found this document useful (0 votes)
6 views14 pages

Unit V

The document provides an overview of Raspberry Pi, highlighting its features, differences from Arduino, and various models including Raspberry Pi 3. It details the setup process, operating systems, and configuration commands necessary for effective use. Additionally, it introduces Python programming on Raspberry Pi and its characteristics, emphasizing its versatility and integration capabilities.

Uploaded by

Nikhil bhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views14 pages

Unit V

The document provides an overview of Raspberry Pi, highlighting its features, differences from Arduino, and various models including Raspberry Pi 3. It details the setup process, operating systems, and configuration commands necessary for effective use. Additionally, it introduces Python programming on Raspberry Pi and its characteristics, emphasizing its versatility and integration capabilities.

Uploaded by

Nikhil bhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

UNIT V- Implementation using Raspberry Pi

What Is a Raspberry Pi?


A Raspberry Pi is a single-board computer, complete with Linux operating system, USB
connections for keyboard and mouse, and an HDMI connector for attaching a monitor.

Difference between Raspberry Pi and Arduino:


The Raspberry Pi is a single board computer with Microprocessor whereas Arduino is
considered as Microcontroller unit.

The Raspberry Pi can run an OS (Linux Distribution) and also consumes more power. Since
Arduino is microcontroller device it has no operating system and can only run a single
program or sketch.

Raspberry Pi also becomes a good choice for building IOT (Internet of Things) .

Introduction to Raspberry Pi 3.

Raspberry Pi 3 is tiny single board computer, introduced by Raspberry Pi Foundation, that


comes with CPU, GPU, USB ports and i/o pins and capable of doing some simple functions
like regular computer.
● Raspberry Pi 1(first generation Model B) came into play in 2012,
● Raspberry Pi 2 was introduced in Feb,2015 will little improvement in design with
added RAM than its previous version.
● Introduced in 2016, Raspberry Pi 3 Model B comes with a quad core processor that
shows robust performance which is 10 times more than Raspberry Pi 1. And speed
exhibits by Raspberry Pi 3 is 80% more than Raspberry Pi 2.
● The Raspberry hardware has gone through a number of variations in terms of
peripheral device support and memory capacity
● WiFi and Bluetooth that lack in older versions(Pi 1 and Pi 2), are added in the new
addition of this device(Pi 3), allowing to maintain the connection with the peripherals
without the involvement of any physical connection
● Raspberry Pi Foundation recently launched Raspberry Pi 3 Model B+ on 14 March
2018, which is the most recent version of Raspberry Pi 3 that exhibits all the
specifications introduced in Pi 3 Model B, with the additional improvement including
Network boot, USB boot, and Power over Ethernet which make the device useful in
hard to reach places.
Apply working with Raspberry pi 3 model:

● Raspberry Pi 3 Model B comes with 64 bit quad core processor, on board WiFi and
Bluetooth and USB features.
● It has a processing speed ranging from 700 MHz to 1.4 GHz where RAM memory
ranges from 256 to 1GB.
● The CPU of this device is considered as the brain of the device which is responsible
for executing numbers of instructions based on mathematical and logical operation.
● The GPU is another advanced chip incorporated in the board that carries out function
of image calculation. The board is equipped with Broadcam video core cable that is
mainly used for playing video games through the device.
● The Pi 3 comes with GPIO (General Purpose Input Output) pins that are essential to
maintain connection with other electronic devices. These input output pins receive
commands and work based on the programming of the device.
● The Ethernet port is incorporated on this device that sets a pathway for
communicating with other devices. You can connect Ethernet port to the router to
maintain a connection for internet.
● The Board has four USB ports that are used for communication and SD card is added
for storing the operating system.
● Power source connector is a basic part of the board that is used to provide 5 V power
to the board. You can use any source to set up a power for the board, however, it is
preferred you connect power cable through laptop USB port for providing 5 V.
● The Pi 3 supports two connection options including HDMI and composite. The
HDMI connector is used to connect LCD or TV, that can support 1.3 and 1.4 version
cables. Composite video connection is used to connect the older version of TV with
the device that uses the 3.5mm jack socket for the audio production.
● The new device comes with a video core multimedia 3D graphics which is capable of
playing 1080 MP video. This feature puts this advice ahead of its predecessors where
video quality was not that much upgraded.
● The USB hard drive incorporated on the board is used to boot the device, similar to
PC hard drive where windows is used to boot the computer hard drive.

Operating System:

● The Foundation provides Raspbian, a Debianbased Linux distribution for download,


as well as third party include Ubuntu MATE, Snappy Ubuntu Core, Windows 10 IOT
Core, RISC OS, and specialised Kodi media center distributions.
● It promotes Python and Scratch as the main programming language, with support for
many other languages.
● The default firmware is closed source, while an unofficial open source is available.

Linux based Operating System:


● Android Things
● Arch Linux
● OpenSuse
● Raspberry Pi Fedora Remix
● Pidora
● Gentoo Linux
● CentOS Raspberry Pi
● Kali Linux
● Slackware ARM
● Puppy Linux

Processor:
• The Raspberry Pi 3 uses a Broadcom BCM2837 SoC with a 1.2 GHz 64-bit
quad-core ARM Cortex-A53 processor, with 512 KB shared L2 cache

Performance:
● The Raspberry Pi 3, with a quad-core Cortex-A53 processor, is described as 10 times
the performance of a Raspberry Pi
● Raspberry Pi 3 to be approximately 80% faster than the Raspberry Pi 2 in parallelized
tasks.

RAM: The Raspberry Pi 2 and the Raspberry Pi 3 have 1 GB of RAM.

Networking:

The Raspberry Pi 3 and Pi Zero W (wireless) are equipped with 2.4 GHz WiFi
802.11n (150 Mbit/s) and Bluetooth 4.1 (24 Mbit/s) based on Broadcom BCM43438
FullMAC chip with no official support for Monitor mode but implemented through unofficial
firmware patching and the Pi 3 also has a 10/100 Ethernet port.

Installing OS:

To set up your Raspberry Pi, you need the following items:

• A USB keyboard and mouse (standard PC peripherals are just fine)


• A monitor or TV with an HDMI input and an HDMI cable
• A 5V microUSB power supply (at least 1 Amp)
• An Ethernet cable to reach to your router, or a USB to WiFi adapter
• A microSD card (4GB OK but 8GB will give you more room for your own files and any
programs that you download; choose a microSD card described as class 10, as this will help
with performance
• A second computer and microSD card adapter to set up the SD card (alternatively, you can
buy a microSD card with NOOBS—that is, New Out Of the Box Software— preinstalled)
Preparing a MicroSD Card with NOOB

When the Raspberry Pi was first launched, use special image writing software to set
up an SD card. However, NOOBS changed all that—it’s as easy to install as copying files
onto the SD card and no special formatting is required.

When Raspberry Pi boots up into NOOBS it will offer a choice of operating system
Make sure that select the recommended option Raspbian. After a lot of file copying and a
reboot, Raspberry Pi will be ready to use.

At this point, have a USB WiFi adapter, configure it and join r wireless network using
the WiFi Config utility that will find under the Preferences section of the desktop menu.

Setting Up SSH

. SSH gives you command-line access to your Raspberry Pi over r network from a
second computer. This means that, once finished setting it up, the only things that need to be
plugged into Raspberry Pi are a power lead and either a network cable or USB WiFi adapter.

Click the LXTerminal icon at the top of your Raspberry Pi desktop

In the LXTerminal window that opens, type the following command (don’t include
the $—that’s the command-line prompt):
$ sudo raspi-config
SSH on a Windows Computer

If using Microsoft Windows, download and install Putty. The installation looks a little odd,
but actually, just download putty.exe, which is the program itself. just save it somewhere
and run it by doubleclicking it. This will open the PuTTY Configuration window

SSH on Mac or Linux

If using a Mac or a Linux computer, the software need to connect to Raspberry Pi is already
on computer
Open a terminal session and type the following command, substituting the IP address of your
Raspberry Pi in place of the IP address of my Raspberry Pi (192.168.1.23):
$ ssh 192.168.1.23 -l pi

Raspberry Pi – VNC Server Connection

● Download a VNC Viewer application for your laptop/PC/Mac such as:


● Enable VNC server on your raspberry pi
sudo apt-get update
sudo apt-get install
realvnc-vnc-server
realvnc-vnc-viewer
● sudo raspi-config
.Navigate to Interface Options, select VNC and click ‘yes’

Connecting to your Raspberry Pi with VNC Server


● Get the IP address of your RPi with ifconfig on the terminal
● Launch VNC Viewer on your laptop/PC
● Enter the Rpi’s IP address into VNC Viewer
● Click enter – it should connect.

Change the resolution of the VNC Desktop


● If you desktop appears to be a bit small and chunky, checkout this video:

The benefit of VNC Control


● You now have a remote connection !!
● You should be able to run your Python or Node JS tank movement code and control it
from your laptop!

Getting Introduced Linux OS Based Linux and Uses:

Operating System Debian Linux


● NOOBS – New Out Of the Box Setup is an easy operating system install manager for
the Raspberry Pi..
● Debian Linux is a Unix-like computer operating system and a Linux distribution that
is composed entirely of free and open-source software,
Versions of Linux available for Raspberry Pi
● RASPBIAN
● PIDORA
● OPENELC (media center)
● RASPBMC (media center)
● Minepeon (bitcoin)
● Kali Linux (security/hacking)

NOOBs New Out Of Box software


● In our kit we have an 32GB SD card which has a pre-installed version of Raspbian
already on it.
● This called a “New Out Of Box Software” or NOOBS installation. The only problem
with this is that it only allows works fat file system and at most 32GB. This might not
be satisfactory. Therefore other options must be used
● .NOOBS is a boot loader

Loading Process

● Kernel
● Services
● Login

Commands? Commands can be one of 4 different kinds:


● An executable program files in /usr/bin. Within this category, programs can be
compiled binaries such as programs written in C and C++, or programs written in
scripting languages such as the shell, Perl, Python, Ruby, etc.
● A command built into the shell itself. bash provides a number of commands
internally called shell built ins. The cd command, for example, is a shell built in.
More commands
● A shell function. These are miniature shell scripts incorporated into the environment.
We will cover configuring the environment and writing shell functions in later
lessons, but for now, just be aware that they exist.
● An alias. Commands that you can define yourselves, built from other commands

Command Line Operation


● ps – this command displays all running processes on our raspberry pi..

Network Address/ IP Address


● Type ip a s – this command allows us to determine our IP address.
It also shows local connection ( ), ethernet connection eth0 , wireless local access network or
wlan0 connection.
Raspberry Pi Configuration

● raspi-config (requires administration priviledges) so we can use the sudo command to


get to the setup menu.

Storage Information

● df –hT (show free space) root file system

Memory Available

● Use the command free –h


Operating system available memory 927

Used 183

Free 743

What storage devices are available?

● Use the command mount

--Only mounted is the file system / on the SD card

Processor Information

Type uname –a displays all the information to the screen.

Type uname –r displays kernel version

Wireless Configure Console

● Scanning the wireless network use:

sudo iwlist wlan0 scan

● Adding the network details to the Raspberry Pi

Open the wpa-supplicant configuration file in nano:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Implementing Configuration Changes


sudo ifdown wlan0 – this turns the wireless connection off.

sudo ifup wlan0 - this turns the wireless connection on.

● We can check to make sure the connection is successful by using this command

● ifconfig wlan0

● If the inet addr field has an address beside it, the Pi has connected to the network.
● Pi Users User management in Raspbian is done on the command line. The default
user is pi with the password raspberry. You can add users and change each user's
password.

Change your password

Use passwd – this command will change your password. CAUTION, once changed
you will need to store it somewhere.

Procedure:

Enter passwd on the command line and hit Enter.

--You'll be prompted to enter your current password to authenticate, and then asked
for a new password. Hit Enter on completion and you'll be asked to confirm it.

--Note that no characters will be displayed while entering your password. Once you've
correctly confirmed, you'll be shown a success message (passwd: password updated
successfully) and the new password will be in effect immediately.

-- sudo (superuser doer)sudo (/ˈsuːduː/ or /ˈsuːdoo/) is a program for Linux computer


operating systems that allows users to run programs with the security privileges of another
user, including the superuser.

The default pi user on Raspbian is a sudoer. This gives the ability to run commands as
root when preceded by sudo, and to switch to the root user with sudo su.

User Profiles

A normal user profile is described through the following hidden files.

● .bashrc

● .bashlogout

● .profile

● pistore.desktop

Deleting a user: sudo user del -r bob

Files Most common commands for manipulating files:

cp ( copy )

mv ( move)

~]$ mv file1 file2 --If file2 does not exist, then file1 is renamed file2.

~]$ mv file1 directory--Moves file1 to the director


rm ( remove )-- The rm command deletes (removes) files and directories.

chown ( change ownership )-- Change the owner of a file by using the chown command.

mkdir ( make directory )-- The mkdir command is used to create directories.

touch ( create empty file )

chmod--The chmod command is used to change the permissions of a file or directory.

Combining < and >

Using this combination,

command < file1 > file2

The command will receive input from file1 and output will be written to file2

Common filters

sort: Sorts standard input then outputs the sorted result on standard output.

uniq: Removes duplicate lines of data.

grep: Examines each line of data it receives from standard input and outputs every
line that contains a specified pattern of characters

. head: Outputs the first few lines of its input

.tail: Outputs the last few lines of its input.

Permissions File permissions: Ability to r)ead, w)rite, e(x)ecute.

Directory permissions: same format

Ownership: Creator(s) of files or directories.

Chgrp -- Changing Group Ownership

Linux on Raspberry pi

• Raspbian
• Raspbian Linux is a Debian Wheezy port optimized for Raspberry Pi.
• Arch
• Arch is an Arch Linux port for AMD devices.
• Pidora
• Pidora Linux is a Fedora Linux optimized for Raspberry Pi.
• RaspBMC
• RaspBMC is an XBMC media-center distribution for Raspberry Pi.
• OpenELEC
• OpenELEC is a fast and user-friendly XBMC media-center distribution.
• RISC OS
• RISC OS is a very fast and compact operating system.

Getting start with Python:


Characteristics of Python
● It supports functional and structured programming methods as well as OOP.
● It can be used as a scripting language or can be compiled to byte-code for building
large applications.
● It provides very high-level dynamic data types and supports dynamic type checking.
● It supports automatic garbage collection.
● It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
● It can be used to develop a large application with small codes.
Working with Python:

1. Python Interpreter: Python interpreter must be installed on your computer, to write


and execute a Python program. It is also called a Python shell.
2. >>> : Symbol >>> is called Python prompt.
3. Python prompt: Python prompt, which indicates that the interpreter is ready to
receive instructions. We can type commands or statements on this prompt for
execution.

Execution Mode
There are two ways to run a program using the Python interpreter:
a) Interactive mode and b) Script mode
(A) Interactive Mode
In the interactive mode, we can type a Python statement on the >>> prompt directly. As soon
as we press enter, the interpreter executes the statement and displays the result(s)

Executing code in Interactive mode


Advantages of using interactive mode :
● It is convenient for testing a single line code for instant execution.
The disadvantage of using Interactive mode :
● In the interactive mode, we cannot save the statements for future use and we have to
retype the statements to run them again.
(B) Script Mode
In the script mode, we can write a Python program in a file, save it and then use the
interpreter to execute the program from the file.
● Python program files have a .py extension.
● Python programs are also known as scripts.
● Python has a built-in editor called IDLE which can be used
to create programs / scripts.

Python IDLE :

IDLE: Integrated Development and Learning Environment


To Create a Program
● First open the IDLE,
● Click File>New File to create a new file,
● then write your program on that file and
● save it with the desired name.
By default, the Python scripts are saved in the Python installation folder.
To run/execute a program in script mode:
● Open the program using an IDLE editor
● In IDLE, go to [Run]->[Run Module] to execute the program
● The output appears on the shell.

Interface sensor with Raspberry pi:

Using Sensors with a Raspberry Pi


● As well as controlling outputs with the GPIO pins, the Raspberry Pi can collect data
about the outside world using sensors
● One powerful feature of the Raspberry Pi is the row of GPIO (general purpose
input/output) pins along the top edge of the board. These pins are a physical interface
between the Pi and the outside world

A push button is an input component that you can add to the Raspberry Pi GPIO pins. It will
complete a circuit when the button is pressed

A passive infrared sensor or PIR detects movement.

● Every object whose temperature is above absolute zero emits infrared (IR) radiation.
The sensor measures the IR signature of the room it’s in, and then watches for any
changes. Any object moving through the room will disturb the IR signature, and will
cause a change to be noticed by the PIR module.

● A Light Dependent Resistor or photocell is a component whose resistance will


change depending on the intensity of light shining on it. It can therefore be used to
detect changes in light. They are commonly used with street lighting, to make
streetlamps turn on when it gets dark at night and off when it gets light in the
morning.

● An air quality sensor is used to determine air quality by detecting polluting gases.
When air enters the sensor, it is energised by a small heater which allows its electrical
resistance to be measured.

Sense HAT( Hardware Added on Top)

The Sense HAT board for the Raspberry Pi has the ability to sense a wide variety of
conditions and provide output via the built-in LED matrix.

The Sense HAT has the following sensors:


● A gyroscope measures the orientation of an object.
● An accelerometer measures an object’s increase in speed (acceleration)
● A magnetometer is used to measure the strength and direction of a magnetic field.
● A temperature sensor is used to measure hot and cold.
● A humidity sensor measures the amount of water vapour in the air.
● A pressure sensor (sometimes called a barometer) measures the force exerted by tiny
molecules of the air we breathe

Explorer HAT

● It has eight capacitive touch pads.


● A capacitive touch sensor detects when the metal pads connect with a person or
object carrying a small electrical charge. Touching one of the eight capacitive touch
pads on the Explorer HAT triggers an event, just like pressing a switch or button.

Interface Actuators with Raspberry pi:

Interfacing of DC motors with Raspberry Pi 3

The main principle in controlling a DC Motor with Raspberry Pi lies with the Motor
Driver.
● A Motor Driver is a special circuit or IC that provides the necessary power (or
rather the current) to the motor for smooth and safe operation.
● Even a small 5V DC Motor draws a high initial current of around 300 – 400
mA. This current will then fall down 150 – 200 mA as the motor gains speed
to around.
● This is a huge current for devices like Microcontrollers, Arduino, Raspberry
Pi etc. Hence, we should never connect a motor directly to Raspberry Pi (or
any other microcontroller).
● Motor Driver play an important role in this situation. They take the control
signals from Raspberry Pi and provide the necessary drive current to the
motor from the power supply.
● , the motor driver (L293D) is given with two control signals from Raspberry
Pi through GPIO Pins. As per the Python Program, the motor will rotate in
either forward or reverse direction.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy