IoT Advance Complete Notes
IoT Advance Complete Notes
UNIT 1
PYTHON BASICS
LECTURE 1
INTRODUCTION
What is Python?
• Python is a high-level programming language created by Guido Van Rossum.
• Python was first released in 1991.
• Today Python interpreters are available for many Operating Systems including
Windows and Linux.
Reasons for Popularity
❑ Free:
Python is free to use and distribute. It is supported by community. Python interpreter
is available for every major platform.
❑ Software quality:
Better than traditional and scripting languages. Readable code, hence reusable and
maintainable.
❑ Developer productivity:
Much better than statically typed languages. Much smaller code. Less to type, debug
and maintain. No lengthy compile and link steps.
❑ Program portability:
Python programs run unchanged on most platforms. Porting program to a new
platform usually need only cut and paste. This is true even for GUI, DB access,
Web programming, OS interfacing,
Python Specification
2|Page
INTERNET OF THINGS (ADVANCE)
3|Page
INTERNET OF THINGS (ADVANCE)
UNIT 1
PYTHON BASICS
LECTURE 2
INSTALLATION OF PYTHON
Python Installation under Windows
• Python has evolved over the years. The latest version for Windows and Linux
environments was Python 3.8.2.
• Python is not shipped as part of Windows OS. So, we need to install it
separately. For this we need to download the Python installer from
www.python.org/downloads/. (http://www.python.org/downloads/.) While
downloading ensure that you choose the appropriate installer from the following,
based on whether you wish to install it on a 32- bit machine or a 64-bit machine:
❖ 64-bit machine: Download Windows x86-64 executable installer
❖ 32-bit machine: Download Windows x86 executable installer
• Once you have chosen and downloaded an installer, execute it by double-
clicking on the downloaded file. A dialog shown in Figure will appear on the
screen.
• In this dialog check the check box 'Add Python 3.8 to PATH'
• Click on 'Install Now' and the installation will happen in a few minutes. Python
files will get installed in the directory:
4|Page
INTERNET OF THINGS (ADVANCE)
C:\Users\SAS\AppData\Local\Programs\Python\Python38-32
• In this path ‘SAS' will be substituted by your user’s name and 'Python38-32' by
version number of Python installation that you have downloaded and installed.
WORKING WITH PYTHON
▪ Once Python is installed, program development can be done using the built-in
Python Integrated Development and Learning Environment (IDLE).
▪ IDLE is a software application that helps programmers develop software code
efficiently.
▪ IDLE is a good development tool. It offers handy features like syntax
highlighting, context-sensitive help and debugging.
▪ Syntax highlighting feature display keywords, functions, methods and strings in
different colors making it easy to identify them.
Program development in Python can be done in 3 ways:
• Using built-in IDLE.
• Using third-party IDEs.
• Using online Python shells.
1. Using Built in IDLE
It is basic integrated learning platform available with the standard python package. It
need not be installed separately. Debuggers are commonly used in built IDLE.
2. Using third-party IDEs
There are third-party packages available for doing almost everything. For Example:
• NumPy: Advanced mathematical operations library with support for large multi-
dimensional arrays and matrices.
• SciPy: Scientific computing library for optimization, integration, interpolation,
signal processing, image processing, etc.
• Pandas: Library for manipulating numerical tables and time series.
• Matplotlib: 2D and 3D Data visualization library.
• OpenCV: Open-source Computer vision library.
3. Using online Python shells.
If you do not wish to install any Python development tool on your machine, then you
can use any of the following online Python shells:
5|Page
INTERNET OF THINGS (ADVANCE)
• https://www.python.org/shell/ (https://www.python.org/shell/)
• https://ideone.com/ (https://ideone.com/)
• https://repl.it/languages/python3 (https://repl.it/languages/python3)
More Sophisticated Tools
Many tools have come into existence to help Python programmers build and
document their program or scripts. These include:
1. Jupyter Notebook - It is a very flexible browser-based tool that lets us to
interactively work with Python (and many other languages). It lets us put our
Python code, output of the code and any kind of visualization or plot etc. in the
same document called Notebook. It is a great tool doing modular program
development.
2. Google Colab - This tool provides a free Jupyter notebook environment to
execute code on Google's cloud servers. As a result, you can leverage the
power of Google's hardware.
3. Spyder - This tool provides a Scientific Python Development Environment with
sophisticated testing and debugging features.
Both Jupyter and Spyder are part of a very popular software distribution called
Anaconda. So, once you download and install Anaconda, you get Jupyter and Spyder
ready-made.
6|Page
INTERNET OF THINGS (ADVANCE)
UNIT 1
PYTHON BASICS
LECTURE 3
PYTHON PRINT FUNCTION ()
The word print is a Function in Python.
What is a function?
A function is a block of code that can perform a specific action. In addition to this,
these blocks of code don’t execute until you call the function.
• Built-in functions - The functions that are pre-defined in Python are known as
Built-in functions.
• User-defined functions - The functions that are created by the programmers
or developers in Python are called User-defined functions.
The function print () takes zero or more arguments and displays them on the screen.
The print () is sending the data to an output device, i.e., console. The print () function
does not evaluate anything.
Let's see it practically. Open the IDE and run the following code:
7|Page
INTERNET OF THINGS (ADVANCE)
8|Page
INTERNET OF THINGS (ADVANCE)
Another example:
You can see a line in between the "ToolsQA" and "Python PCEP Course". As
mentioned, the empty print statements give us a new line.
What happens when we pass multiple lines as an argument to the print function.
Let's see it.
9|Page
INTERNET OF THINGS (ADVANCE)
Consequently, add quotes at the end of the first-line text and start of the second-line
text. You can see the code in the block below.
10 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 1
PYTHON BASICS
LECTURE 4
ESCAPE CHARACTER SEQUENCE
• In other words, it has a special meaning when we use it inside the strings.
• As the name suggests, the escape character escapes the characters in a string
for a brief moment to introduce unique inclusion.
• Backlash signifies that the next character after it has a different meaning. It
could be printing double quotes or indicating a new line.
• Let's see what escape sequences are and how to use them in Escape
Sequences in Python.
11 | P a g e
INTERNET OF THINGS (ADVANCE)
It confuses the interpreter. In other words, the interpreter accepts only one pair of
quotes of a similar type. But, in our example, we have a double pair of the same kinds
of quotes.
That's the reason why we get an error. Consequently, run the same example and see
the output.
Examples:
# wrong quotes
print(""ToolsQA"")
Put a backslash before the quote that you wish to have in your text. Let's run the code
below.
12 | P a g e
INTERNET OF THINGS (ADVANCE)
In other words, we have used the double quote and backslash in combination (\").
That combination is one of the escape sequences in Python. This escape sequence
tells Python that it needs to remove the backslash and put the quote in the string.
# trying to print \
print("\")
13 | P a g e
INTERNET OF THINGS (ADVANCE)
Python gives an error. When you write \, Python expects an escape sequence. But
there is no escape sequence in the text.
So we got an error. To print a backslash, we have to use the double backslashes (\\).
Let's try it.
# trying to print \
print("\\")
\n means a new line. We will get a new line when we use the escape sequence \n in
the print function. Let's see what happens when we put the escape sequence \n in
the middle of the text.
14 | P a g e
INTERNET OF THINGS (ADVANCE)
# \n usage
print("I am from\nToolsQA")
Can you guess the output? I think most of you already guessed it.
It gives a tab space in the output. Let say we have a text "I am from\tToolsQA", then
the output will contain a tab space between the words from and ToolsQA. Additionally,
let's see the example in IDE.
# \t usage
print("I am from\tToolsQA")
15 | P a g e
INTERNET OF THINGS (ADVANCE)
16 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 1
PYTHON BASICS
LECTURE 5
PYTHON VARIABLES
What is Literal?
Literals are some data that can be identified by themselves. For example, if you take
a number 759, we can quickly recognize it by simply seeing it.
Some examples of literals are 151, 7.59, 0.11, "ToolsQA," etc. We have used
double-quotes for the ToolsQA example, and it is a string literal. So far, we have
mentioned it as a text. The real number 7.59, 0.11 is known as floats.
A specific kind of data item defined by its value is known as Data Types.
Data types are the building blocks for any programming language.
1. Integers
2. Floats
3. Characters
4. Strings
5. Booleans
The numbers that don't have any fractional parts are known as Integers.
17 | P a g e
INTERNET OF THINGS (ADVANCE)
We can use the integers directly as we use it generally. In other words, there is no
special notation for the integers in Python.
Python doesn't allow us to put commas in between the digits of a number. Let's see
what happens if we write them in the print statement?
18 | P a g e
INTERNET OF THINGS (ADVANCE)
We didn't get any errors. In other words, the print statement takes them as three
different numbers and prints them.
But that's not what we want. We want the entire number as 123456789. So, in order
to write long integers we do the following.
Using underscore (_ ) in place of the comma (,) and space ( ) in the number, we can
achieve the goal.
Examples
19 | P a g e
INTERNET OF THINGS (ADVANCE)
Use the hyphen (-) before the number to make it a negative number. In other words,
everything else is similar to a positive number. If we don't put a hyphen (-) before a
number, then Python considers it as a positive integer.
int() function
The function int () helps to convert a string or float into an integer.
Let's see some examples of the conversion of other data types into an integer.
Examples
print(int("123"))
20 | P a g e
INTERNET OF THINGS (ADVANCE)
print(int("ToolsQA2019"))
If you pass float to the int() function, it returns the integer part of the float. In other
words, say you pass the value 7.59 to the int() function. It returns the integer part,
i.e., 7.
21 | P a g e
INTERNET OF THINGS (ADVANCE)
print(int(7.59))
# floating-point numbers
print(7.59)
22 | P a g e
INTERNET OF THINGS (ADVANCE)
Scientific Notation
If the floating-point values are huge numbers, then we will use scientific notation to
represent them. In other words, we have to use the alphabet e or E in the scientific
notation.
If you see the number 7590000000000.0, it is complicated to type all the zeroes. In
other words, instead of typing all the zeroes, we can represent it as 759 x 1010, which
is 759E10 in scientific notation.
In scientific notation, the part after the E must be an integer. In addition to this, before
part of the E may be integer or float. Let's see some examples.
# floating-point numbers
print(0.000007)
23 | P a g e
INTERNET OF THINGS (ADVANCE)
As shown above, Python chooses the appropriate notation to display the floating-point
numbers based on the value.
float () function
The float () function works similar to the int () function.
24 | P a g e
INTERNET OF THINGS (ADVANCE)
It is used to identify special characters and ASCII codes (American Standard Code
for Information Interchange).
We have a method chr () in Python to convert a number into the respective character.
chr() function takes only one argument and returns the corresponding character.
print(chr(65))
The number that we have given is the ASCII value of A. Therefore; the output is A.
25 | P a g e
INTERNET OF THINGS (ADVANCE)
Similar to the chr(), we have ord() function that works opposite to the chr().
In other words, the ord() function takes any character and returns the ASCII value of
the given character.
For example, if you give character A to the ord(), then it returns the number 65 -
ASCII value of A.
print(ord('A'))
26 | P a g e
INTERNET OF THINGS (ADVANCE)
Text that has single or double quotes at the starting and ending is known as a string.
# string
print("ToolsQA")
Consequently, the output of the above code is ToolsQA. Let's see the same example
with single-quotes.
# string
print('ToolsQA')
27 | P a g e
INTERNET OF THINGS (ADVANCE)
str()function
str() is similar to the functions int and float.
And it takes one or zero arguments. In other words, if we don't pass anything to
the str() function, then it returns an empty string.
print(str())
As a result, the function str without any arguments returns an empty string.
28 | P a g e
INTERNET OF THINGS (ADVANCE)
Python has a method called bool() to convert any object into a Boolean value.
bool() function
The function bool() returns either True or False based on the argument.
29 | P a g e
INTERNET OF THINGS (ADVANCE)
print(bool(5))
The output of the above code is True. We have passed a non-zero value. Therefore,
it returns True.
print(bool(0))
30 | P a g e
INTERNET OF THINGS (ADVANCE)
Variables contain mainly two parts, one is a name, and another one is value.
Moreover, Values may be of different data types.
An assignment operator is nothing but equals to (=) symbol. The left side of the
assignment contains a name, the right side of the assignment includes a value.
variable_name = value
• Firstly, Python allows using only alphabets, digits, and underscores (_) for
the naming of variables.
We can't use keywords as variable names. Let's see some such keywords.
Python Keywords
Keywords are the reserved words in Python. Moreover, these keywords have
different meanings for various purposes. See the list of keywords.
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class',
'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if',
'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try',
'while', 'with', 'yield']
We can't use the above keywords to name variables in our code. But we can use
them by changing the case of any letter in the keyword. For example,
But, we can name our variable by changing the case of any letter in the keyword print.
32 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 1
PYTHON BASICS
LECTURE 6
PYTHON OPERATORS
Python Arithmetic operators take numeric values as operands and return a single
value as a result.
33 | P a g e
INTERNET OF THINGS (ADVANCE)
Symbol Operator
** Exponentiation
* Multiplication
/ Division
% Modulo
+ Addition
- Subtraction
The left operand of the operator is base and the right one is an exponent.
For example, we will represent the 2 to the power of 5 as 25. Conclusively, we can
calculate the value of 25 using the ** operator as 2 ** 5.
# exponential operator
print(2 ** 5)
print(2. ** 5)
print(2 ** 5.)
print(2. ** 5.)
34 | P a g e
INTERNET OF THINGS (ADVANCE)
• Firstly, when all the operands of exponentiation are integers, then the result is
an integer too.
• Secondly, when at least one operand is a float, then the result is a float.
The multiplication operator multiplies any two numbers and gives the result.
35 | P a g e
INTERNET OF THINGS (ADVANCE)
The multiplication operator also follows the same rules as exponentiation for
calculating integer or float values.
The division operator helps to divide a number with another number. We can
recognize the division operator using the symbol slash (/).
36 | P a g e
INTERNET OF THINGS (ADVANCE)
The result of the division operator is always a float irrespective of the type of
operands.
The double slash (//) is the symbol used to represent floor division (or Integer
division).
For example,
print(5 // 2)
print(5. // 2)
print(5 // 2.)
print(5. // 2.)
37 | P a g e
INTERNET OF THINGS (ADVANCE)
If you see the output/ result of the first operation, i.e., integer by integer is an integer
value. Similarly, the remaining results are floats. Moreover, it's on the same lines as
exponentiation and multiplication.
The rounding off happens to the nearest integer value that is less than the actual
result. In the above case, the nearest integer that is less than 1.5 is 1. For example,
print (11//3) = 3
print (5//5) = 1
print(3 // -2)
print(-3. // 2)
The result of the code with / operator is -1.5 and -1.5. The floor division (//) rounds
the result to the nearest and lesser integer value. That is to say, -2 is lesser than
-1. Therefore, the output is -2 and -2.0.
The percent (%) sign is the symbol to represent the modulo operator.
It will give you the remainder left after performing the floor division.
# modulo operator
print(5 % 2)
38 | P a g e
INTERNET OF THINGS (ADVANCE)
We have to use the plus (+) sign for the addition operation.
For example,
We use the same minus (-) that we use in the usual maths for subtraction.
For example,
39 | P a g e
INTERNET OF THINGS (ADVANCE)
Similarly, unary operators need only one operand to perform their respective
operations.
We have already seen + and - as binary operators (addition and subtraction), Let's
see how we can use them as Unary operators.
For example,
40 | P a g e
INTERNET OF THINGS (ADVANCE)
Now mix the binary operator (+ and -) with the Unary operator (+ and -).
41 | P a g e
INTERNET OF THINGS (ADVANCE)
Based on which operator you evaluate first, you will either get 37 or 49 as an answer.
Precedence
We get the result by performing multiplication first, and then the addition operation.
The expression evaluates as 2 + 5 * 7 => 2 + 35 => 37.
Look at the precedence table, which defines in which order the operators evaluate.
Precedence Table
Precedence Operators
1 +, - (unary)
2 **
42 | P a g e
INTERNET OF THINGS (ADVANCE)
Precedence Operators
3 *, /, %, //
4 +, - (Binary)
The operators with number 1 have the highest precedence, and the operators with
number 4 have the lowest precedence.
Multiple operators in a row mean that they all have the same precedence.
For example,
print( 75 / 2)*
Based on what we have learned so far, both * and / have the same precedence. So
how do we evaluate this one? We need to learn another concept called associativity
to get to this answer.
Associativity Or Binding
Which means the evaluation of the expression happens from left to right.
Some operators have the right associativity, and the flow of execution is from right to
left. For example,
# associativity
print(7 - 4 - 1)
We can perform the above expression from left to right or right to left. Look at the
result from both directions.
43 | P a g e
INTERNET OF THINGS (ADVANCE)
We got two different results. Run the example in IDE to find out the associativity of
the - operator.
We got the result as 2. So, that shows that the associativity of - is left.
Let's take an example to see the right associativity operator from the list of operators
we have discussed.
# associativity
print(5 ** 1 ** 2)
44 | P a g e
INTERNET OF THINGS (ADVANCE)
Let's have a look at the associativity of the operators we have learned so far.
Operators Associativity
** right to left
*, /, %, // left to right
45 | P a g e
INTERNET OF THINGS (ADVANCE)
Python Tuples
A Python Tuple is a group of items that are separated by commas. The indexing,
nested objects, and repetitions of a tuple are somewhat like those of a list, however
unlike a list, a tuple is immutable.
The distinction between the two is that while we can edit the contents of a list, we
cannot alter the elements of a tuple once they have been assigned.
Example
o Tuples are an immutable data type, which means that once they have been
generated, their elements cannot be changed.
o Since tuples are ordered sequences, each element has a specific order that
will never change.
Creating of Tuple:
To create a tuple, all the objects (or "elements") must be enclosed in parenthesis (),
each one separated by a comma. Although it is not necessary to include
parentheses, doing so is advised.
46 | P a g e
INTERNET OF THINGS (ADVANCE)
A tuple can contain any number of items, including ones with different data types
(dictionary, string, float, list, etc.).
Code:
3. empty_tuple = ()
5.
9.
13.
Output:
Empty tuple: ()
47 | P a g e
INTERNET OF THINGS (ADVANCE)
Tuples can be constructed without using parentheses. This is known as triple packing.
Code
2. # Creating a tuple
5. print(tuple_)
7. print(type(tuple_) )
9. try:
11. except:
12. print(TypeError )
Output:
<class 'tuple'>
<class 'TypeError'>
48 | P a g e
INTERNET OF THINGS (ADVANCE)
Python Dictionary
An effective data structure for storing data in Python is dictionaries, in which can
simulate the real-life data arrangement where some specific value exists for some
particular key.
In other words, we can say that a dictionary is the collection of key-value pairs where
the value can be of any Python object. In contrast, the keys are the immutable Python
object, i.e., Numbers, string, or tuple. Dictionary entries are ordered as of Python
version 3.7. In Python 3.6 and before, dictionaries are generally unordered.
The simplest approach to create a Python dictionary is by using curly brackets {}, but
there are other methods as well. The dictionary can be created by using multiple key-
value pairs enclosed with the curly brackets {}, and each key is separated from its
value by the colon (:). The syntax to define the dictionary is given below.
49 | P a g e
INTERNET OF THINGS (ADVANCE)
Syntax:
In the above dictionary Dict, The keys Name and Age are the strings which comes
under the category of an immutable object.
Code
2. print(type(Employee))
4. print(Employee)
Output
<class 'dict'>
Python provides the built-in function dict() method which is also used to create the
dictionary.
Code
2. Dict = {}
4. print(Dict)
5.
50 | P a g e
INTERNET OF THINGS (ADVANCE)
6. # Creating a Dictionary
10. print(Dict)
11.
16. print(Dict)
Output
Empty Dictionary:
{}
We've discussed about using indexing to access data stored in lists and tuples.
However, because the dictionary's keys are distinct from one another, it is possible to
51 | P a g e
INTERNET OF THINGS (ADVANCE)
get the values by utilising the keys. The dictionary values can be accessed in the
following way.
Code
2. print(type(Employee))
Output
<class 'dict'>
Name : David
Age : 30
Salary : 55000
Company : GOOGLE
Python - Arrays
Array is a container which can hold a fix number of items and these items should be
of the same type. Most of the data structures make use of arrays to implement their
algorithms. Following are the important terms to understand the concept of Array.
52 | P a g e
INTERNET OF THINGS (ADVANCE)
Array Representation
As per the above illustration, following are the important points to be considered.
• Each element can be accessed via its index. For example, we can fetch
an element at index 6 as 9.
Basic Operations
53 | P a g e
INTERNET OF THINGS (ADVANCE)
Array is created in Python by importing array module to the python program. Then the
array is declared as shown eblow.
Typecode are the codes that are used to define the type of value the array will hold.
Some common typecodes used are:
Typecode Value
Before lookign at various array operations lets create and print an array using python.
54 | P a g e
INTERNET OF THINGS (ADVANCE)
for x in array1:
print(x)
When we compile and execute the above program, it produces the following result −
Output
10
20
30
40
50
We can access each element of an array using the index of the element. The below
code shows how
print (array1[0])
55 | P a g e
INTERNET OF THINGS (ADVANCE)
print (array1[2])
When we compile and execute the above program, it produces the following result −
which shows the element is inserted at index position 1.
Output
10
30
Insertion Operation
Insert operation is to insert one or more data elements into an array. Based on the
requirement, a new element can be added at the beginning, end, or any given index
of array.
Here, we add a data element at the middle of the array using the python in-built insert()
method.
array1.insert(1,60)
for x in array1:
print(x)
56 | P a g e
INTERNET OF THINGS (ADVANCE)
When we compile and execute the above program, it produces the following result
which shows the element is inserted at index position 1.
Output
10
60
20
30
40
50
Deletion Operation
Deletion refers to removing an existing element from the array and re-organizing all
elements of an array.
Here, we remove a data element at the middle of the array using the python in-built
remove() method.
array1.remove(40)
for x in array1:
57 | P a g e
INTERNET OF THINGS (ADVANCE)
print(x)
When we compile and execute the above program, it produces the following result
which shows the element is removed form the array.
Output
10
20
30
50
Search Operation
You can perform a search for an array element based on its value or its index.
Here, we search a data element using the python in-built index() method.
print (array1.index(40))
When we compile and execute the above program, it produces the following result
which shows the index of the element. If the value is not present in the array then th
eprogram returns an error.
Output
Update Operation
58 | P a g e
INTERNET OF THINGS (ADVANCE)
Update operation refers to updating an existing element from the array at a given
index.
Here, we simply reassign a new value to the desired index we want to update.
array1[2] = 80
for x in array1:
print(x)
When we compile and execute the above program, it produces the following result
which shows the new value at the index position 2.
Output
10
20
80
40
50
Multidimensional arrays
59 | P a g e
INTERNET OF THINGS (ADVANCE)
Previous Page
Next Page
Two dimensional array is an array within an array. It is an array of arrays. In this type
of array the position of an data element is referred by two indices instead of one. So
it represents a table with rows an dcolumns of data.
In the below example of a two dimensional array, observer that each array element
itself is also an array.
Consider the example of recording temperatures 4 times a day, every day. Some
times the recording instrument may be faulty and we fail to record data. Such data for
4 days can be presented as a two dimensional array as below.
Day 1 - 11 12 5 2
Day 2 - 15 6 10
Day 3 - 10 8 12 5
Day 4 - 12 15 8 6
Accessing Values
The data elements in two dimesnional arrays can be accessed using two indices. One
index referring to the main or parent array and another index referring to the position
of the data element in the inner array.If we mention only one index then the entire
inner array is printed for that index position.
Example
60 | P a g e
INTERNET OF THINGS (ADVANCE)
print(T[0])
print(T[1][2])
Output
[11, 12, 5, 2]
10
To print out the entire two dimensional array we can use python for loop as shown
below. We use end of line to print out the values in different rows.
61 | P a g e
INTERNET OF THINGS (ADVANCE)
The next sections will clear the doubts on conditional statements in Python. We will
start our learnings on conditional statements with the most used conditional
statement not only in Python but in any language i.e. the if statement.
The simplest and most used conditional statement in Python is the "if " statement. A
lot of the times, you have to decide whether to do "A " or do "B ". The "if
" statement, as its name suggests evaluates the expression. Moreover, it executes
the conditional block only when the statement is true. You can remember the
statement as:
if (something is True)
So, for example, I have a variable age whose value is 40. Then, with the given
below code, the print statement will be executed only if the age is 40.
age = 40
62 | P a g e
INTERNET OF THINGS (ADVANCE)
if(age == 40):
To refresh your memories, recall that Python does not use braces to represent the
code blocks and uses colon instead. All the code intended to be inside the
conditional statement should b indented properly and in alignment. Misalignment of
even one space can lead to exceptions and errors.
Great! This was what we expected. Now the next step is, what if the condition turns
out to be False and we then want to print something *(or anything else)? *This
comes out as the "else " conditional statement in Python.
Else conditional statement is a simple response to the "if " conditional statement
such as if this does not happen what else would? Therefore, whenever the "if
" statement returns False and conditional block from "if " skips, the conditional
block from "else " executes.
Continuing from the previous example, now my age is 35 and I have an "if
" statement which prints the age. If my age is 40, it will print otherwise another print
statement will execute, telling that my age is not 40.
age = 35
if(age == 40):
else:
63 | P a g e
INTERNET OF THINGS (ADVANCE)
Alright! We now know how to execute some code based on certain conditions. In
other words, if the condition is true (execute if block) otherwise execute else block if
the condition is false. But there is one more use case in the conditional statements.
What if we want to put up one more check once the "if " condition fails and not
execute the else statement directly?
Elif is a rather unique term as other programming languages don’t use it. Other
programming languages use "else if " to put up one more condition. While Python
combines "else and if " and makes it an "elif " conditional statement. The usage of
the "elif " statement will get more clear through the following given code.
Continuing on the same example, we will try to put up one more check in case
the "if " conditional statement fails. Guess the output for the following code:
age = 35
if(age == 40):
elif(age == 35):
print("Age is 35")
64 | P a g e
INTERNET OF THINGS (ADVANCE)
Since the indentation in Python is similar to the "{ " in other programming
languages, we can skip the indentation if there is only a single statement that we
have to execute. The same practice we follow in other languages too! So, writing
the "if " statement as follows:
if(condition):
In addition to this, you can also combine various "if-elif-else " statements giving
rise to a cascading conditional block which we will discuss in the next section.
65 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 2
PYTHON ADVANCE
LECTURE 1
LOOPS IN PYTHON
What is loop?
Loops help to execute a sequence of instructions until a condition is satisfied.
✓ For loops
✓ While loops
while condition:
Here,
1|Page
INTERNET OF THINGS (ADVANCE)
Example
Output
2|Page
INTERNET OF THINGS (ADVANCE)
Steps of execution
i=1
True 1 is printed. i is increased to 2.
n=5
i=2
True 2 is printed. i is increased to 3.
n=5
i=3
True 3 is printed. i is increased to 4.
n=5
i=4
True 4 is printed. i is increased to 5.
n=5
i=5
True 5 is printed. i is increased to 6.
n=5
i=6
False The loop is terminated.
n=5
A while loop might not even execute once if the condition is not met.
Infinite Loops
Infinite loops are the ones where the condition is always true.
3|Page
INTERNET OF THINGS (ADVANCE)
The above code is an example of an infinite loop. There is no command to alter the
value of x, so the condition "x is greater than or equal to 1" is always true. This will
make the loop run forever.
Do-While Loop
There are two variations of the while loop – while and do-While. The difference
between the two is that do-while runs at least once.
A while loop might not even execute once if the condition is not met. However, do-
while will run once, then check the condition for subsequent loops.
Python does not have a native do-while statement. But you can easily emulate a do-
while loop using other approaches, such as functions.
4|Page
INTERNET OF THINGS (ADVANCE)
The above code runs the "run_commands()" function once before invoking the while
loop. Once the while loop starts, the "run_commands" function will never be executed
since x is equal to 20.
5|Page
INTERNET OF THINGS (ADVANCE)
UNIT 2
PYTHON ADVANCE
LECTURE 2
The execution of the program in python loops can be controlled using different
functions. The most common loop control functions are
• A break statement breaks the python loop flow regardless of the loop's natural
completion.
• In simple words, a break statement can terminate the current iteration and exit
the loop. Once a break statement is met, the loop cannot continue.
• The break statement can be written by the word "break" anywhere inside the
Python program.
A simple example of a python break statement is to iterate the word "ToolsQA" and
break the loop when we encounter the letter "Q."
for c in "ToolsQA":
if c == "Q":
6|Page
INTERNET OF THINGS (ADVANCE)
break
else:
print(c)
The above loop prints the characters starting from "T" until a “Q” encounter. The above
code uses for loop in Python.
Output:
The output shows that the statement breaks the loop when we encounter a "Q "
7|Page
INTERNET OF THINGS (ADVANCE)
• The Python continue statement skips the current iteration and lets the loop
execute or "continue" naturally.
• If the "continue" conditions meet, the loop is executed only before the continue
statement.
• All the statements after "continue" get skipped, and the next iteration follows.
• The continue statement can be written by the word "continue" inside the Python
loop. A "continue" statement can be put anywhere inside a loop but only with
caution as it affects a loop's flow.
The following example iterates over the word "ToolsQA" and implements a continue
statement when the character "Q " is iterating.
for c in "ToolsQA":
if c == "Q":
continue
else:
print(c)
Output:
8|Page
INTERNET OF THINGS (ADVANCE)
In the above program, the iteration skips as soon as we find the character "Q." But,
unlike the break statement, the loop continues naturally until all the characters of
"ToolsQA" don't iterate.
9|Page
INTERNET OF THINGS (ADVANCE)
• Python pass statement is an empty check which does not interrupt the normal
flow of the loop.
• Python pass statements are constructive when a developer wants to keep the
code as it is and write the logic afterwards.
• Instead, they can write "pass" in place of that logic to check the program's
execution without the code.
In the below example, we have a pass statement that denotes a piece of code that
will be implemented later.
for c in "ToolsQA":
if c == "Q":
pass
else:
print(c)
Output:
The above Python code uses the "pass" statement whenever we encounter a "***Q
***." The result: Python compiler does nothing and lets the loop continue. However,
the pass statement in Python is different from the continue statement as in the pass
10 | P a g e
INTERNET OF THINGS (ADVANCE)
statement; the loop will execute all the code after "pass," whereas, in the continue
statement, we skip the code.
11 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 2
PYTHON ADVANCE
LECTURE 3
PYTHON OOPS
➢ Python also provides an easy way to create and make use of classes and
objects.
1) Identity:
Some information that can help identify the class's object can be termed as
Identity. For example, an employee's Identity is his /her name, the company Id
and many more.
2) Properties:
Properties are said to the attributes of that object. For example, these attributes
can be the gender, age, Date of Birth for an employee, or the type of processor,
size of RAM and ROM for a smartphone and many more.
3) Behavior:
12 | P a g e
INTERNET OF THINGS (ADVANCE)
The functions that an object can perform are said to its behavior. Object-
Oriented Programming makes the assignment of the functions to class objects
possible. For example, the smartphone can provide high performance and
better picture quality and many more.
➢ This concept is also called DRY (abbreviated for Don't Repeat Yourself).
OOP allows you to encapsulate related data and methods within objects, hiding
internal details and providing a clear interface. This abstraction helps to manage
complexity, improves code organization, and enhances security by preventing direct
access to sensitive data.
Inheritance is a powerful feature in OOP that allows you to create new classes by
inheriting properties and behaviors from existing classes. This promotes code reuse
and saves development time.
OOP's modular and encapsulated structure makes it easier to locate and fix bugs or
make updates. Changes can be isolated to specific objects or classes, reducing the
impact on the rest of the codebase.
OOP allows you to scale your codebase by adding new objects and classes as your
program grows. This makes it easier to manage large and complex projects and
provides a foundation for building robust and scalable applications.
14 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 2
PYTHON ADVANCE
LECTURE 4
CLASS
class ClassName:
<statement_1>
<statement_2>
<statement_N>
In the above syntax, we have used the keyword class to define a class ClassName.
For example –
15 | P a g e
INTERNET OF THINGS (ADVANCE)
Based on these descriptions and specifications, we can study the cellphone. Here, a
cellphone is an object.
class Cellphone:
pass
OBJECT
➢ An instantiation of a class is known as an Object or Instance of that class.
➢ The class contains the description of the object.
obj = Cellphone()
Suppose we have information about cellphones. Now, we are building the class and
objects of Cellphone.
class Cellphone:
# class attribute
cellphone_type = "Smartphone"
# instance attribute
16 | P a g e
INTERNET OF THINGS (ADVANCE)
self.model_name = model_name
self.price = price
Output:
Explanation:
In the above program, we have defined a class with the name Cellphone. Then, we
defined the attributes. These attributes are the characteristics of the object.
We have defined these attributes inside the __init__ method of the class. It acts as an
initializer for executing the code as soon as the object is defined.
17 | P a g e
INTERNET OF THINGS (ADVANCE)
Then, we have created instances of the Cellphone class. Here, phone_1 and phone_2
are values (or references) to our new objects.
The class attribute can be accessed using __class__.species. The Class attributes
act similarly for every instance of a class. The instance attributes can be accessed in
the same way, using phone_1.model_name and phone_1.price. However, they are
different for every class’s instance.
18 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 2
PYTHON ADVANCE
LECTURE 5
INHERITANCE
# parent class
class Cellphone:
def __init__(self):
print("This is a Cellphone")
def who(self):
print("Cellphone")
def performance(self):
print("High performance")
# child class
class iPhone(Cellphone):
def __init__(self):
19 | P a g e
INTERNET OF THINGS (ADVANCE)
super().__init__()
def who(self):
def refreshrate(self):
phone = iPhone()
phone.who()
phone.performance()
phone.refreshrate()
Output:
This is a Cellphone
High performance
In the above program, we have defined two classes, i.e., Cellphone (parent class) and
iPhone (child class). The functions of the parent class are inherited from the child
class. It can be seen from the performance () method.
We have used the super() function inside the __init__() method. This function helps
the users execute the parent class __init__() method inside the child class.
20 | P a g e
INTERNET OF THINGS (ADVANCE)
CONSTRUCTOR
A constructor is defined as the special kind of function or method that is used for
instance variables initialization during the creation of an object of a class.
Creating a constructor:
The __init__ method or function is used for creating a constructor of the class and it
is also used when an object is created.
Any number of arguments can be passed at the time of creating an object of a class,
once the __init__() function is defined.
Each class is required to have a constructor, still if it just relies on the default
constructor.
Syntax:
def __init__(self):
# body
Example:
class DummyClass:
# constructor
def __init__(self):
self.num=200
21 | P a g e
INTERNET OF THINGS (ADVANCE)
# a method
def read_number(self):
print(self.num)
obj = DummyClass()
obj.read_number()
Output:
200
22 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 2
PYTHON ADVANCE
LECTURE 6
STRING
STRING
In computer programming, a string is a sequence of characters. For example, "hello"
is a string containing a sequence of characters 'h', 'e', 'l', 'l', and 'o'.
We use single quotes or double quotes to represent a string in Python. For example,
In Python, strings are immutable sequences of characters, and there are several built-
in methods that allow you to manipulate and work with strings.
1. Replace:
The replace () method replaces all occurrences of a specified substring with another
substring within a string.
For example:
23 | P a g e
INTERNET OF THINGS (ADVANCE)
2. Join:
The join () method concatenates a list of strings into a single string, using the specified
string as a separator.
For example:
3. Split:
The split() method splits a string into a list of substrings based on a specified delimiter.
By default, the delimiter is a whitespace.
For example:
4. Reverse:
Strings don't have an inbuilt reverse method, but you can achieve it using slicing.
For example:
24 | P a g e
INTERNET OF THINGS (ADVANCE)
The upper() method converts a string to uppercase, while the lower() method converts
it to lowercase.
For example:
6. Count:
The count() method returns the number of occurrences of a specified substring within
a string.
For example:
7. Find:
The find() method searches for the first occurrence of a specified substring within a
string and returns its index.
For example:
25 | P a g e
INTERNET OF THINGS (ADVANCE)
8. Length:
The len() function returns the length (the number of characters) of a string.
For example:
26 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 2
PYTHON ADVANCE
LECTURE 7
PYTHON FUNCTION
PYTHON FUNCTION
1. Built-in functions –
➢ These functions are the part of the Python libraries and packages.
➢ These are also called as pre-defined functions.
➢ Python provides a wide range of built-in functions that are readily available for
use.
➢ These functions are part of the Python standard library and cover various
operations, including mathematical computations, string manipulation, file
handling, and more.
27 | P a g e
INTERNET OF THINGS (ADVANCE)
2. User-defined functions –
In this example, the greet() function takes a name parameter and prints a greeting
message using the provided name.
User-defined functions can have return values using the return statement.
28 | P a g e
INTERNET OF THINGS (ADVANCE)
For example:
In this case, the add() function takes two parameters and returns their sum.
Creating a function
The basic steps to create a user-defined function are:
➢ The def keyword is used to define function followed by the function name.
➢ Arguments should be written inside the opening and closing parentheses of the
function, and end the declaration with a colon.
➢ Write the program statements to be executed within the function body.
➢ The return statement is optional. It should be written at the end of the function.
………………
………………
return
29 | P a g e
INTERNET OF THINGS (ADVANCE)
Calling a Function
After declaring a function, it must be called using function name followed by
parentheses with appropriate argument.
Note: It is necessary to define a function before calling; otherwise, it will give an error.
Example-1
def hello():
print('Hello')
hello()
Output:
Hello
Example-2
def sum(a,b):
c=a+b
return c
z=sum(10,20)
30 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 2
PYTHON ADVANCE
LECTURE 8
LAMBDA FUNCTION
A lambda function can have any number of parameters, but the function
body can only contain one expression. Moreover, a lambda is written in a
single line of code and can also be invoked immediately.
Here, p1 and p2 are the parameters which are passed to the lambda
function. You can add as many or few parameters as you need.
31 | P a g e
INTERNET OF THINGS (ADVANCE)
Example
Now that you know about lambdas let’s try it with an example. So, open
your IDLE and type in the following:
adder = lambda x, y: x + y
32 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 3
CLOUD FEATURES
LECTURE 1
CLOUD COMPUTING AND IoT CLOUD
The term “Cloud” came from a network design that was used by network
engineers to represent the location of various network devices and their
inter-connection. The shape of this network design was like a cloud.
1|Page
INTERNET OF THINGS (ADVANCE)
Examples of IoT cloud platforms: AWS IoT Core, Microsoft Azure IoT
Hub, Google Cloud IoT Core, and IBM Watson IoT Platform.
2|Page
INTERNET OF THINGS (ADVANCE)
➢ Fast and flexible means you can expand storage space, edit software
settings, and work with the number of users.
➢ Cloud Computing means the pooling of resources.
➢ As the number of IoT devices and automation in use grows, security
concerns emerge. Cloud solutions provide companies with reliable
authentication and encryption protocols.
3|Page
INTERNET OF THINGS (ADVANCE)
UNIT 3
CLOUD FEATURES
LECTURE 2
TYPES OF CLOUDS
TYPES OF CLOUDS
Public Cloud
4|Page
INTERNET OF THINGS (ADVANCE)
1. High Scalability
2. Cost Reduction
3. Reliability and flexibility
4. Disaster Recovery
Private cloud
5|Page
INTERNET OF THINGS (ADVANCE)
6|Page
INTERNET OF THINGS (ADVANCE)
Hybrid cloud
Community cloud:
4. Public cloud is less secure than the community cloud, which is more
secure than private cloud.
9|Page
INTERNET OF THINGS (ADVANCE)
UNIT 3
CLOUD FEATURES
LECTURE 3
I. Ready-to-use applications:
SaaS provides fully functional software applications over the internet,
eliminating the need for users to install, configure, or maintain the
software on their devices.
II. Accessibility:
Users can access SaaS applications through web browsers, making
them accessible from any device with an internet connection.
III. Automatic updates:
The service provider handles updates and patches, ensuring that
users are always using the latest version of the software.
IV. Scalability:
10 | P a g e
INTERNET OF THINGS (ADVANCE)
Advantages of SaaS
Disadvantages of SaaS
➢ Low performance.
➢ It has limited customization options.
➢ It has security and data concerns.
I. Development environment:
11 | P a g e
INTERNET OF THINGS (ADVANCE)
Advantages of PaaS
➢ It is quite affordable.
➢ It manages application development phases in the cloud very
efficiently.
Disadvantages of PaaS
I. Virtualized infrastructure:
IaaS provides virtualized computing resources over the internet,
including virtual machines, storage, and networking.
II. Flexibility and control:
Users have full control over the virtualized infrastructure, allowing
them to customize the environment according to their requirements.
III. Resource management:
Users can easily scale resources up or down based on demand,
paying only for the resources they consume.
IV. Rapid provisioning:
IaaS platforms can quickly provision new virtual machines and
resources, reducing deployment time for applications.
Advantages of IaaS
13 | P a g e
INTERNET OF THINGS (ADVANCE)
Disadvantages of IaaS
15 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 3
CLOUD FEATURES
LECTURE 4
CLOUD CONNECTIVITY AND DATA STORAGE
o The customer can neither format, nor install his own file system or
change drive properties.
16 | P a g e
INTERNET OF THINGS (ADVANCE)
➢ If one system fails, then it is required only to change the pointer to the
location, where the object is stored.
➢ To aggregate the storage assets into cloud storage systems, the cloud
provider can use storage virtualization software known
as StorageGRID.
The following diagram shows how StorageGRID virtualizes the storage into
storage clouds:
17 | P a g e
INTERNET OF THINGS (ADVANCE)
➢ Cost effectiveness
➢ Increased agility
➢ Faster deployment
➢ Efficient data management
➢ Virtually unlimited scalability
➢ Business continuity
18 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 3
CLOUD FEATURES
LECTURE 5
ARDUINO ARCHITECTURE, PROGRAMING AND APPLICATION
Arduino Architecture:
19 | P a g e
INTERNET OF THINGS (ADVANCE)
Arduino Uno consists of 14 digital input/output pins (of which 6 can be used
as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB
connection, a power jack, an ICSP (In-circuit serial programming) header,
and a reset button.
a) Power Jack:
Arduino can be power either from the pc through a USB or through
external source like adaptor or a battery. It can operate on a external
supply of 7 to 12V.
b) Digital Inputs:
It consists of 14 digital inputs/output pins, each of which provide or
take up 40mA current. Some of them have special functions like pins
0 and 1, which act as Rx and Tx respectively, (The TX pin sends out
(transmits) the digital signal, and the RX pin listens (receives) for a
digital signal.) for serial communication.
c) Analog inputs:
It has 6 analog input/output pins, each providing a resolution of 10
bits.
d) ARef:
It provides reference to the analog inputs
e) Reset:
It resets the microcontroller when low.
Arduino Programming
20 | P a g e
INTERNET OF THINGS (ADVANCE)
1. Declaration of Variables
21 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 3
CLOUD FEATURES
LECTURE 6
RASPBERRY PI
22 | P a g e
INTERNET OF THINGS (ADVANCE)
Raspberry Pi Architecture
1. Memory
The Central processing unit is the brain of the raspberry pi board and
that is responsible for carrying out the instructions of the computer
through logical and mathematical operations.
4. Ethernet Port
5. GPIO Pins
The general-purpose input & output pins are used in the raspberry pi to
associate with the other electronic boards. These pins can accept input
& output commands based on programming raspberry pi. The raspberry
pi affords digital GPIO pins. These pins are used to connect other
electronic components. For example, you can connect it to the
temperature sensor to transmit digital data.
6. XBee Socket
The power source cable is a small switch, which is placed on side of the
shield. The main purpose of the power source connector is to enable an
external power source.
8. UART
9. Display
The connection options of the raspberry pi board are two types such as
HDMI and Composite. Many LCD and HD TV monitors can be attached
using an HDMI male cable and with a low-cost adaptor. The versions of
HDMI are 1.3 and 1.4 are supported and 1.4 version cable is
recommended.
1. Desktop PC
3. Media Usage
4. Game Servers
6. Robot Controller
8. Time-lapse Camera
9. FM Radio Station
UNIT 4
LECTURE 1
Network
✓ A computer network is a collection of two or more computer systems
that are linked together.
✓ A network connection can be established using either cable or
wireless media.
✓ Hardware and software are used to connect computers and devices
in any network.
Networks
Wired Wireless
a) Wired Network:
▪ The term “wired” refers to any physical medium made up of cables.
▪ Copper wire, twisted pair, or fibre optic cables are all options.
▪ A wired network employs wires to link devices to the Internet or
another network, such as laptops or desktop PCs.
▪ They are sometimes also called bound media.
1|Page
INTERNET OF THINGS (ADVANCE)
Wired Networks
Coaxial Fibre Optic
Twisted Pair Cable
Cable Cable
There are three common types of wired media in the data transmission.
They are
• Twisted-Pair Cable,
• Fibre-Optic Cable.
2|Page
INTERNET OF THINGS (ADVANCE)
Advantages
Disadvantages
3|Page
INTERNET OF THINGS (ADVANCE)
Advantages
• It eliminates crosstalk.
Disadvantages
• It is difficult to manufacture
Coaxial Cable
4|Page
INTERNET OF THINGS (ADVANCE)
Advantages
• They can span to longer distance at higher speeds as they have better
shielding when compared to twisted pair cable
Disadvantages
5|Page
INTERNET OF THINGS (ADVANCE)
Advantages
• It is resistant to corrosion.
Disadvantages
6|Page
INTERNET OF THINGS (ADVANCE)
UNIT 4
LECTURE 2
b. Wireless Network
➢ “Wireless” means without wire, media that is made up of
electromagnetic waves (EM Waves) or infrared waves.
➢ Antennas or sensors will be present on all wireless devices.
➢ Cellular phones, wireless sensors, TV remotes, satellite disc
receivers, and laptops with WLAN cards are all examples of wireless
devices.
➢ For data or voice communication, a wireless network uses
radiofrequency waves rather than wires.
Wireless Network
Ultra
Bluetooth Infrared WiFi ZigBee Wide
Band
7|Page
INTERNET OF THINGS (ADVANCE)
1. Bluetooth
2. Infrared
3. Wi-Fi
9|Page
INTERNET OF THINGS (ADVANCE)
4. ZigBee
11 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 4
LECTURE 3
M2M (Machine-to-Machine)
Application
12 | P a g e
INTERNET OF THINGS (ADVANCE)
appropriate banks and accounts. The bank returns approval codes via
the host computer, allowing transactions to proceed.
a. wired communication
b. wireless communication.
13 | P a g e
INTERNET OF THINGS (ADVANCE)
o NFC is similar to RFID, but it can only be used for short-range data
transfer.
o NFC technology is used to transfer data in payment applications such
as Apple Pay and contactless credit cards.
4. Cellular networks
14 | P a g e
INTERNET OF THINGS (ADVANCE)
15 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 4
IoT NETWORKING AND APPLICATION
LECTURE 4
1. 2G (Second Generation):
2. 3G (Third Generation):
16 | P a g e
INTERNET OF THINGS (ADVANCE)
3. 4G (Fourth Generation):
4. 5G (Fifth Generation):
17 | P a g e
INTERNET OF THINGS (ADVANCE)
18 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 4
LECTURE 5
Low Power Wide Area Network (LPWAN)
Low power wide area networks (LPWAN) are a type of wireless network
designed for long-range communication in a quiet bandwidth environment.
LPWANs can collect data from sensors or meters in remote areas where
traditional cellular networks are not available or costly.
a. Low power:
IoT sensors and devices must transfer data regularly so the battery life of
these devices must be extended as much as possible.
Types of LPWANs
a. Sigfox
Today, one of the most widely deployed LPWANs is the proprietary,
unlicensed Sigfox. The ultra-narrowband technology operates over a
public network in the 868 MHz or 902 MHz bands and is limited to a
single operator per country.
19 | P a g e
INTERNET OF THINGS (ADVANCE)
b. LoRaWAN
The LoRa Alliance-specified and backed unlicensed LoRa transmits
at several sub-gigahertz frequencies, making it less susceptible to
interference. A LoRaWAN network server enhances internet
bandwidth and power consumption.
c. RPMA
Random phase multiple access, RPMA, is an Ingenu Inc. proprietary
LPWAN. Despite its shorter range, it provides better bidirectional
communication than Sigfox.
d. NB-IOT
NB-IoT is a wireless broadband technology for Internet of Things (IoT)
applications. It operates in the license-free sub 1 GHz spectrum with
a bandwidth of 200 kHz and has a latency of 10 ms or less.
e. LTE-M
LTE-M is an evolution of LTE for low power, low data rate machine-to-
machine communications in license-free spectrum bands. It provides
high throughput with ultra-low latency and long battery life,
Advantages of LPWAN
20 | P a g e
INTERNET OF THINGS (ADVANCE)
➢ Low Power Wide Area Network (LPWAN) has a Data rate of 624kbps
for uplink and 156kbps for downlink.
➢ It provides a low-power solution for IoT devices that need to be
connected.
Disadvantages of LPWAN
➢ LPWAN only supports low data rates, so it cannot be used for high
data rate applications.
➢ It has a high latency between end nodes. As a result, LPWAN is not
suitable for low latency applications.
21 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 4
LECTURE 6
SigFox, LoRaWAN
▪ SigFox, LoRaWAN are the examples of LPWAN technology.
▪ Both LoRaWAN and SigFox implements wireless data integration for
the long range, low power division.
▪ However, LoRaWAN and SigFox are different technologies.
1. SigFox :
2. LoRaWAN :
Narrowband IoT
➢ Narrowband Internet of Things (NB-IoT) is a low-power, wide-area
network (LPWAN) technology designed to enable efficient
communication for a large number of Internet of Things (IoT) devices.
➢ It is a part of the 3GPP (3rd Generation Partnership Project) standard
and is specifically designed to address the needs of IoT applications
that require long battery life, extended coverage, and low data rates.
23 | P a g e
INTERNET OF THINGS (ADVANCE)
I. Smart Metering:
Tracking and managing the location and status of valuable assets, such
as containers, vehicles, and equipment.
25 | P a g e
INTERNET OF THINGS (ADVANCE)
V. Industrial IoT:
26 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 4
LECTURE 7
RFID (Radio Frequency IDentification)
➢ Radio Frequency IDentification is commonly known as RFID.
➢ The objective of RFID is to track and identify objects or products
through tags.
➢ The RFID are in the form of a small chip that can receive and transmit
information through electromagnetic fields.
➢ RFIDs are frequently used for all sorts of products, from
pharmaceuticals to warehouses, clothing, and accessories to
transportation and logistics.
1) Active Tags:
The Active Tags run on their own battery, and transmit their own ID
signal.
28 | P a g e
INTERNET OF THINGS (ADVANCE)
2) Passive Tags:
The Passive Tags are small in size, have no batteries of their own, and
instead uses the Reader’s energy source.
29 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 4
LECTURE 8
Components of RFID Systems
RFID is a technology that uses radio waves to wirelessly identify and track
objects.
30 | P a g e
INTERNET OF THINGS (ADVANCE)
• RFID readers are devices that generate radio signals to activate RFID
tags within their range and then receive and interpret the data from
the tags.
• Readers can be fixed or handheld, and they come with different
communication interfaces to connect with other systems.
d) Connectors:
• Connectors are used to establish connections between the RFID
reader and other equipment, such as antennas or controllers.
e) Cables:
• Cables are necessary to link the various components of the RFID
system, such as connecting antennas to readers.
f) Encoder/Printers for Smart Labels:
• To create RFID smart labels, which are adhesive labels with
embedded RFID tags, specialized devices called encoder/printers are
used.
• These devices can program data into the RFID tags and print human-
readable information on the label surface.
g) Controllers:
• RFID controllers manage the communication between the readers
and the software.
• They help coordinate the flow of data and manage multiple readers
within a larger RFID system.
h) Software:
31 | P a g e
INTERNET OF THINGS (ADVANCE)
Barcodes:
RFID:
RFID is a technology that uses radio waves to wirelessly identify and track
objects.
32 | P a g e
INTERNET OF THINGS (ADVANCE)
RFID does not require line-of-sight scanning like barcodes. RFID tags
can be read from a distance, and multiple tags can be read
simultaneously.
b) Data Capacity:
RFID tags can store more data than barcodes. Some RFID tags can hold
kilobytes of information but barcodes typically store limited information.
c) Durability:
RFID tags are more durable and robust than barcodes. They can
withstand harsh environmental conditions, such as extreme
temperatures, moisture, and chemicals, without affecting their
readability. Barcodes, on the other hand, may become damaged due to
wear and tear.
e) Readability in Bulk:
f) Versatility:
33 | P a g e
INTERNET OF THINGS (ADVANCE)
RFID can seamlessly integrate with the Internet of Things (IoT), enabling
real-time data communication and interaction between physical objects
and digital systems but bar codes have no such features.
34 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 5
IoT APP DEVELOPMENT
LECTURE 1
FRAMEWORK SELECTION FOR IoT APP DEVELOPMENT
Device Compatibility
Communication Protocols
Scalability and Performance
APP DEVELOPMENT
SELECTION FOR IoT
Security Features
FRAMEWORK
Data Management
Ease of Integration
Developer-Friendly
Real-Time Capabilities
Industry Adoption
1. Device Compatibility:
1|Page
INTERNET OF THINGS (ADVANCE)
Check if the framework supports the types of IoT devices and platforms
you plan to use in your project. It should be compatible with a wide range
of devices, sensors, and actuators to accommodate the diverse IoT
ecosystem.
2. Communication Protocols:
4. Security Features:
5. Data Management:
6. Ease of Integration:
7. Developer-Friendly:
2|Page
INTERNET OF THINGS (ADVANCE)
8. Real-Time Capabilities:
Some applications require processing data at the edge (on the IoT
devices themselves). So, look for frameworks that support edge
computing capabilities. This can reduce data transmission and latency,
improving overall system performance.
Consider the popularity and adoption of the framework within the IoT
development community. A widely used framework is more likely to have
better support, frequent updates, and a larger pool of resources.
3|Page
INTERNET OF THINGS (ADVANCE)
1. IoTivity:
➢ IoTivity is an open-source framework developed by the Open
Connectivity Foundation (OCF).
➢ It provides a standardized approach to IoT device connectivity and
communication.
➢ IoTivity supports various transport protocols such as MQTT
(Message Queuing Telemetry Transport) and HTTP (Hypertext
Transfer Protocol), making it suitable for different types of IoT
devices and platforms.
➢ It emphasizes interoperability and security, making it suitable for
large-scale IoT deployments.
2. Node-RED:
4|Page
INTERNET OF THINGS (ADVANCE)
6|Page
INTERNET OF THINGS (ADVANCE)
UNIT 5
IoT APP DEVELOPMENT
LECTURE 2
DEVELOPMENT OF AN IoT APPLICATION
7|Page
INTERNET OF THINGS (ADVANCE)
o Dashboarding
o Device to Mobile Communication
o Over-the-air updates
o Metadata management
o Data visualization
➢ There are several network protocols that you can use like WiFi, 2G,
5G, Bluetooth, LoRa, NB-IoT, or Zigbee.
➢ Depending on the devices used and the availability of resources, one
needs to pick the right channels for connectivity.
➢ For example: If devices are usually used in a home or office
environment, one can use WiFi for data transmission. Whereas if your
devices are going to be in motion or in remote locations, one may use
GSM.
➢ Firmware are the technical terms for the program that runs your
hardware.
8|Page
INTERNET OF THINGS (ADVANCE)
➢ The right IoT platform will provide the necessary tools to create an
application that serves the purpose.
➢ In order to choose an IoT cloud platform, the following factors needs
to be considered:
o Uptime
o Data security
o Debugging
o Feature stability
o Security
o Migration capabilities
o Connectivity, and
o Scalability
10 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 5
IoT APP DEVELOPMENT
LECTURE 3
IMPLEMENT AND DEPLOY THE APPLICATION IN IoT
Clearly define the purpose and goals of your IoT application. Identify the
devices and sensors you'll use, the data to be collected, and the actions
app will perform based on that data.
Choose a suitable IoT platform or framework that aligns with the project
requirements and provides the necessary tools for developing and
managing IoT devices and data.
Set up and connect IoT devices, sensors, and actuators to the selected
platform. This may involve programming and configuring the devices to
communicate with the platform using the supported protocols.
Create the backend infrastructure for the IoT app. This includes setting
up servers, databases, and cloud services to store and manage data
received from IoT devices.
11 | P a g e
INTERNET OF THINGS (ADVANCE)
Create the user interface (UI) for the IoT app. This can be a web
application, a mobile app, or both, depending on your target audience
and use cases.
Add data processing and analytics capabilities to the IoT app backend.
This may involve real-time data processing and generating action from
the collected data.
8. Security Measures:
9. Deployment:
Once the app is thoroughly tested and deemed ready for deployment,
prepare it for release. Deploy the backend services on the chosen
hosting infrastructure or cloud platform and make the frontend
accessible to users.
12 | P a g e
INTERNET OF THINGS (ADVANCE)
update the app to add new features, fix bugs, and enhance security as
needed.
13 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 5
IoT APP DEVELOPMENT
LECTURE 4
Testing and integration are crucial stages in the development of an IoT app
to ensure that the application works seamlessly with IoT devices and
services.
The steps involved in testing and integration of an IoT app are as follows:
➢ Unit Testing:
• Perform unit testing on individual components of the IoT app,
including backend services, APIs, and frontend modules.
• This ensures that each unit functions correctly and as expected
in isolation.
➢ Integration Testing:
• Test the integration between different components of the IoT app.
• Verify that the frontend can communicate with the backend, and
data flows correctly between the app and IoT devices.
➢ Device Integration Testing:
• Integrate real IoT devices into the app and test their connectivity,
data transmission, and functionality.
• Ensure that the app can communicate effectively with these
devices and interpret the data received correctly.
➢ Communication Protocol Testing:
14 | P a g e
INTERNET OF THINGS (ADVANCE)
15 | P a g e
INTERNET OF THINGS (ADVANCE)
16 | P a g e
INTERNET OF THINGS (ADVANCE)
UNIT 5
IoT APP DEVELOPMENT
LECTURE 5
Steps to effectively maintain and improve the IoT app based on feedback
are as follows:
4. Iterative Development:
5. Bug Fixing:
Take user feedback into account while improving the app's UI and UX.
Make the app more user-friendly.
7. Performance Optimization:
8. Security Updates:
Stay alert about security threats and address any reported security
issues quickly.
18 | P a g e