0% found this document useful (0 votes)
197 views

IoT Lab Rtu

The document provides details about experiments to be conducted on a Raspberry Pi. It includes a list of Linux commands and Python programs to try on the Raspberry Pi, including reading input, printing output, and performing arithmetic operations. It also describes connecting sensors, cameras, and other hardware to the Raspberry Pi and controlling devices through Python programs and cron jobs. Guidelines for lab conduct are also provided.

Uploaded by

fecifa3051
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
197 views

IoT Lab Rtu

The document provides details about experiments to be conducted on a Raspberry Pi. It includes a list of Linux commands and Python programs to try on the Raspberry Pi, including reading input, printing output, and performing arithmetic operations. It also describes connecting sensors, cameras, and other hardware to the Raspberry Pi and controlling devices through Python programs and cron jobs. Guidelines for lab conduct are also provided.

Uploaded by

fecifa3051
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

Detailed Syllabus

Start Raspberry Pi and try various Linix commands in command terminal window: ls, cd, touch, mv,
1 rm, man, mkdir, rmdir, tar, gzip, cat, more, less, ps, sudo, cron, chown, chgrp, ping etc.

Run some python programs on Pi like:


a) Read your name and print Hello message with name
2 b) Read two numbers and print their sum, difference, product and division.
c) Word and character count of a given string.
d) Area of a given shape (rectangle, triangle and circle) reading shape and appropriate values from
standard input.
Run some python programs on Pi like:
a) Print a name 'n' times, where name and n are read from standard input, using for and while loops.
3 b) Handle Divided by Zero Exception.
c) Print current time for 10 times with an interval of 10 seconds.
d) Read a file line by line and print the word count of each line.
a) Light an LED through Python program
4 b) Get input from two switches and switch on corresponding LEDs
c) Flash an LED at a given on time and off time cycle, where the two times are taken from a file.
a) Flash an LED based on cron output (acts as an alarm)
5 b) Switch on a relay at a given time using cron, where the relay's contact terminals are connected to a
load.
c) Get the status of a bulb at a remote place (on the LAN) through web.
The student should have hands on experience in using various sensors like temperature, humidity,
smoke, light, etc. and should be able to use control web camera, network, and relays connected to the
Pi.

Page | 1
LIST OF EXPERIMENTS

Exp.No Name of Experiment Page No.


Study Various Linux Commands in command terminal window.
1 9
Study and Install Python in Eclipse and WAP for data
2 15
types in python.
3 Study and WAP for Arithmetic operation in python. 25

4 Study and WAP for looping statement in python. 30

5 Study and Install IDE of Arduino and different types of Arduino 37


6 Write program using Arduino IDE for Blink LED 42
7 Write Program for RGB LED using Arduino. 45
Study the Temperature sensor and Write Program foe monitor
8 48
temperature using Arduino.
9 Study and Implement RFID, NFC using Arduino. 53
10 Study and Implement MQTT Protocol using Arduino. 57
11 Study and Configure Raspberry Pi. 60
12 WAP for LED blink using Raspberry Pi. 63
13 Study and Implement Zigbee Protocol using Raspberry Pi. 67
WAP for interfacing various sensors and camera module with using
14 70
Raspberry Pi.

Page | 2
DO’S AND DONT’S
DO’s
1. Please switch off the Mobile/Cell phone before entering Lab.
2. Enter the Lab with complete source code and data.
3. Check whether all peripheral are available at your desktop before proceeding
For program.
4. Intimate the lab In-charge whenever you are incompatible in using the system or in
Case software get corrupted/ infected by virus.
5. Arrange all the peripheral and seats before leaving the lab.
6. Properly shutdown the system before leaving lab.
7. Keep the bag outside in the racks.
8. Enter the lab on time and leave at proper time.
9. Maintain the decorum of the lab.
10. Utilize lab hours in the corresponding experiment.
11. Get your CD/Pen drive checked by lab In charge before using it in the lab.

DONT’S
1. No one is allowed to bring storage devices like Pan Drive /Floppy etc. in the lab.
2. Don’t mishandle the system.
3. Don’t leave the system on standing for long
4. Don’t bring any external material in the lab.
5. Don’t make noise in the lab.
6. Don’t bring the mobile in the lab. If extremely necessary then keep ringers off.
7. Don’t enter in the lab without permission of lab In-charge.
8. Don’t litter in the lab.
9. Don’t delete or make any modification in system files.Don’t carry any lab equipment’s outside the lab.

Page | 3
INSTRUCTIONS TO THE STUDENTS

General Instructions
 Maintain separate observation copy for each laboratory.
 Observations or readings should be taken only in the observation copy.
 Get the readings counter signed by the faculty after the completion of the experiment.
 Maintain Index column in the observation copy and get the signature of the faculty before leaving the
lab.

Before entering in the Lab


 All the students are supposed to prepare the theory regarding the next program.
 Students are supposed to bring the practical file and the lab copy.
 Previous programs should be written in the practical file.
 Algorithm of the current program should be written in the lab copy.
 Any student not following these instructions will be denied entry in the lab.

While working in the Lab


 Adhere to experimental schedule as instructed by the lab in charge.
 Get the previously executed program signed by the instructor.
 Get the output of the current program checked by the instructor in the lab copy.
 Each student should work on his/her assigned computer at each turn of the lab.
 Take responsibility of valuable accessories.
 Concentrate on the assigned practical and do not play games.
 If anyone caught red handed carrying any equipment of the lab, then he will have to face serious
consequences.

Before Leaving the Lab


 The equipment’s/components should be returned back to the lab assistant in good condition after the
completion of the experiment.
 The students should get the signature from the faculty in the observation copy.
 They should also check whether their file is checked and counter signed in the index.

Page | 4
Department Of Computer Science & Engineering

List of Program Educational Objectives (PEO)

Graduate students will have thorough knowledge in science and engineering disciplines

PEO-1 and have broad-based education in areas of computer science, including theoretical
foundations, algorithms data structures and hardware.

Graduates will have solid foundation in engineering field required to solve computing

PEO-2 problems using various programming languages and software’s/tools, and students can
solve problems through logical and analytical thinking.

Graduates will be trained with good engineering breadth so as to comprehend, analyze,


PEO-3
design, and create novel products and solutions for the real life problem.

To develop the professional and ethical attitude, effective communication skills,

PEO-4 teamwork skills, multidisciplinary approach, and an ability to relate engineering issues to
broader social context.

Graduates will be provided with an academic environment to peruse excellence in

PEO-5 leadership, teamwork and lifelong learning needed for successful professional career
through independent self-studies, projects, thesis and through internships etc.

Page | 5
List of Program Outcomes
Engineering Knowledge: Apply knowledge of mathematics and science, with
PO-1 fundamentals of Engineering to be able to solve complex engineering problems
related.

Problem Analysis: Identify, Formulate, review research literature and analyze


complex engineering problems and reaching substantiated conclusions using first
PO-2 principles of mathematics, natural sciences and engineering sciences.

Design/Development of solutions: Design solutions for complex engineering


problems and design system components or processes that meet the specified needs
PO-3 with appropriate consideration for the public health and safety and the cultural
societal and environmental considerations.

Conduct Investigations of Complex problems: Use research–based knowledge


and research methods including design of experiments, analysis and interpretation
PO-4
of data, and synthesis of the information to provide valid conclusions.

Modern Tool Usage: Create, Select and apply appropriate techniques, resources
and modern engineering and IT tools including prediction and modeling to
PO-5 complex engineering activities with an understanding of the limitations.

The Engineer and Society: Apply Reasoning informed by the contextual


PO-6 knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.

Environment and Sustainability: Understand the impact of the professional


PO-7 engineering solutions in societal and environmental contexts and demonstrate the
knowledge of, and need for sustainable development.

Ethics: Apply Ethical Principles and commit to professional ethics and


PO-8
responsibilities and norms of the engineering practice.

Individual and Team Work: Function effectively as an individual and as a


PO-9
member or leader in diverse teams and in multidisciplinary Settings.

Page | 6
Communication: Communicate effectively on complex engineering activities with
the engineering community and with society at large such as able to comprehend
PO-10 and with write effective reports and design documentation, make effective
presentations and give and receive clear instructions.

Project Management and Finance: Demonstrate knowledge and understanding of


the engineering management principles and apply these to one’s own work, as a
PO-11
member and leader in a team, to manage projects and in multi-disciplinary
environments.

Life-Long Learning: Recognize the need for and have the preparation and ability
PO-12 to engage in independent and life-long learning the broadest context of
technological change.

List of Program Specific Outcomes (PSO)


Knowledge Enhancement in Computing: The ability to interpret the foundation
and strategy of hardware and software of computer systems. Graduates can solve
PSO-1 the problems in the areas related to algorithms, multimedia, data analytics, cloud
computing, human computer interface, robotics, artificial intelligence and
networking for efficient design of computer systems.

Software Design and Development: The ability to understand the software


development lifecycle and methodologies of software systems. Graduate will learn
PSO-2
competent skills and knowledge of software design process. Graduate will be
acquaintance to practical proficiency with a broad area of programming concepts.

Page | 7
Course Outcomes:
After completion of this course students will able to:
CO -1: Explain the concept and Application of Internet of Things
CO -2: Illustrate key technologies, protocols and standards in Internet of Things.
CO -3: Analyze trade-offs in interconnected wireless embedded device networks
CO -4: Application of IOT in automation of Commercial and Real-World examples
CO -5: Design a simple IOT system comprising sensors, edge devices and wireless network connections involving
prototyping, programming and data analysis.

Course Outcomes to Program Outcomes Mapping:

Program Outcomes PSO’s


Course
Outcomes PO- PO PO PO- PO PO- PO- PO PO- PO PO PO
PSO- PSO-
1 -2 -3 4 -5 6 7 -8 9 -10 -11 - 1 2
12

CO-1 2 3 2 - - - - - - - - 3 3 1
2 2 2 - - - - - 2 2 2 3 1
CO-2
CO-3 3 2 - - - - - - - - 2 1 1
2 3 2 - - - - - - - - 3 1 1
CO-4
2 1 - - - - - - - - - - 3 1
CO-5

Note: Correlation levels 1, 2 or 3 as defined below:


1: Slight (Low) 2: Moderate (Medium) 3: Substantial (High)

Page | 8
EXPERIMENT NO. 1
Aim: Study Various Linux Commands in command terminal window.
Objectives: Student should get the knowledge of Linux commands.
Outcomes: Student will be aware of Linux commands. Linux commands
Here are some fundamental and common Linux commands with example usage:
File system
ls
The ls command lists the content of the current directory (or one that is specified). It can be used with the -
l flag to display additional information (permissions, owner, group, size, date and timestamp of last edit)
about each file and directory in a list format. The -a flag allows you to view files beginning with. (i.e.
defiles).
cd
Using cd changes the current directory to the one specified. You can use relative (i.e. cd directory) or
absolute (i.e. cd /home/pi/directory) paths.
pwd
The pwd command displays the name of the present working directory: on a Raspberry Pi, entering pwd will
output something like /home/pi.
mkdir
You can use mkdir to create a new directory, e.g. mkdirnewDir would create the directory newDir in the
present working directory.
rmdir
To remove empty directories, use rmdir. So, for example, rmdiroldDir will remove the directory oldDir only
if it is empty.
rm
The command rmremoves the specified file (or recursively from a directory when used with -r). Be careful
with this command: files deleted in this way are mostly gone for good!
cp
Using cp makes a copy of a file and places it at the specified location (this is similar to copying and pasting).
For example, cp ~/fileA /home/otherUser/ would copy the file fileA from your home directory to that of the
user otherUser (assuming you have permission to copy it there). This command can either take FILE

Page | 9
FILE (cpfileAfileB), FILE DIR (cpfileA /directoryB/) or -r DIR DIR (which recursively copies the contents
of directories) as arguments.
mv
The mv command moves a file and places it at the specified location (so where cp performs a 'copy-
paste', mv performs a 'cut-paste'). The usage is similar to cp. So mv ~/fileA /home/otherUser/ would move
the file fileA from your home directory to that of the user otherUser. This command can either take FILE
FILE (mv fileAfileB), FILE DIR (mv fileA /directoryB/) or DIR DIR (mv /directoryB /directoryC) as
arguments. This command is also useful as a method to rename files and directories after they've been
created.
touch
The command touch sets the last modified time-stamp of the specified file(s) or creates it if it does not
already exist.
Cat
You can use cat to list the contents of file(s), e.g. cat thisFile will display the contents of thisFile. Can be used
to list the contents of multiple files, i.e. cat *.txt will list the contents of all .txt files in the current directory.
head
The head command displays the beginning of a file. Can be used with -n to specify the number of lines to
show (by default ten), or with -c to specify the number of bytes.
tail
The opposite of head, tail displays the end of a file. The starting point in the file can be specified either
through -b for 512 byte blocks, -c for bytes, or -n for number of lines.
chmod
You would normally use chmod to change the permissions for a file. The chmod command can use
symbols u (user that owns the file), g (the files group), and o (other users) and the
permissions r (read), w (write), and x (execute). Using chmodu+x *filename* will add execute permission for
the owner of the file.
chown
The chown command changes the user and/or group that owns a file. It normally needs to be run as root using
sudo e.g. sudochownpi:root *filename* will change the owner to pi and the group to root.
ssh

Page | 10
ssh denotes the secure shell. Connect to another computer using an encrypted network connection. For more
details see SSH (secure shell)
scp
The scp command copies a file from one computer to another using ssh. For more details see SCP (secure
copy)
sudo
The sudo command enables you to run a command as a superuser, or another user. Use sudo -s for a
superuser shell. For more details see Root user / sudo
dd
The dd command copies a file converting the file as specified. It is often used to copy an entire disk to a
single file or back again. So, for example, dd if=/dev/sdd of=backup.img will create a backup image from an
SD card or USB disk drive at /dev/sdd. Make sure to use the correct drive when copying an image to the SD
card as it can overwrite the entire disk.
df
Use df to display the disk space available and used on the mounted filesystems. Use df -h to see the output in
a human-readable format using M for MBs rather than showing number of bytes.
unzip
The unzip command extracts the files from a compressed zip file.
tar
Use tar to store or extract files from a tape archive file. It can also reduce the space required by compressing
the file similar to a zip file.
To create a compressed file, use tar -cvzf *filename.tar.gz* *directory/* To extract the contents of a file,
use tar -xvzf *filename.tar.gz*
pipes
A pipe allows the output from one command to be used as the input for another command. The pipe symbol
is a vertical line |. For example, to only show the first ten entries of the ls command it can be piped through
the head command ls | head
tree
Use the tree command to show a directory and all subdirectories and files indented as a tree structure.
&

Page | 11
Run a command in the background with &, freeing up the shell for future commands.
wget
Download a file from the web directly to the computer with wget. So wget
https://www.raspberrypi.org/documentation/linux/usage/commands.md will download this file to your
computer as commands.md
curl
Use curl to download or upload a file to/from a server. By default, it will output the file contents of the file to
the screen.
man
Show the manual page for a file with man. To find out more, run man man to view the manual page of the
man command.
Search
grep
Use grep to search inside files for certain search patterns. For example, grep "search" *.txt will look in all the
files in the current directory ending with .txt for the string search.
The grep command supports regular expressions which allows special letter combinations to be included in
the search.
awk
awk is a programming language useful for searching and manipulating text files.
find
The find command searches a directory and subdirectories for files matching certain patterns.
whereis
Use whereis to find the location of a command. It looks through standard program locations until it finds the
requested command.
Networking
ping
The ping utility is usually used to check if communication can be made with another host. It can be used with
default settings by just specifying a hostname (e.g. ping raspberrypi.org) or an IP address (e.g. ping 8.8.8.8).
It can specify the number of packets to send with the -c flag.

Page | 12
nmap
nmap is a network exploration and scanning tool. It can return port and OS information about a host or a
range of hosts. Running just nmap will display the options available as well as example usage.
hostname
The hostname command displays the current hostname of the system. A privileged (super) user can set the
hostname to a new one by supplying it as an argument (e.g. hostname new-host).
ifconfig
Use ifconfig to display the network configuration details for the interfaces on the current system when run
without any arguments (i.e. ifconfig). By supplying the command with the name of an interface
(e.g. eth0 or lo) you can then alter the configuration: check the manual page for more details.

Page | 13
Sr. no VIVA QUESTIONS

1. What is the Internet of Things (IoT)?

2. List layers of IoT protocol stack

3. List mostly used sensors types in IoT

4. What are the most common IoT applications?

5. Define GPIO.

6. What is the importance of the network in IoT?

Page | 14
EXPERIMENT NO. 2

Aim: Study and Install Python in Eclipse and WAP for data types in python.

Objectives: Student should get the knowledge of Python and Eclipse background.
Outcomes: Student will be aware of Python and Eclipse background.
What is Python:
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming
language. It was created by Guido van Rossum during 1985- 1990. Like
Perl,PythonsourcecodeisalsoavailableundertheGNUGeneralPublicLicense(GPL). This Experiment gives
enough understanding on Python programminglanguage.

Python is a high-level, interpreted, interactive and object-oriented scripting language.


Pythonisdesignedtobehighlyreadable.ItusesEnglishkeywordsfrequentlywhereas
otherlanguagesusepunctuation,andithasfewersyntacticalconstructionsthanother languages.

 PythonisInterpreted−Pythonisprocessedatruntimebytheinterpreter.Youdo
notneedtocompileyourprogrambeforeexecutingit.ThisissimilartoPERLand PHP.

 PythonisInteractive –YoucanactuallysitataPythonpromptandinteractwith the interpreter directly to


write yourprograms.

 Python is Object-Oriented − Python supports Object-Oriented style or technique of programming


that encapsulates code withinobjects.

 Python is a Beginner's Language − Python is a great language for the beginner- level
programmers and supports the development of a wide range of applications from simple text
processing to WWW browsers togames.

History of Python
Python was developed by Guido van Rossum in the late eighties and early nineties at the National
Research Institute for Mathematics and Computer Science in the Netherlands.

Page | 15
Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol- 68,
SmallTalk, and Unix shell and other scripting languages.

Python is copyrighted. Like Perl, Python source code is now available under the GNU General Public
License (GPL).

Python is now maintained by a core development team at the institute, although Guido van Rossum still
holds a vital role in directing its progress.

Python Features

Python's features include −

 Easy-to-learn−Pythonhasfewkeywords,simplestructure,andaclearlydefined syntax. This allows the


student to pick up the languagequickly.

 Easy-to-read − Python code is more clearly defined and visible to theeyes.


 Easy-to-maintain − Python's source code is fairlyeasy-to-maintain.
 Abroadstandardlibrary−Python'sbulkofthelibraryisveryportableandcross- platform compatible on
UNIX, Windows, andMacintosh.

 Interactive Mode − Python has support for an interactive mode which allows interactive testing
and debugging of snippets ofcode.

 Portable − Python can run on a wide variety of hardware platforms and has the same interface on
allplatforms.

 Extendable − You can add low-level modules to the Python interpreter. These modules enable
programmers to add to or customize their tools to be more efficient.

 Databases − Python provides interfaces to all major commercialdatabases.


 GUI Programming − Python supports GUI applications that can be created and ported to many
system calls, libraries and windows systems, such as Windows MFC, Macintosh, and the X
Window system ofUnix.

 Scalable − Python provides a better structure and support for large programs than shell scripting.
Page | 16
Apartfromtheabove-mentionedfeatures,Pythonhasabiglistofgoodfeatures,feware listed below−

 It supports functional and structured programming methods as well asOOP.


 Itcanbeusedasascriptinglanguageorcanbecompiledtobyte-codeforbuilding largeapplications.

 It provides very high-level dynamic data types and supports dynamic type checking.

 IT supports automatic garbagecollection.


 It can be easily integrated with C, C++, COM, ActiveX, CORBA, andJava.

Configure Python in Eclipse

Download Python from http://www.python.org. Download the version 3.3.1 or higher of Python.
If you are using Windows you can use the native installer for Python.

Eclipse Python plugin

ThefollowingassumethatyouhavealreadyEclipseinstalled.Foraninstallation description of Eclipse


please see Eclipse IDE forJava.

ForPythondevelopmentunderEclipseyoucanusethePyDevPluginwhichisan open source project.


Install PyDev via the Eclipse update manager via the following update
site:http://pydev.org/updates.

Configuration of Eclipse

YoualsohavetomaintaininEclipsethelocationofyourPythoninstallation.Open
intheWindow▸Preference▸Pydev▸InterpreterPython menu.

Press the New button and enter the path topython.exein your Python
installation directory. For Linux and Mac OS X users this is normally
/usr/bin/python.

Page | 17
Data Types in Python:

Variables are nothing but reserved memory locations to store values. This means that when you
create a variable you reserve some space in
memory.Basedonthedatatypeofavariable,theinterpreterallocates

Memoryanddecides whatcanbestoredinthereservedmemory.Therefore,byassigningdifferentdata
types to variables, you can store integers, decimals or characters in these variables.

Assigning Values to Variables

Python variables do not need explicit declaration to reserve memory space. The declaration
happens automatically when you assign a value to a variable. The equal sign (=) is used to assign
values to variables.

The operand to the left of the = operator is the name of the variable and the operand to the right of
the = operator is the value stored in the variable. For example −

#!/usr/bin/python

counter=100 # An integer
assignment miles =1000.0 # A
floatingpoint
name = "John" # Astring

print
counter
print
miles
print
name
Here, 100, 1000.0 and "John" are the values assigned to counter, miles, and name
variables, respectively. This produces the following result−
Page | 18
100

1000.0
John
Multiple Assignment
Python allows you to assign a single value to several variables simultaneously. For example −

a=b=c=1

Here, an integer object is created with the value 1, and all three variables are assigned to the same
memory location. You can also assign multiple objects to multiple variables. For example −

a,b,c = 1,2,"john"

Here, two integer objects with values 1 and 2 are assigned to variables a and b
respectively,andonestringobjectwiththevalue"john"isassignedtothevariable c.

Standard Data Types


The data stored in memory can be of many types. For example, a person's age is stored as a
numeric value and his or her address is stored as alphanumeric characters. Python has various
standard data types that are used to define the operations possible on them and the storage method
for each of them.

Python has five standard data types −


 Numbers
 String
 List
 Tuple
 Dicti
onary
PythonNum
bers
Number data types store numeric values. Number objects are created when you assign a value to
Page | 19
them. For example −

var1 = 1
var2 = 10
You can also delete the reference to a number object by using the del statement. The syntax of the del
statement is −

delvar1[,var2[,var3[. .............. ,varN]]]]

You can delete a single object or multiple objects by using the del statement. For example −

delvar

delvar_a, var_b

Python supports four different numerical types −


 int (signed integers)
 long (long integers, they can also be represented in octal andhexadecimal)
 float (floating point realvalues)
 complex (complex
numbers) Examples
Here are some examples of numbers −

Int long Float complex

10 51924361L 0.0 3.14j

100 -0x19323L 15.20 45.j

Page | 20
-786 0122L -21.9 9.322e-

36j

080 0xDEFABCECBDAECBFBA 32.3+e18 .876j

El

Page | 21
-0490 535633629843L -90. -

.6545+0

- 0x26 -052318172735L - 32.54e10 3e+26J


0 0

0x69 -4721885298529L 70.2-E12 4.53e-7j

 Python allows you to use a lowercase l with long, but it is recommended that you use only an
uppercase L to avoid confusion with the number 1. Python displays long integers with an
uppercaseL.

 A complex number consists of an ordered pair of real floating-point


numbersdenotedbyx+yj,wherexandyaretherealnumbersandjisthe imaginaryunit.

Python Strings
Strings in Python are identified as a contiguous set of characters represented in the quotation marks.
Python allows for either pairs of single or double quotes. Subsets of strings can be taken using the slice
operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from -1
at the end.

heplus(+)signisthestringconcatenationoperatorandtheasterisk(*)istherepetition operator. For example−

#!/usr/bin/python

str= 'Hello World!'

printstr # Prints completestring

Page | 22
printstr[0] # Prints first character of thestring
printstr[2:5] # Prints characters starting from 3rd to5th

printstr[2:] # Prints string starting from 3rdcharacter print str* 2


# Prints string twotimes
printstr+ "TEST" # Prints concatenated string

This will produce the following result −

Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST

Page | 23
Que. No. VIVA QUESTIONS

Q.1. What are the key features of Python?

Q.2. Differentiate between lists and tuples.

Q.3. Explain the ternary operator in Python.

Q.4. What are negative indices?

Q.5. Is Python case-sensitive?

Q.6. How long can an identifier be in Python?

Q.7. How would you convert a string into lowercase?

Q.8. What is the pass statement in Python?

Page | 24
EXPERIMENT NO 3

Aim: Study and WAP for Arithmetic operation in python.

Objectives: Student should get the knowledge of Arithmetic operation in python.

Outcomes: Student will be develop of Arithmetic operation programs in python.

Operators

Operators are the constructs which can manipulate the value of operands.

Consider the expression 4 + 5 = 9. Here, 4 and 5 are called operands and + is called operator.

Types of Operator

Python language supports the following types of operators.

 ArithmeticOperators

 Comparison (Relational) Operators

 AssignmentOperators

 LogicalOperators

 Bitwise Operators

 Membership Operators

 IdentityOperators

Let us have a look on all operators one by one.

Python Arithmetic Operators

Assume variable a holds 10 and variable b holds 20, then –


Page | 25
Operator Description Example

+ Addition Adds values on either side of the operator. a + b = 30

- Subtraction Subtracts right hand operand from left a – b = -


hand operand. 10

* Multiplication Multiplies values on either side of the a * b = 200


operator

/ Division Divides left hand operand by right hand b/a=2


operand

% Modulus Divides left hand operand by right hand b%a=0


operand and returns remainder

** Exponent Performs exponential (power) a**b =10


calculation onoperators to the
power 20

Page | 26
// Floor Division - The division of operands 9//2 = 4
where the result is the quotient in which and
the digits after 9.0//2.0
thedecimalpointareremoved.But if one of = 4.0,-
the operands is negative, the result is
11//3 =
floored, i.e., rounded away from zero
-4, -
(towards negative infinity)−
11.0//3

= -4.0

Example

Assume variable a holds 21 and variable b holds 10, then −


#!/usr/bin/python
a =21
b =10
c=0

c=a+b
print "Line 1 - Value of c is ", c
c=a-b
print "Line 2 - Value of c is ", c
c=a*b
print "Line 3 - Value of c is ", c
c=a/b
print "Line 4 - Value of c is ", c
c=a%b
print "Line 5 - Value of c is ", c
a =2
b =3
Page | 27
c = a**b
print "Line 6 - Value of c is ", c
a = 10
b=5
c = a//b
print "Line 7 - Value of c is ", c
When you execute the above program, it produces the following result −

Line 1 - Value of c is 31 Line


2 - Value of c is 11 Line 3 -
Value of c is 210 Line 4 -
Value of c is 2 Line 5 - Value
of c is 1 Line 6 - Value of c is
8 Line 7 - Value of c is 2

Page | 28
Que. No. VIVA QUESTIONS

Q.1. What is Python good for?

Q.2. Can you name ten built-in functions in Python and explain each in brief?

What will the following code output?


Q.3.

How will you convert a list into a string?


Q.4.
How will you remove a duplicate element from a list?
Q.5.

Can you explain the life cycle of a thread?


Q.6.

Explain the //, %, and ** operators in Python.


Q.7.

Page | 29
EXPERIMENT NO 4
Aim: Study and WAP for looping statement in python.
Objectives: Student should get the knowledge of for looping statement in python.
Outcomes: Student will be develop looping statement programs in python.
Looping Statement in Python:
Ingeneralstatementsareexecutedsequentially:Thefirststatementinafunctionis
executedfirst,followedbythesecond,andsoon.Theremaybeasituationwhenyou need to execute a block of code
several number oftimes.
Programming languages provide various control structures that allow for more complicated execution paths.
A loop statement allows us to execute a statement or group of statements multiple times. The following
diagram illustrates a loop statement −

Python programming language provides following types of loops to handle looping requirements.

Sr.No. Loop Type & Description

Page | 30
1 while loop

Repeats a statement or group of statements while a given condition is TRUE. It


tests the condition before executingthe loopbody.

2 for loop

Executes a sequence of statements multiple times and abbreviates the code that
manages the loop variable.

3 nested loops

Youcanuseoneormoreloopinsideanyanotherwhile,foror do..whileloop.

Loop Control Statements

Loop control statements change execution from its normal sequence. When execution leaves a scope, all
automatic objects that were created in that scope are destroyed.

Python supports the following control statements. Click the following links to check their detail.

Sr.No. Control Statement & Description

1 break statement

Terminates the loop statement and transfers execution to the statement


immediately following the loop.

Page | 31
2 continue statement

Causes the loop to skip the remainder of its body and immediately retest its
condition prior to reiterating.

3 pass statement

The pass statement in Python is used when a statement is required syntactically


but you do not want any command or code to execute.

It has the ability to iterate over the items of any sequence, such as a list or a string.

Syntax

foriterating_var in sequence:
statements(s)
If a sequence contains an expression list, it is evaluated first. Then, the first item in the
sequenceisassignedtotheiteratingvariableiterating_var.Next,thestatementsblockis executed. Each item in
the list is assigned to iterating_var, and the statement(s) block is executed until the entire sequence
isexhausted.

Flow Diagram

Page | 32
Example #!/usr/bin/python
forletterin'Python': # First Example
print 'Current Letter :',letter
fruits = ['banana', 'apple','mango']
forfruitinfruits: # SecondExample
print 'Current fruit :',fruit
print "Good bye!"

When the above code is executed, it produces the following result − Current
Letter : P
Current Letter : y
Current Letter : t

Current Letter : h Current


Letter : o Current Letter : n
Current fruit : banana
Current fruit : apple
Current fruit : mango Good
bye!
Iterating by Sequence Index

An alternative way of iterating through each item is by index offset into the sequence itself. Following is a
Page | 33
simple example −

#!/usr/bin/python
fruits = ['banana', 'apple', 'mango'] for index
in range(len(fruits)):
print 'Current fruit :', fruits[index]
print "Good bye!"

When the above code is executed, it produces the following result − Current fruit
: banana
Current fruit : apple
Current fruit : mango
Good bye!
Here, we took the assistance of the len() built-in function, which provides the total number of elements in
the tuple as well as the range() built-in function to give us the actual sequence to iterate over.

Using else Statement with Loops

Python supports to have an else statement associated with a loop statement

 If the else statement is used with a forloop, the else statement is executed when the loop has
exhausted iterating thelist.

 If the else statement is used with a while loop, the else statement is executed when the condition
becomesfalse.

The following example illustrates the combination of an else statement with a for statement that searches for
prime numbers from 10 through20.

#!/usr/bin/python

fornuminrange(10,20): #to iterate between 10 to20


foriinrange(2,num): #to iterate on the factors of the number if
num%i==0: #to determine the first factor

Page | 34
j=num/i #to calculate the second factor print
'%d equals %d * %d' %(num,i,j)
break #to move to the next number, the #first FOR else:
# else part of theloop
printnum, 'is a prime number'

When the above code is executed, it produces the following result− 10 equals 2
*5
11 is a prime number 12
equals 2 *6
13 is a prime number 14
equals 2 *7
15 equals 3 *5
16 equals 2 *8
17 is a primenumber

Page | 35
Que. No. VIVA QUESTIONS

Q.1. How would you convert a string into an int in Python?

Q.2. How do you take input in Python?

Q.3. What is a function?

Q.4. What is recursion?

Q.5. What does the function zip() do?

Q.6. How do you calculate the length of a string?

Q.7. Explain Python List Comprehension.

Q.8. How do you get all values from a Python dictionary?

Page | 36
EXPERIMENT NO 5
Aim: Study and Install IDE of Arduino and different types of Arduino
Objectives: Student should get the knowledge of Arduino IDE and different types of ArduinoBoard
Outcomes: Student will be get knowledge of Arduino IDE and different types of ArduinoBoard
Arduino:

Arduinoisaprototypeplatform(open-source)basedonaneasy-to-usehardwareand software. It consists of a


circuit board, which can be programmed (referred to as a microcontroller) and a ready-made software
called Arduino IDE (Integrated
DevelopmentEnvironment),whichisusedtowriteanduploadthecomputercodeto the physicalboard.
Arduino provides a standard form factor that breaks the functions of the micro- controller into a more
accessible package.
Arduinoisaprototypeplatform(open-source)basedonaneasy-to-usehardwareand software. It consists of a
circuit board, which can be programmed (referred to as a microcontroller) and a ready-made software
called Arduino IDE (Integrated
DevelopmentEnvironment),whichisusedtowriteanduploadthecomputercodeto the physicalboard.
The key features are −

 Arduino boards are able to read analog or digital input signals from different
sensorsandturnitintoanoutputsuchasactivatingamotor,turningLEDon/off, connect to the cloud and
many otheractions.
 You can control your board functions by sending a set of instructions to the microcontroller on the
board via Arduino IDE (referred to as uploadingsoftware).
 Unlike most previous programmable circuit boards, Arduino does not need an extra piece of hardware
(called a programmer) in order to load a new code onto the board. You can simply use a USBcable.

Page | 37
 Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn toprogram.
 Finally, Arduino provides a standard form factor that breaks the functions ofthe micro-controller into
a more accessiblepackage.
Download the Arduino Software (IDE)
 Get the latest version from the arduino.cc web site. You can choose between the Installer(.exe)and
the Zippackages.Wesuggestyouusethefirstonethatinstalls directly everything you need to use the
Arduino Software (IDE), including the drivers. With the Zip package you need to install the drivers
manually. The Zip file is also useful if you want to create a portableinstallation.
 When the download finishes, proceed with the installation and please allow the driver installation
process when you get a warning from the operatingsystem.

 Choose the components toinstall

Page | 38
 Choose the installation directory (we suggest to keep the defaultone)

 The process will extract and install all the required files to execute properly the Arduino Software
(IDE)

Page | 39
 Proceed with board specificinstructions
 When the Arduino Software (IDE) is properly installed you can go back tothe

Different Arduino Boards:


Arduino USB
1.Arduino uno

ThisisthelatestrevisionofthebasicArduinoUSBboard.Itconnectsto the computer with a standard USB cable


and contains everything else you need to program and use theboard.
2.Arduino NG REV-C

Revision C of the Arduino NG does not have a built-in LED on pin 13 - instead you'll see two small unused
solder pads near the labels "GND" and "13".

Arduino Bluetooth

The Arduino BT is a microcontroller board originally was based on the ATmega168, but now is supplied
with the 328, and the Bluegiga WT11 bluetooth module. It supports wireless serial communication over
bluetooth.

Arduino Mega

The original Arduino Mega has an ATmega1280 and an FTDI USB-to- serial chip.

Arduino NANO

The Arduino Nano 3.0 has an ATmega328 and a two-layer PCB. The power LED moved to the top of the
board.

Page | 40
Que. No. VIVA QUESTIONS
Q.1.
Define Arduino.

Q.2.
What is Pulse Width Modulation?

Q.3.
Mention applications of PWM in IoT.

Q.4.
Define MicroPython

Q.5.
Mention some of the wearable Arduino boards

Q.6.
What is a library in Arduino?

Q.7.
Explain Android things

Q.8.
What is WSN?

Page | 41
EXPERIMENT NO 6
Aim: Write program using Arduino IDE for Blink LED
Objectives: Student should get the knowledge of Arduino Board and different types of LED
Outcomes: Student will be Write program using Arduino IDE for Blink LED
Hardware Requirements:
 1xBreadboard
 1x Arduino UnoR3
 1x RGBLED
 1x 330ΩResistor
 2xJumper
With a simple modification of the breadboard, we could attach the LED to an output pin of the Arduino. Move the
red jumper wire from the Arduino 5V connector to D13, as shown below:

Now load the 'Blink' example sketch from Lesson 1. You will notice that both the built-in 'L' LED and

theexternal LED should nowblink.

Upload the modified sketch to your Arduino board and the LED should stillbeblinking, but this time
using pinD7.

Page | 42
1. /*
2. Blink
3. Turns on an LED on for one second, then off for one second, repeatedly.4.
5. This example code is in the public domain.6. */
7.
8. // Pin 13 has an LED connected on most Arduinoboards.
9. // give it aname:
10. intled = 13;11.
12. // the setup routine runs once when you pressreset:
13. void setup(){
14. // initialize the digital pin as anoutput.
15. pinMode(led,OUTPUT);
16.} 17.
18. // the loop routine runs over and over againforever:
19. void loop(){
20. digitalWrite(led,HIGH); // turn the LED on (HIGH is the voltagelevel)
21. delay(1000); // wait for asecond
22. digitalWrite(led,LOW); // turn the LED off by making the voltageLOW
23. delay(1000); // wait for asecond
24.}

Lets try using a different pin of the Arduino – say D7. Move the red jumper lead from pin D13 to pin D7 and
modify the following line near the top of the sketch:

1.intled = 13;

so that it reads:

1. intled = 7;

Page | 43
Que. No. VIVA QUESTIONS
Q.1.
What is a crystal oscillator?

Q.2.
What is Zigbee?

Q.3.
Mention suitable databases for IoT

Q.4.
What is the main difference between floating CPU and fixed-point CPU?

Q.5.
What are various types are of CAN Frame?

Q.6.
List out Some popular companies are working on IoT

Page | 44
EXPERIMENT NO 7
Aim: Write Program for RGB LED using Arduino.
Objectives: Student should get the knowledge of Arduino IDE and RGB Led
Outcomes: Student will be developed programs using Arduino IDE and Arduino Board for RGBLed
Hardware Requirements:
 1xBreadboard
 1x Arduino UnoR3
 1xLED
 1x 330ΩResistor
 2x Jumper
WiresBlinking theLED
With a simple modification of the breadboard, we could attach the LED to an output pin of the Arduino.
Move the red jumper wire from the Arduino 5V connector to D13, as shown below:

Now load the 'Blink' example sketch from Lesson 1. You will notice that both the built-in 'L' LED and the external LED
shouldnowblink.

Page | 45
intred_light_pin= 11;
intgreen_light_pin = 10;
intblue_light_pin = 9;
voidsetup() {
pinMode(red_light_pin, OUTPUT);
pinMode(green_light_pin, OUTPUT);
pinMode(blue_light_pin, OUTPUT);
}
voidloop() {
RGB_color(255, 0, 0); // Red
delay(1000);
RGB_color(0, 255, 0); // Green
delay(1000);
RGB_color(0, 0, 255); // Blue
delay(1000);
RGB_color(255, 255, 125); // Raspberry
delay(1000);
RGB_color(0, 255, 255); // Cyan
delay(1000);
RGB_color(255, 0, 255); // Magenta
delay(1000);
RGB_color(255, 255, 0); // Yellow
delay(1000);
RGB_color(255, 255, 255); // White
delay(1000);
}
void RGB_color(intred_light_value, intgreen_light_value, intblue_light_value)
{
analogWrite(red_light_pin, red_light_value);
analogWrite(green_light_pin, green_light_value);
analogWrite(blue_light_pin, blue_light_value);
}

Page | 46
Que. No. VIVA QUESTIONS
Q.1.
What is IoT Thingworx?

Q.2.
What is replication?

Q.3.
What is Salesforce IoT Cloud?

Q.4.
Explain IoT GE-PREDIX

Q.5.
What are IoT publishers?

Q.6.
What are mostly used IoT protocols?

Page | 47
EXPERIMENT NO 8
Aim: Study the Temperature sensor and Write Program foe monitor temperature using Arduino.
Objectives: Student should get the knowledge of Temperature Sensor
Outcomes: Student will be developed programs using Arduino IDE and Arduino Board for Temperature
Sensor
Connecting to a Temperature Sensor
These sensors have little chips in them and while they're not that delicate, they do need to be handled properly. Be
careful of static electricity when handling them and make sure the power supply is connected up correctly and is
between 2.7 and 5.5V DC - so don't try to use a 9V battery!
They come in a "TO-92" package which means the chip is housed in a plastic hemi-cylinder with three legs. The
legs can be bent easily to allow the sensor to be
plugged into a breadboard. You can also solder to the pins to connect long wires. If you need to waterproof
the sensor, you can see below for an Instructable for how to make an excellentcase.
Reading the Analog Temperature Data
Unlike the FSR or photocell sensors we have looked at, the TMP36 and friends doesn't act like a resistor. Because
of that, there is really only one way to read the temperature value from the sensor, and that is plugging the output
pin directly into an Analog (ADC) input.

Page | 48
Remember that you can use anywhere between 2.7V and 5.5V as the power supply. For this example I'm
showing it with a 5V supply but note that you can use this with a 3.3v supply just as easily. No matter what
supply you use, the analog voltage reading will range from about 0V (ground) to about 1.75V.
If you're using a 5V Arduino, and connecting the sensor directly into an Analog pin, you can use these
formulas to turn the 10-bit analog reading into a temperature:
Voltage at pin in milliVolts = (reading from ADC) * (5000/1024)
This formula converts the number 0-1023 from the ADC into 0-5000mV (= 5V) If you're using a 3.3V
Arduino, you'll want to usethis:
Voltage at pin in milliVolts = (reading from ADC) * (3300/1024)
This formula converts the number 0-1023 from the ADC into 0-3300mV (= 3.3V) Then, to convert millivolts
into temperature, use thisformula:
Centigrade temperature = [(analog voltage in mV) - 500] /10
Simple Thermometer

ThisexamplecodeforArduinoshowsaquickwaytocreateatemperaturesensor,it simply prints to the serial port what


the current temperature is in both Celsius and Fahrenheit.

Page | 49
1. //TMP36 PinVariables
2. intsensorPin= 0; //the analog pin the TMP36's Vout (sense) pin is connectedto
3. //the resolution is 10 mV / degree centigrade witha
4. //500 mV offset to allow for negative temperatures5.
6. /*
7. * setup() - this function runs once when you turn your Arduinoon
8. * We initialize the serial connection with the computer9. */
10.voidsetup()
11.{
12. Serial.begin(9600); //Start the serial connection with thecomputer
13. //to view the result open the serialmonitor
14.} 15.
16.voidloop() // run over and overagain
17.{
18. //getting the voltage reading from the temperaturesensor
19. intreading = analogRead(sensorPin);20.
21. // converting that reading to voltage, for 3.3v arduinouse3.3
22. floatvoltage = reading * 5.0;23.
voltage /=1024.0;
24.
25. // print out thevoltage
26. Serial.print(voltage); Serial.println(" volts");27.
28. // now print out thetemperature
29. float temperatureC= (voltage - 0.5) *100; //converting from 10 mv per degree wit
500 mVoffset
30. //to degrees ((voltage -500mV)
times 100)

Page | 50
31. Serial.print(temperatureC); Serial.println(" degrees C");32.
33. // now convert toFahrenheit
34. float temperatureF= (temperatureC* 9.0 / 5.0) +32.0;
35. Serial.print(temperatureF); Serial.println(" degrees F");36.

37.delay(1000);
38.}

Page | 51
Que. No. VIVA QUESTIONS
Q.1.
Mention some of the commonly used water sensors

Q.2.
List the Name of various temperature sensors.

Q.3.
Explain the working principle of thermistor.

Q.4.
What is Bluetooth Low Energy?

Q.5.
What are the functions used to read analog and digital data from a sensor in
Arduino?
Q.6.
What are the most common IoT applications?

Page | 52
EXPERIMENT NO 9
Aim: Study and Implement RFID, NFC using Arduino.
Objectives: Student should get the knowledge of RFID, NFC using Arduino.
Outcomes: Student will be developed programs using Arduino IDE and Arduino Board for RFID,NFC.
Hardware Requirements:

● 1 x Arduino UNO or 1 x Starter Kit for Raspberry Pi + RaspberryPi


● 1 x CommunicationShield
● 1 x RFID 13.56 MHz / NFC Module for Arduino and RaspberryPi
● 1 x Mifare tag(card/keyring/sticker)
RFID: ● 1 xPC
RFIDsystemismadeupoftwoparts:atagorlabelandareader.RFIDtagsorlabels are embedded with a
transmitter and a receiver. The RFID component on the tags have two parts: a microchip that stores
and processes information, and an antenna to receive and transmit a signal. The tag contains the
specific serial number for one specificobject.
To read the information encoded on a tag, a two-way radio transmitter-receiver called an interrogator or
reader emits a signal to the tag using an antenna. The tag responds with the information written in its
memory bank. The interrogator will then transmit the read results to an RFID computer program.
How to Interface RFID Reader to Arduino

Lets first wire the whole thing up. You may observe the circuit diagram given below. Take note of the
followingstuffs.

Note 1:-Power supply requirement of RFID Readers vary from product to product. The RFID reader I
used in this tutorial is a 12 Volts one. There are 5 Volts and 9 Volts versions available in themarket.

Note 2:- You may ensure the RFID Reader and RFID Tags are frequency compatible. Generally they are
supposed to be 125Khz. You may ensure this before purchasing them.

Note3:-TherearetwopossibleoutputsfromRFIDReader.OneisRS232compatible output and other one is

Page | 53
TTL compatible output. A TTL compatible output pin can be
connecteddirectlytoArduino.WhereasanRS232compatibleoutputmustbeconvertedto TTL using an RS232
to TTL converter (You can design this yourself using MAX232 IC)
So that’s all! Lets get to circuit diagram!

Make connections as shown. Make sure you connect Ground Pin of RFID reader to GroundPinofArduino. (You can also
use the hardware Rx pin of Arduinouno – that’s pin 0). If you are new to SoftwareSerial Library, you may read my
previous tutorial oninterfacingGSMmodule to Arduino(this article clearly explains how to use Software
SerialLibrary).

Page | 54
Lets get to the programming side!
#include <SoftwareSerial.h>
SoftwareSerialmySerial(9, 10);
void setup()
{
mySerial.begin(9600); // Setting the baud rate of SoftwareSerial Library
Serial.begin(9600); //Setting the baud rate of SerialMonito
r
}void loop()
{
if(mySerial.available()>0)
{
Serial.write(mySerial.read());
}
}

mySerial.available() – checks for any data coming from RFID reader module through the SoftwareSerial pin 9.
Returns the number of bytes available to read from software serial port.Returns a -1 if no data is available to read.

mySerial.read() – Reads the incoming data through software serial port.

Serial.write() – Prints data to serial monitor of arduino. So the function Serial.write(mySerial.read())–


printsthedatacollectedfromsoftwareserialporttoserial monitor of arduino.

Page | 55
Que. No. VIVA QUESTIONS
Q.1.
What is RFID.

Q.2.
Differentiate between RFID & NFC.

Q.3.
What are the fundamental components of IoT?

Q.4.
Library present in arduino for serial communication.

Q.5.
How to install a new library in Arduino?

Q.6.
Name some important IoT hardware

Page | 56
EXPERIMENT NO 10
Aim: Study and Implement MQTT Protocol using Arduino.
Objectives: Student should get the knowledge of MQTT Protocol using Arduino.
Outcomes: Student will be developed programs using Arduino IDE and Arduino Board for
MQTTProtocol
MQTT:
MQ Telemetry Transport (MQTT) is an open source protocol for constrained devices and low-bandwidth, high-
latency networks. It is a publish/subscribe messaging transport that is extremely lightweight and ideal for
connecting small devices to constrained networks.
MQTT is bandwidth efficient, data agnostic, and has continuous session awareness. MQTT targets large
networks of small devices that need to be monitored or controlled fromaback-
endserverontheInternet.Itisnotdesignedfordevice-to-devicetransfer. Nor is it designed to “multicast” data to many
receivers. MQTT is extremely simple, offering few controloptions.

MQTT methods
MQTT defines methods (sometimes referred to as verbs) to indicate the desired action to be performed on the
identified resource. What this resource represents, whether pre-existing data or data that is generated
dynamically, depends on the implementation of the server. Often, the resource corresponds to a file or the output
of an executable residing on the server.
Connect
Waits for a connection to be established with the server.
Disconnect
WaitsfortheMQTTclienttofinishanywork it mustdo, andfortheTCP/IPsession todisconnect.
Subscribe

Page | 57
Waits for completion of the Subscribe or Unsubscribe method.
Unsubscribe
Requests the server unsubscribe the client from one or more topics.
Publish
Returns immediately to the application thread after passing the request to the MQTT client.

Page | 58
` Que. No. VIVA QUESTIONS
Q.1.
List layers of IoT protocol stack

Q.2.
Mention suitable databases for IoT

Q.3.
How to reduce the size of the sketch?

Q.4.
List majorly used IoT controllers by industries

Q.5.
What is Z-Wave?

Q.6.
What is MQTT?

Page | 59
EXPERIMENT NO 11
Aim: Study and Configure Raspberry Pi.
Objectives: Student should get the knowledge of Raspberry Pi.
Outcomes: Student will be get knowledge of Raspberry Pi

Raspberry Pi

The Raspberry Pi is a series of small single-board computers developed in the UnitedKingdomby the Raspberry
Pi Foundationto promote the teaching of basic computersciencein schools and in developing countries.The original
model became far more popular than anticipated, selling outside of its target market for usessuch as robotics.
Peripherals (including keyboards, mice and cases) are not included with the Raspberry Pi. Some accessories
however have been included in several official and unofficialbundles.
AccordingtotheRaspberryPiFoundation,over5millionRaspberryPihavebeensold
beforeFebruary2015,makingitthebest-selling.ByNovember2016 they had sold 11 million units, reaching 12.5m in
March 2017, making it thethird best-selling "general purpose computer"ever.
To get started with Raspberry Pi, you need an operating system. NOOBS (New Out Of Box Software) is an easy
operating system install manager for the Raspberry Pi.
How to get and installNOOBS

DOWNLOAD NOOBS OSFROM

We recommend using an SD card with a minimum capacity of 8GB.

1. GO to thehttps://www.raspberrypi.org/downloads/

2. Click on NOOBS, then click on the Download ZIP button under ‘NOOBS (offline and network install)’,
and select a folder to save itto.
3. Extract the files from thezip.

FORMAT YOUR SD CARD

Page | 60
It is best to format your SD card before copying the NOOBS files onto it. To do this:

1. DownloadSD Formatter 4.0for either Windows orMac.


2. Follow the instructions to install thesoftware.
3. InsertyourSDcardintothecomputerorlaptop’sSDcardreaderandmakeanoteofthe drive letter allocated to it,
e.g.G:/
4. In SD Formatter, select the drive letter for your SD card and formatit.

DRAG AND DROP NOOBS FILES


1. Once your SD card has been formatted, drag all the files in the extracted NOOBS folder and drop them
onto the SD carddrive.
2. The necessary files will then be transferred to your SDcard.
3. When this process has finished, safely remove the SD card and insert it into your RaspberryPi.
FIRST BOOT
1. Plug in your keyboard, mouse, and monitorcables.
2. Now plug the USB power cable into yourPi.
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 will then run through its installation process. Note that this can take awhile.
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
RaspberryPicameraboard,orevencreateusers.YoucanexitthismenubyusingTabon your keyboard to move
toFinish.

LOGGING IN AND ACCESSING THE GRAPHICAL USER INTERFACE

The default login for Raspbian is username pi with the password raspberry. Note that you will not see any
writing appear when you type the password. This is a security feature in Linux.
To load the graphical user interface, type startx and press Enter.

Page | 61
Que. No. VIVA QUESTIONS
Q.1.
List available wireless communications boards available in Raspberry Pi?

Q.2.
What are the various types of antennas designed for IoT devices?

Q.3.
Why use the scheduler in RTOS?

Q.4.
List available models in Raspberry Pi

Q.5.
Mention real-time usage of Raspberry pi

Q.6.
What are the operating systems supported by Pi?

Page | 62
EXPERIMENT NO 12
Aim: WAP for LED blink using Raspberry Pi.

Objectives: Student should get the knowledge of LED blinking using Raspberry Pi. Outcomes: Student will
be developed program of LED bilking using Raspberry Pi. Hardware Requirements:
 1xBreadboard
 1x RaspberryPi
 1x RGBLED
 1x 330ΩResistor
 2x JumperWires

Semiconductor light-emitting diode is a type of component which can turn electric


energyintolightenergyviaPNjunctions.Bywavelength,itcanbecategorizedintolaser diode, infrared light-emitting
diode and visible light-emitting diode which is usually known as light-emitting diode(LED).
When2V-3VforwardvoltageissuppliedtoanLED,itwillblinkonlyifforwardcurrents flow through the LED.
Usually there are red, yellow, green, blue and color-changing
LEDswhichchangecolorwithdifferentvoltages.LEDsarewidelyusedduetotheirlow operating voltage, low
current, luminescent stability and smallsize.
LEDs are diodes too. Hence they have a voltage drop which usually varies from 1V to 3V depending on their
types. Generally they brighten if supplied with a 5mA-30mA current and we usually use 10mA-20mA.Thus
when an LED is used ,it is necessary to connect a current-limiting resistor to protect it from being burnt.
In this experiment, connect a 220Ω resistor to the anode of the LED, then the resistor to 3.3 V and connect the
cathode of the LED to GPIO0 (See Raspberry Pi Pin Number Introduction). Write1toGPIO0, and the
LEDwillstayoff;write0toGPIO0,andthentheLEDwillblink,just as indicated by the principleabove

Page | 63
Step 1: Build the circuit given above
Step 2: Change directory
cd /home/pi/Sunfounder_SuperKit_Python_code_for_RaspberryPi/
Step 3: Run
sudo python 01_led.py
Now, you should see the LED blink.
Python Code
importRPi.GPIO as IO # calling header file for GPIO’s of PI
import time # calling for time to provide delays in program

IO.setmode (IO.BOARD) # programming the GPIO by BOARD pin numbers, GPIO21 is called as PIN40
IO.setup(40,IO.OUT) # initialize digital pin40 as an output.
IO.output(40,1) # turn the LED on (making the voltage level HIGH)
time.sleep(1) # sleep for a second
IO.cleanup() # turn the LED off (making all the output pins LOW)
time.sleep(1) #sleep for a second

#loop is executed second time


IO.setmode (IO.BOARD)
IO.setup(40,IO.OUT)
IO.output(40,1)
time.sleep(1)
IO.cleanup()
time.sleep(1)

Page | 64
#loop is executed third time
IO.setmode (IO.BOARD)
IO.setup(40,IO.OUT)
IO.output(40,1)
time.sleep(1)
IO.cleanup()
time.sleep(1)

Page | 65
Que. No. VIVA QUESTIONS
Q.1.
What is the difference between M2M and IoT?

Q.2.
What are the features of influxDB?

Q.3.
What are IoT testing tools?

Q.4.
Mention IoT software

Q.5.
What is Shodan?

Q.6.
Mention some examples of MEMS sensor

Page | 66
EXPERIMENT NO 13
Aim: Study and Implement Zigbee Protocol using Raspberry Pi.
Objectives: Student should get the knowledge of Zigbee Protocol using Raspberry Pi.
Outcomes: Student will be developed program of Zigbee Protocol using Raspberry Pi.
Hardware Requirements

 RaspberryPi2
 XBee 1mW Wire Antenna- Series 1 (2 No:)
 XBee Explorer Dongle (2No:)

ZigBeeCommunication Using RaspberryPi:


ZigBee is a communication device used for the data transfer between the controllers, computers, systems, really
anything with a serial port. As it works with low power consumption, the transmission distances is limited to
10–100 meters line-of-sight. ZigBee devices can transmit data over long distances by passing data through
amesh network of intermediate devices to reach more distant ones. ZigBee is typically used in low data rate
applications that require long battery life and securenetworking. Its main applications are in the field of wireless
sensor network based on industries as it requires short-range low-rate wireless data transfer. The technology
defined by the ZigBee specification is intended to be simpler and less expensive than other
wirelessnetworks.
Here we make use of an interface of Zigbee with Raspberry Pi2 for a proper wireless
communication.RaspberryPi2hasgotfourUSBports,soitisbettertouseaZigbeeDonglefor this interface. Now we want
to check the communication between the two paired ZigBee modules.

Page | 67
The response showed inside a red box indicates the presence of ausb device in the module. Write a python script to
perform Zigbee communication which is given below.
import serial
# Enable USB Communication
ser = serial.Serial('/dev/ttyUSB0', 9600,timeout=.5) while
True:
ser.write('HelloUser\r\n') # write a Data
incoming =ser.readline().strip()
print 'Received Data : '+ incoming

Page | 68
Que. No. VIVA QUESTIONS
Q.1.
What is Asset Tracking?

Q.2.
What are the risks associated with the IOE Internet of Everything?

Q.3.
What is the basic difference between the IoT network and Wireless Sensor
Network?
Q.4.
What is the importance of the network in IoT?

Q.5.
What is the connection between IoT and sensors in the commercial enterprise?

Q.6.
Explain the types of testing in IoT?

Page | 69
EXPERIMENT NO 14
Aim: WAP for interfacing various sensors and camera module with using Raspberry Pi.

Objectives: Student should get the knowledge of sensors and camera module .Outcomes: Student will be
developed program of sensor and camera module using Raspberry Pi.
Hardware Requirements:
 1xBreadboard
 1x RaspberryPi
 1x camera
 Temperature sensor, Humidity sensor,Gas sensor,LDR
 1x 330ΩResistor
 2x JumperWires

Sensor CommunicationUsing RaspberryPi: The DHT22 temperature and humidity sensor is used in
the Smart Home Automation to access the temperature threshold should be determined if the fan or air
conditioner need to turn on or off automatically. The temperature sensor data may also indicate fire in the
house and notify the users through SMS and email notification.

DHT22
In addition, Raspberry Pi has 40 GPIO pins which can be used to connect with home appliances and control
them based on the sensor data. Raspberry Pi is connected to the DHT22 to sense temperature and humidity.
Sensor data from the DHT22 is decoded using Adafruit’s DHT22 Python library and converted to user
readable format for both the temperature and humidity, i.e., temperature in 0C and humidity in %.

Page | 70
IoT based sensor network using RPI
The sensor data is then stored in a MySQL database which is configured in the Raspberry

Pi with proper credentials. The value of the sensor data is then compared with the threshold value that we
have specified in the Python program. Two temperature thresholds have been specified one for maximum
positive temperature value and another for maximum negative temperature value.

Humidity Index
If the temperature exceeds these thresholds, then it sends an email and SMS notification by using Raspberry Pi
as means to send the alert to the users When temperature of the house rises above the trigger limit set by the
owner, the Raspberry Pi will instantly send SMS and Email notifications to the owner. The time of sending
mail, sensor ID, triggered limit, and the last sensed value are also stored in the database of the Raspberry Pi .

Page | 71
Camera Modules

Raspberry Pi currently sell two types of camera board: an 8MP device and a 12MP High Quality (HQ) camera.
The 8MP device is also available in NoIR form without an IR filter. The original 5MP device is no longer
available from Raspberry Pi. The specifications of all the devices can be found here.

All Raspberry Pi cameras are capable of taking high-resolution photographs, along with full HD 1080p video,
and can be fully controlled programmatically. This documentation describes how to use the camera in various
scenarios, and how to use the various software tools.

Once installed, there are various ways the cameras can be used. The simplest option is to use one of the
provided camera applications. There are four Linux command-line applications installed by default

(e.g. raspistill ): using these is described .

You can also programatically access the camera using the Python programming language, using

the picamera library.

Page | 72
Advanced camera usage

Advanced features, along with some hints and tips, are described in the following pages:

 Using RAW
 Long exposures
 Directly accessing sensors
 Using V4L2 to access the camera (e.g. Using Pi cameras as webcams)
 Removing the HQ camera IR filter

libcamera - The future of Raspberry Pi camera software

libcamera is a new Linux API for interfacing to cameras. Raspberry Pi have been involved with the
development of libcamera and are now using this sophisticated system for new camera software. This means
Raspberry Pi are moving away from the firmware-based camera image processing pipeline (ISP) to a more open
system.

Page | 73
Que. No. VIVA QUESTIONS
Q.1.
What is sharding?

Q.2.
What is Thingful?

Q.3.
What are IoT test approaches?

Q.4.
Define IoT Contiki

Q.5.
What is the aim of airflow sensors?

Q.6.
What is Salesforce IoT Cloud?

Page | 74

You might also like