IoT Lab Rtu
IoT Lab Rtu
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.
Page | 1
LIST OF EXPERIMENTS
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.
Page | 4
Department Of Computer Science & Engineering
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.
PEO-4 teamwork skills, multidisciplinary approach, and an ability to relate engineering issues to
broader social context.
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.
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.
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.
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.
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.
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
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
5. Define GPIO.
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.
PythonisInterpreted−Pythonisprocessedatruntimebytheinterpreter.Youdo
notneedtocompileyourprogrambeforeexecutingit.ThisissimilartoPERLand PHP.
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
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.
Scalable − Python provides a better structure and support for large programs than shell scripting.
Page | 16
Apartfromtheabove-mentionedfeatures,Pythonhasabiglistofgoodfeatures,feware listed below−
It provides very high-level dynamic data types and supports dynamic type checking.
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.
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.
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.
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 −
You can delete a single object or multiple objects by using the del statement. For example −
delvar
delvar_a, var_b
Page | 20
-786 0122L -21.9 9.322e-
36j
El
Page | 21
-0490 535633629843L -90. -
.6545+0
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.
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.
#!/usr/bin/python
Page | 22
printstr[0] # Prints first character of thestring
printstr[2:5] # Prints characters starting from 3rd to5th
Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST
Page | 23
Que. No. VIVA QUESTIONS
Page | 24
EXPERIMENT NO 3
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
ArithmeticOperators
AssignmentOperators
LogicalOperators
Bitwise Operators
Membership Operators
IdentityOperators
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
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 −
Page | 28
Que. No. VIVA QUESTIONS
Q.2. Can you name ten built-in functions in Python and explain each in brief?
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.
Page | 30
1 while loop
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 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.
1 break statement
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
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
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.
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
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
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:
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.
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
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
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
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:
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.
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.
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
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.
Page | 60
It is best to format your SD card before copying the NOOBS files onto it. To do this:
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
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
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:)
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
You can also programatically access the camera using the Python programming language, using
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 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