0% found this document useful (0 votes)
137 views94 pages

F-IoT Unit-3

The document provides an overview of Python programming and its use in Internet of Things applications. It discusses Python's characteristics such as being a multi-paradigm and interpreted language. The document also covers Python data types like numbers, strings and lists as well as how to work with them.
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)
137 views94 pages

F-IoT Unit-3

The document provides an overview of Python programming and its use in Internet of Things applications. It discusses Python's characteristics such as being a multi-paradigm and interpreted language. The document also covers Python data types like numbers, strings and lists as well as how to work with them.
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/ 94

ANURAG COLLEGE OF ENGINEERING

(Approved by AICTE, New Delhi & Affiliated to JNTU-HYD)


Aushapur (V), Ghatkesar (M), Medchal (Dist.), Telangana-501 301.

FUNDAMENTALS OF INTERNET OF THINGS


B.Tech - III YEAR II SEM - CSE

Presented By:

G. Kiran Kumari
Assistant Professor
Department of ECE
Anurag College of Engineering
Syllabus

UNIT – III

Introduction to Python programming,


Introduction to Raspberry Pi, Interfacing
Raspberry Pi with basic peripherals,
Implementation of IoT with Raspberry Pi

Anurag College of Engineering 2


Introduction to Python
• Python is a general-purpose high-level language
programming language.
• It is simple, easy to learn, and very powerful.
• Python does not require a compilation step prior to being
used.
• Python applications or file names end in .py
• This is very powerful; but unless a Python development
environment is used, some syntax errors will not be
discovered until the application is executed.
• Python provides a robust exception-handling mechanism.
• Python was named after the British comedy troupe Monty
Python. 3
Anurag College of Engineering
Characteristics of Python

The main characteristics of Python are:

• Multi-paradigm programming language


• Interpreted language
• Interactive language

4
Anurag College of Engineering
Multi-paradigm programming language:
• Python supports more than one programming
paradigm including object-oriented programming and
structured programming.
Interpreted language:
• Python is an interpreted language and does not require an
explicit compilation step.
• The Python interpreter executes the program source code
directly, statement by statement, as a processor or
scripting engine does.
Interactive language:
• Python provides an interactive mode in which the user
can submit commands at the Python prompt and interact
with the interpreter directly.
5
Anurag College of Engineering
Benefits of Python
The key benefits of Python are:
• Easy-to-learn, read and maintain
• Object and Procedure Oriented
• Extendable
• Scalable
• Portable
• Broad library support

Anurag College of Engineering 6


Easy-to-learn, read and maintain :
• Python is a minimalistic language with relatively few
keywords and has fewer syntactical constructions as
compared to other languages.
• Reading Python programs is easy with pseudo-code like
constructs.
• Python is easy to learn , an extremely powerful language
for a wide range of applications.
• Due to its simplicity , programs written in Python are
generally easy to maintain.

7
Anurag College of Engineering
Object and procedure oriented :
• Python supports both procedure-oriented programming
and object-oriented programming.
• Procedure oriented paradigm allows programs to be
written around procedures or functions that allow reuse
of code .
• Object oriented paradigm allows programs to be written
around objects that include both data and functionality.

8
Anurag College of Engineering
Extendable:
• Python is an extendable language and allows integration
of low-level modules written in languages such as
C/C++. This is useful to speedup a critical portion of a
program.

Scalable:
• Due to the minimalistic nature of Python, it provides a
manageable structure for large programs.

9
Anurag College of Engineering
Portable:
• Python programs can be directly executed from source
code and copied from one machine to other without
worrying about portability.
• Since Python is an interpreted language , programmers
do not have to worry about compilation , linking and
loading of programs.
• The Python interpreter converts the source code to an
immediate form called byte codes and then translates this
into the native language of the system and then runs it.

10
Anurag College of Engineering
Broad Library Support:

• Python has a broad library support and works on various


platforms such as Windows ,Linux, Mac, etc.
• There are a large number of Python packages available
for various applications such as machine learning , image
processing , network programming , cryptography, etc.

11
Anurag College of Engineering
Python Data Types and Data Structures

Numbers

• Number data type is used to store numeric values.


• Numbers are immutable data types, therefore
changing the value of a number data type results in
a newly allocated object.

12
Anurag College of Engineering
Working with Numbers in Python
Integer:
>>>a=5
>>>type(a)
<type ‘int’>

Floating Point:
>>>b=2.5
>>>type(b)
<type ‘float’>

13
Anurag College of Engineering
Long:
>>>x=9898878787676L
>>>type(x)
<type ‘long’>

Complex:
>>>y=2+5j
>>>y
(2+5j)
>>>type(y)
<type ‘complex’>
>>>y.real
2
>>>y.imag
5
14
Anurag College of Engineering
Addition:
>>>c=a+b
>>>c
7.5
>>>type(c)
<type ‘float’>
Subtraction:
>>>d=a-b
>>>d
2.5
>>>type(d)
<type ‘float’>
15
Anurag College of Engineering
Multiplication:
>>>e=a*b
>>>e
12.5
>>>type(e)
<type ‘float’>

Division:
>>>f=b/a
>>>f
0.5
>>>type(f)
<type ‘float’>
16
Anurag College of Engineering
Power:
>>>g=a**2
>>>g
25

17
Anurag College of Engineering
Strings

• A string is simply a list of characters in order.


• There are no limits to the number of characters
that can have in a string.
• A string which has zero characters is called an
empty string

18
Anurag College of Engineering
Working with Strings in Python
Create string:
>>> s=“Hello World!”
>>>type(s)
<type ‘str’>

String concatenation:
>>> s=“Hello World!”
>>>type(s)
<type ‘str’>
>>>t= “ This is a sample program.”
>>>type(t)
<type ‘str’>
>>>r= s+t
>>>r
Hello World! This is a sample program. 19
Anurag College of Engineering
Get Length of String:
>>> s=“Hello World!”
>>>len (s)
12

Convert string to Integer:


>>>x=“100”
>>>type(s)
<type ‘str’>
>>>y=int (x)
>>>y
100
20
Anurag College of Engineering
Print string:
s=“Hello World!”
>>>print s
Hello world!

Formatting output:
>>>print “The string (%s) has %d characters” % (s, len(s))
The string (Hello World!) has 12 characters

Anurag College of Engineering 21


Convert to upper/lower case:
Upper case:
s=“Hello World!”
>>>s. upper()
‘HELLO WORLD!’
Lower case:
s=“Hello World!”
>>>s. lower()
‘hello world!’

22
Anurag College of Engineering
Strip:
Strip returns a copy of the string with the leading and
trailing characters removed.
s=“Hello World!”
>>>s.strip (“!”)
‘Hello World’

Accessing sub-strings:
s=“Hello World!”
>>>s[0]
‘H’
>>>s[6:]
‘World!’
>>>s[6: -1]
‘World’
23
Anurag College of Engineering
Lists

• List is a compound data type used to group


together other values.
• List items need not all have the same type.
• A list contains items separated by commas and
enclosed within square brackets.

24
Anurag College of Engineering
Working with Lists in Python
>>>fruits=[‘apple’ , ‘orange’ , ‘banana’ , ‘mango’]
>>>type(fruits)
<type ‘list’>
>>>len (fruits)
4

>>>fruits[1]
‘orange’
>>>fruits[1:3]
[‘orange’ , ‘banana’]
>>>fruits[1:]
[‘orange’ , ‘banana’ , ‘mango’]
25
Anurag College of Engineering
Appending an item to a list:
>>>fruits . append (‘pear’)
>>>fruits
[‘apple’ , ‘orange’ , ‘banana’ , ‘mango’ , ‘pear’]
Removing an item from a list:
>>>fruits . remove (‘mango’)
>>>fruits
[‘apple’ , ‘orange’ , ‘banana’ , ‘pear’]
Inserting an item to a list:
>>>fruits . insert (1,‘mango’)
>>>fruits
[‘apple’ , ‘mango’ , ‘orange’ , ‘banana’ , ‘pear’]
26
Anurag College of Engineering
Combining lists:
>>>fruits=[‘apple’ , ‘mango’ , ‘orange’ , ‘banana’ , ‘pear’]
>>>fruits
‘apple’ , ‘mango’ , ‘orange’ , ‘banana’ , ‘pear’
>>>vegetables=[‘potato’ , ‘carrot’ , ‘onion’ , ‘beans’ ,
‘radish’]
>>>vegetables
‘potato’ , ‘carrot’ , ‘onion’ , ‘beans’ , ‘radish’
>>>eatables=fruits+vegetables
>>>eatables
[‘apple’ , ‘mango’ , ‘orange’ , ‘banana’ , ‘pear’ ,
‘potato’ , ‘carrot’ , ‘onion’ , ‘beans’ , ‘radish’]
27
Anurag College of Engineering
Lists can be nested:
>>>fruits=[‘apple’ , ‘mango’ , ‘orange’ , ‘banana’ , ‘pear’]
>>>fruits
‘apple’ , ‘mango’ , ‘orange’ , ‘banana’ , ‘pear’
>>>vegetables=[‘potato’ , ‘carrot’ , ‘onion’ , ‘beans’ ,
‘radish’]
>>>vegetables
‘potato’ , ‘carrot’ , ‘onion’ , ‘beans’ , ‘radish’
>>>nested=[fruits,vegetables]
>>>nested
[[‘apple’ , ‘mango’ , ‘orange’ , ‘banana’ , ‘pear’ ],
[‘potato’ , ‘carrot’ , ‘onion’ , ‘beans’ , ‘radish’]]
28
Anurag College of Engineering
Tuples

• A tuple is a sequence data type that is similar to


the list.
• A tuple consists of a number of values separated
by commas and enclosed within parentheses.
• The elements of tuples cannot be changed, so
tuples can be thought of as read-only lists.

29
Anurag College of Engineering
Working with Tuples in Python
>>>fruits=[“apple” , “mango” , “banana” , “pineapple”]
>>>fruits
(‘apple’ , ‘mango’ , ‘banana’ , ‘pineapple’)
>>>type(fruits)
<type ‘tuple’>

Get length of tuple:


>>>len (fruits)
4

30
Anurag College of Engineering
Get an element from a tuple:
>>>fruits=[“apple” , “mango” , “banana” , “pineapple”]
>>>fruits[0]
‘apple’
>>>fruits[:2]
[‘apple’ , ‘mango’]

31
Anurag College of Engineering
Combining tuples:
>>>fruits =[“apple” , “mango” , “banana” , “pineapple”]
>>>fruits
(‘apple’ , ‘mango’ , ‘banana’ , ‘pineapple’)
>>>vegetables=[“potato’”, “carrot”, “onion’”, “radish”]
>>>vegetables
(‘potato’ , ‘carrot’ , ‘onion’ , ‘radish’)
>>>eatables=fruits+vegetables
>>>eatables
(‘apple’ , ‘mango’ , ‘banana’ , ‘pineapple’ ,
‘potato’ , ‘carrot’ , ‘onion’ , ‘radish’)
32
Anurag College of Engineering
Dictionaries

• Dictionary is a mapping data type or a kind of


hash table that maps keys to values.
• Keys in a dictionary can be of any data type,.
• Numbers and strings are commonly used for
keys.
• Values in a dictionary can be any data type or
object.

33
Anurag College of Engineering
Working with Dictionaries in Python
>>>student={‘name’: ‘Mary’ , ‘id’ : ‘8776’, ‘major’: ‘cs’}
>>>student
{‘major’: ‘cs’ , ‘name’: ‘Mary’ , ‘id’ : ‘8776’ }
>>>type(student)
<type ‘dict’>

Get length of a dictionary:


>>>student={‘name’: ‘Mary’ , ‘id’ : ‘8776’, ‘major’: ‘cs’}
>>>len (student)
3
34
Anurag College of Engineering
Get the value of a key in dictionary:
>>>student={‘name’: ‘Mary’ , ‘id’ : ‘8776’, ‘major’: ‘cs’}
>>>student[‘name’]
‘Mary’
Get all items in a dictionary:
>>>student . items{}
[{‘major’ , ‘cs’}, {‘name’ , ‘Mary’}, {‘id’ , ‘8776’}]
Get all keys in a dictionary:
>>>student . Keys{}
[ ‘major’ , ‘name’ , ‘id’]
Get all values in a dictionary:
[ ‘cs’ , ‘Mary’ , ‘8776’]
>>>student
{‘major’: ‘cs’ , ‘name’: ‘Mary’ , ‘id’ : ‘8776’ }
35
Anurag College of Engineering
Check if dictionary has a key:
>>>student={‘name’: ‘Mary’ , ‘id’ : ‘8776’, ‘major’: ‘cs’}
>>>student.has_key{‘name’}
True
>>>student.has_key{‘grade’}
False

Anurag College of Engineering 36


Type Conversions
Convert to string:
>>>a=10000
>>>str(a)
‘10000’
Convert to int:
>>>b=“2013”
>>>int(b)
2013
Convert to float:
>>>b=“2013”
>>>float(b)
2013.0
37
Anurag College of Engineering
Convert to long:
>>>b=“2013”
>>>long(b)
2013L
Convert to list:
>>>s=“aeiou”
>>>list(s)
[‘a’ , ‘e’ , ‘i’ , ‘o’ , ‘u’]
Convert to set:
>>>x=[‘mango’ , ‘apple’ , ‘banana’ , ‘mango’ , ‘banana’]
>>>set{x}
Set{[‘mango’ , ‘apple’ , ‘banana’]}
38
Anurag College of Engineering
Control Flow

Control flow statements in Python:


• if
• for
• while
• range
• break/continue
• pass

Anurag College of Engineering 39


if statement
>>>a = 25**5
>>>if a>10000:
print “More”
else:
print “Less”

More

40
Anurag College of Engineering
if statement
>>>a = 25**5
>>>if a>10000:
if a<1000000:
print “Between 10k and 100k”
else:
print “More than 100k”
elif a==10000:
print “Equal to 10k”
else:
print “Less than 10k”

More than 100k 41


Anurag College of Engineering
for statement
• The for statement in Python iterates over items of any
sequence (list, string, etc.) in the order in which they
appear in the sequence.

Looping over characters in a string:


helloString = “Hello World”
for c in helloString:
print c

42
Anurag College of Engineering
Looping over items in a list:
fruits=[‘apple’ , ‘orange’ , ‘banana’ , ‘mango’]
i=0
for item in fruits:
print “Fruit-%d: %s” % {i, item}
i=i+1
Looping over keys in a dictionary:
student= ‘name’: ‘Mary’ , ‘id’ : ‘8776’, ‘major’: ‘cs’
for key in student:
print “%s: %s % (key, student[key])

43
Anurag College of Engineering
while statement
• The while statement in Python executes the statements
within the while loop as long as the while condition is
true.

Print even numbers upto 100:


>>> i = 0
>>> while i<100:
if i%2 == 0:
print i
i = i+1
44
Anurag College of Engineering
range statement
• The range statement in Python generates a list of numbers
in arithmetic progression.

Generate a list of numbers from 0-9:


>>>range {10}
[0, 1, 2, 3, 4, 5, 6, 7 , 8, 9]

Generate a list of numbers from 10-100 with increments


of 10:
>>>range(10,110,10)
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
45
Anurag College of Engineering
break/continue statement
• The break statement breaks out of the for/while loop
whereas the continue statement continues with the next
iteration.
Break statement:
>>>y=1
>>>for x in range(4,256,4) :
y=y*x
if y > 512:
break
print y

4
32
384
46
Anurag College of Engineering
break/continue statement
Continue statement:
>>>fruits=[‘apple’ , ‘orange’ , ‘banana’ , ‘mango’]
>>>for item in fruits:
if item == “banana”:
continue
else:
print item
apple
orange
mango
47
Anurag College of Engineering
pass statement
• The pass statement in Python is a null operation.
• The pass statement is used when a statement is required
syntactically but do not want any command or code to
execute.
>>>fruits=[‘apple’ , ‘orange’ , ‘banana’ , ‘mango’]
>>>for item in fruits:
if item == “banana”:
pass
else:
print item
apple
orange
48
Anurag College of Engineering
Functions
• A function is a block of code that takes information in (in
the form of parameters), does some computation and
returns a new piece of information based on parameter
information.
• A function in Python is a block of code that begins with the
keyword def followed by the function name and
parentheses.
• The function parameters are enclosed within the
parenthesis.
• The code block within a function begins after a colon that
comes after the parenthesis enclosing the parameters.
• The first statement of the function body can optionally be a
documentation string or docstring.
49
Anurag College of Engineering
Example- Function that computes the average grade
given a dictionary containing student records:
Students = { ‘1’ : {‘name’ : ‘Bob’ , ‘grade’ : 2.5},
‘2’ : {‘name’ : ‘Mary’ , ‘grade’ : 3.5},
‘3’ : {‘name’ : ‘David’ , ‘grade’ : 4.2},
‘4’ : {‘name’ : ‘John’ , ‘grade’ : 4.1},
‘5’ : {‘name’ : ‘Alex’ , ‘grade’ : 3.8}}
def averageGrade(students) :
“ This function computes the average grade”
sum ~ 0.0
for key in students:
sum = sum + students[key] [‘grade’]
average = sum/len(students)
return average
avg ~ averageGrade(students)
Print “The average grade is: %0.2f” % (avg) 50
Anurag College of Engineering
• Functions can have default values of the parameters.
• If a function with default values is called with fewer parameters
or without any parameter, the default values of the parameters are
used.
Example- Function with default arguments
>>>def displayFruits{fruits=[‘apple’ , ‘orange’]}:
print “There are %d fruits in the list” % {len{fruits}}
for item in fruits:
print item
Using default arguments
>>>displayFruits{}
apple
orange
>>>fruits=[‘banana’ , ‘pear’ , ‘mango’]
>>>displayFruits{fruits}
banana
pear
mango
51
Anurag College of Engineering
• All parameters in the Python functions are passed by
reference.
• If a parameter is changed within a function the change also reflected back
in the calling function.
Example- Passing by reference
>>> displayFruits{fruits}:
print “There are %d fruits in the list” % {len{fruits}}
for item in fruits:
print item
print “ Adding one more fruit”
fruits.append{‘mango’}

>>> fruits = [‘banana’ , ‘pear’ , ‘apple’]


>>>displayFruits{fruits}
There are 3 fruits in the list
banana
pear
apple
Adding one more fruit
>>> print “There are %d fruits in the list” % {len{fruits}} 52
Anurag College of Engineering
There are 4 fruits in the list
• Functions can also be called using keyword arguments that
identify the arguments by the parameter name when the
function is called.
• Python functions can have variable length arguments.
• These variable length arguments are passed as a tuple to the
function with an argument prefixed with asterik (*)
Modules
• Python allows organizing of the program code into different
modules which improves the code readability and management.
• A module is a Python file that defines some functionality in the
form of functions or classes.
• Modules can be imported using the import keyword.
• Modules to be imported must be present in the search path.
• The import keyword followed by the module name imports all
the functions in the module.
• To use only a specific function it is recommended to import
only that function using the keyword from.
• Python comes with a number of standard modules such as
system related modules(sys), OS related module(os),
mathematical modules(math, fractions, etc.), internet related
modules (email, json, etc).

55
Anurag College of Engineering
Example- Importing the student that contains two
functions and using it
def averageGrade(students) :
sum = 0.0
for key in students:
sum = sum + students[key] [‘grade’]
average = sum/len(students)
return average
def printRecords(students):
print “There are %d students” %(len(students))
i=1
for key in students:
print “Student-%d: “ % (i)
print “Name: “ + students[key][‘name’]
print “Grade: “ + str{students[key][‘grade’]}
56
Anurag College of Engineering
Example- Using student module

57
Anurag College of Engineering
Example- Importing a specific function from a
module

58
Anurag College of Engineering
Example- Listing all names defined in a
module

59
Anurag College of Engineering
Packages

• Python package is hierarchical file structure that


contains of modules and sub packages.
• Packages allow better organization of modules
related to a single application environment.

60
Anurag College of Engineering
skimage package listing:

61
Anurag College of Engineering
• Fig. shows the listing of the skimage package that
provides image processing algorithms.
• The package is organized into a root directory (skimage)
with sub-directories (color, draw, etc) which are sub-
packages within the skimage package.
• Each directory contains a special file named _init_.py
which tells Python to treat directories as packages.
• This file can either be an empty file or contain some
initialization code for the package.

62
Anurag College of Engineering
File Handling
• Python allows reading and writing to files using the file
object.
• The open(filename, mode) function is used to get a file
object.
• The mode can be read (r), write (w), append (a), read and
write (r+ or w+), read-binary (rb), write-binary (wb), etc.

63
Anurag College of Engineering
Reading an entire file:
Fig. shows reading an entire file with read function.
After the file contents have been read the close
function is called which closes the file object.

64
Anurag College of Engineering
Reading line by line from a file using the readline
function:

65
Anurag College of Engineering
Reading lines in a loop using the readlines
function:

66
Anurag College of Engineering
Reading a certain number of bytes from a file
using the read(size) function:

67
Anurag College of Engineering
Getting the current position of read using the
tell function:

68
Anurag College of Engineering
Seeking to a certain position using seek function :

69
Anurag College of Engineering
Writing a file using the write function :

70
Anurag College of Engineering
Date/Time Operations

• Python provides several functions for date and


time access and conversions.
• The datetime module allows manipulating date
and time in several ways.

71
Anurag College of Engineering
Example-Manipulating with date:

72
Anurag College of Engineering
Example-Manipulating with time:

73
Anurag College of Engineering
Classes
• Python is an Object-Oriented Programming
(OOP) language.
• Python provides all the standard features of
Object-Oriented Programming such as classes,
class variables, class methods, inheritance,
function loading and operator overloading.

74
Anurag College of Engineering
Class:
A class is simply a representation of a type of object and
user-defined prototype for an object that is composed of
three things: a name, attributes and operations/ methods.
Instance/Object:
Object is an instance of the data structure defined by a
class.
Inheritance:
Inheritance is the process of forming a new class from an
existing class or base class.
Function overloading:
Function overloading is a form of polymorphism that
allows a function to have different meanings, depending
on its context.
75
Anurag College of Engineering
Operator overloading:
Operator overloading is a form of polymorphism that
allows assignment of more than one function to a
particular operator.
Function overriding :
Function overriding allows a child class to provide a
specific implementation of a function that is already
provided by the base class. Child class implementation of
the overridden function has the same name, parameters
and return type as the function in the base class.

76
Anurag College of Engineering
Python Packages for IoT

• JavaScript Object Notation (JSON)


• Extensible Markup Language (XML)
• HTTPLib (Hypertext Transfer Protocol Lib)
• URLLib (Uniform Resource Locator Lib)
• SMTPLib (Simple Mail Transfer Protocol Lib)

77
Anurag College of Engineering
JavaScript Object Notation (JSON)

• JavaScript Object Notation (JSON) is an easy to read and


write data-interchange format.
• JSON is used as an alternative to XML and is easy for
machines to parse and generate.
• It is built on two structures- a collection of name-value
pairs(e.g. A Python dictionary) and ordered lists of
values (e.g. A Python list).
• JSON format is often used for serializing and
transmitting structured data over a network connection
(e.g. transmitting data between a server and web
application).

78
Anurag College of Engineering
Extensible Markup Language (XML)

• XML (Extensible Markup Language) is a data format for


structured document interchange.

79
Anurag College of Engineering
HTTPLib and URLLib

• HTTPLib2 and URLLib2 are Python libraries used in


network/internet programming.
• HTTPLib2 is an HTTP client library and URLLib2 is a
library for fetching URLs

80
Anurag College of Engineering
SMTPLib
• Simple Mail Transfer Protocol (SMTP) is a protocol
which handles sending email and routing e-mail between
mail servers.
• The Python smtplib module provides an SMTP client
session object that can be used to send email.

81
Anurag College of Engineering
Introduction to Raspberry Pi

• Raspberry Pi is a low-cost mini computer with the size


of a credit card.
• Raspberry Pi runs various flavors on Linux and can
perform almost all tasks that a normal desktop computer
can do.
• Raspberry Pi also allows interfacing sensors and
actuators through the general purpose I/O pins.
• Since Raspberry Pi runs Linux operating system , it
supports Python.

82
Anurag College of Engineering
Raspberry Pi Board:

83
Anurag College of Engineering
Raspberry Pi board with various
components/peripherals labeled:

84
Anurag College of Engineering
Raspberry Pi board with various
components/peripherals labeled:

85
Anurag College of Engineering
About the Raspberry Pi Board
Processor and RAM:
• Raspberry Pi is based on an ARM processor.
• The Raspberry Pi (Model B, Revision 2) comes with
700MHz Low Power ARM11 76JZ-F processor and 512
MB SDRAM.

USB Ports:
• Raspberry Pi comes with two USB 2.0 ports.
• The USB ports on Raspberry Pi can provide a current
upto 100mA.
• For connecting devices that draw current more than
100mA, an external USB powered hub is required.
86
Anurag College of Engineering
About the Raspberry Pi Board
Ethernet Ports:
• Raspberry Pi comes with standard RJ45 Ethernet port.
• An Ethernet cable or a USB Wi-Fi adapter can be
connected to provide Internet connectivity.

HDMI Output:
• High-Definition Multimedia Interface (HDMI) port on
Raspberry Pi provides both video and audio output.
• Raspberry Pi can connected to a monitor using HDMI
cable.
• For monitors having a DVI (Digital Visual Interface) port
but no HDMI port, we can use HDMI to DVI
adapter/cable.
87
Anurag College of Engineering
About the Raspberry Pi Board
Composite Video Output:
• Raspberry Pi comes with a composite video output with
an RCA (Radio Corporation of America) jack that
supports both PAL (Phase Alternating Line ) and NTSC
(National Television Standards Committee) video output.
• The RCA jack can be used to connect old television that
have an RCA input only.
Audio Output:
• Raspberry Pi has a 3.5mm audio output jack.
• This audio jack is used for providing audio output to old
televisions along with the RCA jack for video.
• The audio quality from this jack is inferior to the HDMI
output.
88
Anurag College of Engineering
About the Raspberry Pi Board
GPIO Pins:

• Raspberry Pi comes with a number of general purpose


input/output (GPIO) pins.
• There are four types of pins on Raspberry Pi
1. True GPIO pins
2. I2C (Inter-Integrated Circuit) interface pins
3. SPI (Serial Peripheral Interface) interface pins
4. Serial Transmit and Receive pins.

89
Anurag College of Engineering
Raspberry Pi GPIO Header Pins

90
Anurag College of Engineering
About the Raspberry Pi Board
Display Serial Interface (DSI):
• The DSI interface can be used to connect an LCD panel to
Raspberry Pi.
Camera Serial Interface (CSI):
• The CSI interface can be used to connect a camera module to
Raspberry Pi.
Power Input:
• Raspberry Pi has a micro-USB connector for power input.
SD card Slot:
• Raspberry Pi does not have a built in operating system and
storage. We can plug in an SD card loaded with a Linux
image to the SD card slot. An 8GB SD card is required for
setting up New Out-of-the-Box Software (NOOBS). 91
Anurag College of Engineering
About the Raspberry Pi Board
Status LEDs:
• Raspberry Pi has five status LEDs.
• Table below shows the Raspberry Pi status LEDs and
their functions.

92
Anurag College of Engineering
Anurag College of Engineering 93
Anurag College of Engineering 94

You might also like