Вы находитесь на странице: 1из 56

Training Report

on
INTERNET OF THINGS
(IOT)
Submitted in partial fulfillment of the requirements
for the award of the degree of

BACHELOR OF TECHNOLOGY
in
ELECTRONICS AND COMMUNICATION

Submitted By:
Sanyam Jain
2817291
Batch: 2017-2021)

Panipat Institute of Engineering & Technology,


(Affiliated to Kurukshetra University Kurukshetra, India)
Samalkha, Panipat
(2019-2020)

1
CANDIDATE’S DECLARATION

I hereby declare that the work presented in this training report entitled “Internet of
Things (I.O.T)”, submitted in partial fulfillment of the requirement for the award of the
degree of Bachelor of Technology in Electronics and Communication, submitted to
Panipat Institute of Engineering & Technology, Kurukshetra University, Kurukshetra,
India is an authentic record of my own work carried out during the period from 17 June
2019 to 23 July 2019 under the guidance of Mr. Vipul Ror .
The work reported in this project report has not been submitted by me for the award
of any other degree or diploma.

Date: 23 July 2019 Student’s name: Sanyam Jain


Place: Delhi Roll No.: 2817291

2
CERTIFICATE

This is to certify that the summer training report (ECE-315N) entitled “Internet of
Things (I.O.T)” done by Sanyam Jain, Roll No. 2817291 is an authentic work carried out
by him at Sofcon India pvt. ltd. under my guidance. The matter embodied in this
training title/ project work has not been submitted earlier for the award of any degree
or diploma to the best of my knowledge and belief.

Date: 23 July 2019 Company Mentor Name: Mr. Vipul Ror


()

3
Acknowledgement

Working in the Sofcon India Pvt Ltd was interesting. During these six-weeks summer
training, I learnt a lot on Internet of Things, hands-on experience of Arduino ,
Raspberry pi, languages like python, html and php.

I thank Mr. Vipul Ror for guiding me so well during my training.


Therefore I am grateful to the people working in Sofcon for the chance to make this
experiment.

Further on, I want to thank the students and trainees in the Sofcon who made this
demanding time joyful but always efficient.

Sanyam Jain

4
5
List of Figures

Figure 1.1 Figure Name Page no.

Figure 1.2

Figure 1.3

Figure 2.1

Figure 2.2

The figures must be numbered as (chapter number.figure number). Suppose chapter number is 2 and
figure in the chapter 2 is 3 then figure must be numbered as Figure 2.3

6
List of Tables

Table 1.1 Table Name Page no

Table 1.2

Table 2.1

The tables must be numbered as (chapter number.table number). Suppose chapter number is 1 and
table in the chapter 1 is 1 then table must be numbered as Table 1.1

7
List of Graphs

Graph 1.1 Graph Name Page no

Graph 1.2

The graphs should be numbered as (chapter number.graph number). Suppose chapter number is 2 and
graph in the chapter 2 is 3 then graph must be numbered as Graph 2.3

8
Abbreviations

AE Analogy-based Estimation
AHF Attribute Hiding Factor
AIF Attribute Inheritance Factor

List all the abbreviations you have used in the project report/thesis/dissertation etc.

9
CONTENTS (16 PTS.)
Candidate's Declaration i

Certificate ii

Acknowledgement iii

Abstract iv

List of Figures v

List of Tables vi

List of Graphs vii

Abbreviations viii

CHAPTER NO DESCRIPTION PAGE NO.

Chapter 1: INTRODUCTION 1

1.1 1

1.2 4

1.3 6

1.4 8

Chapter 2: 14

How to write references?


10
A. References
The heading of the References section must not be numbered. Please use Regular and Italic styles to
distinguish different fields as shown in the References section. Number the reference items
consecutively in square brackets (e.g. [1]).
When referring to a reference item, please simply use the reference number, as in [2]. Do not use
“Ref. [3]” or “Reference [3]” except at the beginning of a sentence, e.g. “Reference [3] shows …”.
Multiple references are each numbered with separate brackets (e.g. [2], [3], [4]–[6]). Examples of
reference items of different categories shown in the References section include:
• example of a book in [1]
• example of a book in a series in [2]
• example of a journal article in [3]
• example of a conference paper in [4]
• example of a patent in [5]
• example of a website in [6]
• example of a web page in [7]

Examples of REFERENCES
[1] S. M. Metev and V. P. Veiko, Laser Assisted Microtechnology, 2nd ed., R. M. Osgood, Jr., Ed.
Berlin, Germany: Springer-Verlag, 1998.
[2] J. Breckling, Ed., The Analysis of Directional Time Series: Applications to Wind Speed and
Direction, ser. Lecture Notes in Statistics. Berlin, Germany: Springer, 1989, vol. 61.
[3] S. Zhang, C. Zhu, J. K. O. Sin, and P. K. T. Mok, “A novel ultrathin elevated channel low-
temperature poly-Si TFT,” IEEE Electron Device Lett., vol. 20, pp. 569–571, Nov. 1999.
[4] M. Wegmuller, J. P. von der Weid, P. Oberson, and N. Gisin, “High resolution fiber distributed
measurements with coherent OFDR,” in Proc. ECOC’00, 2000, paper 11.3.4, p. 109. [5] R. E.
Sorace, V. S. Reinhardt, and S. A. Vaughn, “High-speed digital-to-RF converter,” U.S. Patent 5
668 842, Sept. 16, 1997.
[6] (2002) The IEEE website. [Online]. Available: http://www.ieee.org/

Guidelines for Training report

The following guidelines must be followed in preparing the training report:

11
Good quality white executive bond paper A4 size should be used for typing and duplication. Care
should be taken to avoid smudging while duplicating the copies.
Page Specification: (Written paper and source code)
Left margin – 1.5"
Right margin – 1"
Top margin – 1"
Bottom margin – 1"

Page numbers - All text pages as well as Program source code listing should be numbered at the
bottom center of the pages.

Normal Body Text: Font Size: 12, Times New Roman, 1½ Spacing, Justified. 6 point above and
below para spacing

Paragraph Heading: Font Size: 14, Times New Roman, Underlined, Left Aligned. 6 point above &
below spacing.

Chapter Heading: Font Size: 16, Times New Roman, Centre Aligned, 12 point above and below
spacing.

Coding (if any): Font size: 10, Courier New, Normal

Binding: Project Report should be typed on one side of the page and binding should be spiral of the
report.

Figures & Graph: Figures and its caption should be center aligned. Figure caption should be of font
size: 12, Times New Roman, 1½ Spacing, 6 point above & below spacing.

Tables: Table content and its caption should be center aligned, font size: 12, Times New Roman;
Caption should have 1½ Spacing, 6 point above & below spacing.

Sequence of pages
First Page
 Candidate declaration certificate should consists of names and roll numbers of student

Second Page
 The Second page should contain a training certificate provided by the company where training
has undergone.

Third Page
 The third page may include the Acknowledgement

Fourth
 The Fourth page should contain an abstract of the Project report. The candidate may
emphasise here his contributions.

12
Fifth, Sixth and Seventh
 In this page, list of figures, list of tables, list of graphs and photographs and notation must be
provided and abbreviations.

Important Note:
 All the above pages are to be numbered in Roman numerals of lower case. Ex. i, ii, iii,
iv,…
 The document/chapter pages must be numbered using numbers i.e. 1, 2, 3……
 All the pages numbered in Roman numerals are to be placed before “Content Page” and
document/chapter pages numbered in natural numbers are to be placed after the
“Content Page”.

13
IntroductIon to the topIc

1.1 What is IOT ?

 IOT is a system where physical devices are connected to each other with sensors
within and these items are in turn connected to the internet via wireless
connection. Internet of things will Connect non-living things with living things-
the vision of IOT is to connect everything starting from industrial equipment to
everyday objects.
 The sorts of things extent from gas turbines to vehicles to utility meters. It can
likewise incorporate living beings, for example, plants, ranch creatures and
individuals. For instance, the Cow Tracking Project in Essex utilizes information
gathered from radio situating labels to screen dairy animals for ailment and
track conduct in the group.
 Fundamentally anything you can connect a sensor and availability to can take an
interest in the new associated biological communities. Use sensors for data
connection- The physical articles that are being associated will have one or more
sensors. Every sensor will screen a particular condition, for example, area,
vibration, movement and temperature.
 In IoT, these sensors will associate with each other and to frameworks that can
comprehend or present data from the sensor's information bolsters. These
sensors will give new data to an organization's frameworks and to individuals.
Before, individuals conveyed with individuals and with machines.
 In very simple words, IOT, most commonly known as internet-of- things, is a
network of devices connected together in order to exchange information. The
devices are embedded with software, sensors and network connectivity which
will help them to collect and exchange data. The whole infrastructure creates an
opportunity for the machines to communicate with each other. The 28 devices
can be anything starting from cellphones, headphones, washing machines or any
electronic devices.

14
Overall, IOT is a giant network of connected devices and the relationship will be
between people-people, people-things and things to things.

1.2 Why IOT is a popular topic ?

 IOT products are aimed at automating our lives. All the lights will be switched of
as soon as you step out of the house, your warehouse will send notifications as
soon it gets short of certain products and what not.
 There are numerous points of interest of joining IoT into our lives, which can
help people, organizations, and society once a day. For people this new idea can
come in numerous structures including wellbeing, security, monetarily, and
consistently arranging.
 The joining of IOT into the human services framework could end up being
inconceivably gainful for both an individual and a general public.
 A chip could be actualized into every person, taking into consideration healing
centers to screen the indispensable indications of the patient. By following their
crucial signs, it could show regardless of whether genuine appraisal is vital.
 With the majority of the data that is accessible on the Internet, it can likewise
unnerve individuals into trusting they require more care than what is truly
required. Healing centers as of now battle to survey and deal with the patients
that they have. By observing individual's wellbeing, it will permit them to judge
who needs essential consideration.
 The Internet of Things can likewise help individuals with their own wellbeing.
ADT, which is a home security framework, permits people to screen their
security frameworks at home through their telephones, with the capacity to
control it. IOT can likewise work as a device that can spare individuals cash inside
their family units. In the event that their home apparatuses can convey, they can
work in a vitality effective way.

 At last, IOT can help individuals with their ordinary arrangements.

15
By permitting physical gadgets to impart, it is taking the information that is
separately gathered, sharing it, and afterward making an interpretation of the
data into approaches to make our present frameworks more productive.

The Smart Home Devices and the Future :

Smart home automation and IoT are creating a lot of buzz in the IT industry.
Daily lives have been made simpler, better, and more comfortable with the
increasing number of smart homes and connected devices.

16
By 2020, it is expected that the global
al smart home market will reach around 40
billion dollars.. Now, these smart home devices range from anything like smart
kettles, refrigerators, and dryers to air conditioners and a range of safety and
security devices, like alarm systems and circuit secur
security cameras.

CLIENT-SEVER
SEVER COMPUTING
COMPUTING:

 A server host runs one or more server programs which share their resources with
clients.

17
 A client does not share any of its resour
resources,
ces, but requests a server's content or
service function. Clients therefore initiate communication sessions with servers
which await incoming requests.
 Examples of computer applications that use the client client–server
server model
are Email, network printing
printing, and the World Wide Web.

AC TO DC VOLTAGE CONVERSION:
(220V TO 5V)

18
If VB >= VE THEN ACTIVE MODE else OFF MODE

19
Python

Python is a popular programming language. It was created by Guido


van Rossum, and released in 1991.

It is used for:

 web development (server-side),


 software development,
 mathematics,
 system scripting.

WHAT CAN PYTHON DO?

 Python can be used on a server to create web applications.


 Python can be used alongside software to create workflows.
 Python can connect to database systems. It can also read and
modify files.
 Python can be used to handle big data and perform complex
mathematics.
 Python can be used for rapid prototyping, or for production-
ready software development.

WHY PYTHON?

 Python works on different platforms (Windows, Mac, Linux,


Raspberry Pi, etc).
 Python has a simple syntax similar to the English language.
 Python has syntax that allows developers to write programs
with fewer lines than some other programming languages.
 Python runs on an interpreter system, meaning that code can
be executed as soon as it is written. This means that
prototyping can be very quick.
 Python can be treated in a procedural way, an object-orientated
way or a functional way.

20
PYTHON SYNTAX COMPARED TO OTHER PROGRAMMING
LANGUAGES

 Python was designed for readability, and has some similarities


to the English language with influence from mathematics.
 Python uses new lines to complete a command, as opposed to
other programming languages which often use semicolons or
parentheses.
 Python relies on indentation, using whitespace, to define scope;
such as the scope of loops, functions and classes. Other
programming languages often use curly-brackets for this
purpose.

 In Python, keywords are case sensitive.


 There are 33 keywords in Python 3.7. This number can vary
slightly in the course of time.
 All the keywords except True, False and None are in lowercase
and they must be written as it is. The list of all the keywords is
given below:

and del from not while


as elif global or with
assert else if pass yield
break except import print
class exec in raise
continue finally is return
def for lambda try

DATATYPES IN PYHTON
Numbers Boolean
List Set
Strings Tuple
Dictionary

21
PYTHON LIST
List is an ordered sequence of items. It is one of the most used datatype in
Python and is very flexible. All the items in a list do not need to be of the same
type.

Declaring a list is pretty straight forward. Items separated by commas are


enclosed within brackets [ ].

1. >>> a = [1, 2.2, 'python']

Lists are mutable, meaning, value of elements of a list can be altered.

1. >>> a = [1,2,3]
2. >>> a[2]=4
3. >>> a
4. [1, 2, 4]

PYTHON TUPLE
Tuple is an ordered sequence of items same as list.The only difference is that
tuples are immutable. Tuples once created cannot be modified.

Tuples are used to write-protect data and are usually faster than list as it
cannot change dynamically.

It is defined within parentheses () where items are separated by commas.

1. >>> t = (5,'program', 1+3j)

PYTHON STRINGS
String is sequence of Unicode characters. We can use single quotes or double
quotes to represent strings. Multi-line strings can be denoted using triple
quotes, ''' or """.
1. >>> s = "This is a string"
2. >>> s = '''a multiline

Python Set

22
Set is an unordered collection of unique items. Set is defined by values
separated by comma inside braces { }. Items in a set are not ordered.
1. >>> a = {1,2,2,3,3,3}
2. >>> a
3. {1, 2, 3}

PYTHON DICTIONARY
Dictionary is an unordered collection of key-value pairs.

It is generally used when we have a huge amount of data. Dictionaries are


optimized for retrieving data. We must know the key to retrieve the value.

In Python, dictionaries are defined within braces {} with each item being a pair
in the form key:value. Key and value can be of any type.
1. >>> d = {1:'value','key':2}
2. >>> type(d)
3. <class 'dict'>

What is a function in Python?

In Python, function is a group of related statements that perform a specific task.

Functions help break our program into smaller and modular chunks. As our
program grows larger and larger, functions make it more organized and
manageable.

Furthermore, it avoids repetition and makes code reusable.

SYNTAX OF FUNCTION
def function_name(parameters):

"""docstring"""

statement(s)

23
CONVERSION BETWEEN DATA TYPES

We can convert between different data types by using different type conversion
functions like int(), float(), str() etc.

1. >>> float(5)
2. 5.0

Conversion from float to int will truncate the value (make it closer to zero).

1. >>> int(10.6)
2. 10
3. >>> int(-10.6)
4. -10

Conversion to and from string must contain compatible values.

1. >>> float('2.5')
2. 2.5
3. >>> str(25)
4. '25'
5. >>> int('1p')
6. Traceback (most recent call last):
7. File "<string>", line 301, in runcode
8. File "<interactive input>", line 1, in <module>
9. ValueError: invalid literal for int() with base 10: '1p'

We can even convert one sequence to another.

1. >>> set([1,2,3])
2. {1, 2, 3}
3. >>> tuple({5,6,7})
4. (5, 6, 7)
5. >>> list('hello')
6. ['h', 'e', 'l', 'l', 'o']

To convert to dictionary, each element must be a pair

1. >>> dict([[1,2],[3,4]])
2. {1: 2, 3: 4}
3. >>> dict([(3,26),(4,44)])
4. {3: 26, 4: 44}

24
Python GUI – tkinter

Python offers multiple options for developing GUI (Graphical User Interface).
Out of all the GUI methods, tkinter is most commonly used method. It is a
standard Python interface to the Tk GUI toolkit shipped with Python. Python
with tkinter outputs the fastest and easiest way to create the GUI applications.
Creating a GUI using tkinter is an easy task.
To create a tkinter:

1. Importing the module – tkinter


2. Create the main window (container)
3. Add any number of widgets to the main window
4. Apply the event Trigger on the widgets.
There are two main methods used you the user need to remember while
creating the Python application with GUI.

1. Tk(screenName=None, baseName=None, className=’Tk’,


useTk=1): m=tkinter.Tk() where m is the name of the
main window object

2. mainloop(): m.mainloop()

Example: calculator using python


from tkinter import *
def delete():
ent.set("")
def clear():
x=var.get()
l=len(x)
y=x[0:l-1]
ent.set(y)
def prt(num):
l=len(var.get())
var.insert(l,num)

def equal():
ent.set(eval(var.get()))

root=Tk()
25
root.title("calculator")
ent=StringVar()
var=Entry(root,textvariable=ent,justify="left")
var.grid(row=0,column=0)
var7=Button(root,text=" 7 ",command =lambda:prt('7')).grid(row=1,column=0)
var8=Button(root,text=" 8 ",command = lambda:prt('8')).grid(row=1,column=1)
var9=Button(root,text=" 9 ",command = lambda:prt('9')).grid(row=1,column=2)
var10=Button(root,text=" +
",command=lambda:prt('+')).grid(row=1,column=3)
var4=Button(root,text=" 4 ",command = lambda:prt('4')).grid(row=2,column=0)
var5=Button(root,text=" 5 ",command = lambda:prt('5')).grid(row=2,column=1)
var6=Button(root,text=" 6 ",command = lambda:prt('6')).grid(row=2,column=2)
var11=Button(root,text=" - ",command=lambda:prt('-')).grid(row=2,column=3)
var1=Button(root,text=" 1 ",command = lambda:prt('1')).grid(row=3,column=0)
var2=Button(root,text=" 2 ",command = lambda:prt('2')).grid(row=3,column=1)
var3=Button(root,text=" 3 ",command = lambda:prt('3')).grid(row=3,column=2)
var12=Button(root,text=" * ",command=lambda:prt('*')).grid(row=3,column=3)
var13=Button(root,text=" delete ",command=clear).grid(row=4,column=0)
var0=Button(root,text=" 0 ",command = lambda:prt('0')).grid(row=4,column=1)
var15=Button(root,text=" = ",command=equal).grid(row=4,column=2)
var16=Button(root,text=" / ",command=lambda:prt('/')).grid(row=4,column=3)
var17=Button(root,text="clear all",command=delete).grid(row=5,column=0)
mainloop()

Output:

26
27
 MICROCONTROLLER
 It’s like a small computer on a single IC. It contains a processor core, ROM, RAM
and I/O pins dedicated to perform various tasks.
 Microcontrollers are generally used in projects and applications that require
direct control of user.
 As it has all the components needed in its single chip, it does not need any
external circuits to do its task so microcontrollers are heavily used in embedded
systems and major microcontroller manufacturing companies are making them
to be used in embedded market.
 A microcontroller can be called the heart of embedded system.
 Some examples of popular microcontrollers are 8051, AVR, PIC series of
microcontrollers,.

Fig: Above is architecture of 8051 microcontroller. And you can see all the required
components for a small project is present in a single chip.

28
 MICROPROCESSOR

 Microprocessor has only a CPU inside them in one or few Integrated Circuits.
Like microcontrollers it does not have RAM, ROM and other peripherals.
 They are dependent on external circuits of peripherals to work. But
microprocessors are not made for specific task but they are required where
tasks are complex and tricky like development of software’s, games and other
applications that require high memory and where input and output are not
defined.
 It may be called heart of a computer system.
 Some examples of microprocessor are Pentium, I3, and I5 etc.

From this image of architecture of microprocessor it can be easily seen that it have
registers and ALU as processing unit and it does not have RAM, ROM in it.

29
What is the difference between microprocessor and
microcontroller?
EMBEDDED

.
 Key difference in both of them is presence of external peripheral, where
microcontrollers have RAM, ROM, EEPROM embedded in it while we have to use
external circuits in case of microprocessors.
 As all the peripheral of microcontroller are on single chip it is compact while
microprocessor is bulky.
 Processing speed of microcontrollers is about 8 MHz to 50 MHz, but in contrary
processing speed of general microprocessors is above 1 GHz so it works much
faster than microcontrollers.
 Microcontrollers are compact so it makes them favorable and efficient system
for small products and applications while microprocessors are bulky so they are
preferred for larger applications.
 Tasks performed by microcontrollers are limited and generally less complex.
While task performed by microprocessors are software development, Game
development, website, documents making etc. which are generally more
complex so require more memory and speed so that’s why external ROM, RAM
are used with it.
 Microcontrollers are based on Harvard architecture where program memory
and data memory are separate while microprocessors are based on von
Neumann model where program and data are stored in same memory module.

30
rASpBerrY pI

 Raspberry Pi is neither a microprocessor or microcontroller , it is a single board


computer which contains a SOC (System On Chip - Has multicore
processor,GPU,ROM,I/O Peripherals inside it.),DDR RAM memory, Ethernet port,
USB host,micro HDMI on it.
 Raspberry Pi is a credit-card sized computer with low cost, which plugs into a
computer monitor or TV, and to operate it, a user can use a standard keyboard
and mouse to operate it. Raspberry Pi is a series of single-board computers and
it is developed by the Raspberry Pi Foundation in the United Kingdom. This is
developed to promote and create awareness of basic computer science in
schools across the world.
 The latest version of Raspberry Pi computer is Raspberry Pi 3 Model B, which is
very tiny credit card size computer. This can be used efficiently just by
connecting mouse, keyboard, display, power supply, micro SD card along with
installing Linux Distribution in it and that makes a fully-fledged computer where
the user can run all the applications from word processors and spreadsheets to
games.
 Raspberry Pi 3 is an online and open source website creation tool written in PHP
language. It is the most popular open source Content Management System. The
Raspberry Pi 3 Model B is the first Raspberry Pi model to be open-source from
the get-go. The Raspberry Pi 3 is a quad-core and it is much faster and capable
than its previous Raspberry Pi models.

The advantages of Raspberry Pi 3 Model B overs its predecessor:

 The new board in Raspberry Pi 3 Model B is capable of playing 1080p MP4 video
at 60 frames per second, which boost the Pi’s media center credentials.
 The Raspberry Pi 3 comes with built-in Wi-Fi and Bluetooth which helps to also
support the wireless internet out of the box.
 The Pi 3 board supports remote updates to Pi and also sharing images of
operating system between multiple computer machines like booting process can
31
be directly done by using a USB-attached hard drive or pen drive and also by
supporting booting from a network-attached file system.

pIn dIAGrAM oF rASpBerrY pI ModeL

32
33
Some Operating Systems That Can Be Run on Raspberry Pi

 NOOBS
The Raspberry Pi supports several OSes and as such usually comes without one.
Most of the time, however, it ships with an SD card that includes NOOBS (New
Out Of the Box Software) – an OS that includes of a variety of Operating
Systems from which you can choose which to or you to choose which to run on
your Raspberry Pi setup.
 RASPBIAN
It is a Debian-based engineered especially for the Raspberry Pi and it is the
perfect general-purpose OS for Raspberry users.
It employs the Openbox stacking window manager and the Pi Improved
Xwindows Environment Lightweight coupled with a number of pre-installed
software which includes Minecraft Pi, Java, Mathematica, and Chromium.
Raspbian is the Raspberry foundation’s official supported OS and is capable of
accomplishing any task you throw at it.
 UBUNTU CORE
It is the version of Ubuntu designed for Internet of
Things applications. Ubuntu is the most popular Linux-based Operating System
in the world with over 20+ derivatives and given that it has an active and
welcoming forum, it will be easy to get up and running with Ubuntu Snappy
Core on your Raspberry Pi.
 LINUTOP OS
It is a secure raspbian-based web kiosk and digital signage player. it is dedicated
to professionals with the need to deploy public internet stalls and digital
signage solutions using raspberries.this os is perfect if you run hotels,
restaurants, shops, city halls, offices, museums, etc. and it is compatible with
raspberry pi b, b+ and 2.

34
Some Programming Languages Ported to the Raspberry Pi

 Scratch. Scratch is an entry-level programming language that comes as


standard with the Raspberry Pi distribution, Raspbian. ...
 Python. Python is one of the primary programming languages hosted on
the Raspberry Pi. ...
 HTML5. ...
 JavaScript. ...
 JQuery. ...
 Java. ...
 C programming language. ...
 C++
INPUT-OUTPUT PROGRAMMING STEPS FOR RASPBERRY Pi
i) Import the library
>> import RPi.GPIO as var
ii) Import time library
>>import time
iii) Set GPIO set mode
>> var.setmode(var.BOARD)
iv) Set pin as i/p or o/p
>> var.setup(pinadd, var.OUT)
>> var.setup(pinadd, var.IN,pull_up_down=var.PUD_UP)
v) Set warning (optional)
>>var.setwarnings(false)
vi) Make pin high or low
>>var.output(pinadd, var.HIGH)
vii) Check for input condition
>>if var.inpur=(pinno)==var.LOW :
LED BLINKING PROGRAM USING PYTHON

import RPi.GPIO as led

import time

led.setmode (led.BOARD)

35
led.setwarnings(False)
led.setup(3,led.OUT)
led.setup(5,led.OUT)
while True:
led.output(3,led.HIGH)
led.output(5,led.LOW)
time.sleep(1)
led.output(3,led.LOW)
led.output(5,led.HIGH)

36
37
ArduIno
 An Arduino is a microcontroller motherboard. A microcontroller is a simple
computer in that, only one program can be run at a time. It is very easy to use.
 Arduino is an open-source and prototype platform which is based on software
and hardware. It is easy to use. Arduino is the overall microcontroller
motherboard and it has ready-made software called Arduino IDE (Integrated
Development Environment), this software is used to write and upload the
computer program code to the physical board.
Some of the features of Arduino are as listed below:
 Microcontroller motherboard in Arduino is capable to read the analog /digital
input signals from different sensors and then convert those signals into an
output process like turning LED on/off, activating a motor, etc.
 The user can control the functions of a board by sending signals (set of
instructions) to the microcontroller board using Arduino IDE software.
 Arduino does not require any extra piece of hardware/programmer whenever to
want to load a new piece of program to the board. It can be done by using a USB
cable.
 Since Arduino IDE uses an easier version of C++, it is very easy to learn the
programming language to program.

Why Arduino Boards ?


 Arduino board has been used for making different engineering projects and different
applications. The Arduino software is very simple to use for beginners, yet flexible
adequate for advanced users. It runs windows, Linux and Mac. Teachers and
students in the schools utilize it to design low cost scientific instruments to verify the
principles of physics and chemistry. There are numerous other microcontroller
platforms obtainable for physical computing. The Netmedia’s BX-24, Parallax Basic
Stamp, MIT’s Handyboard, Phidget and many others present related functionality.
 Arduino also makes simpler the working process of microcontroller, but it gives some
advantages over other systems for teachers, students and beginners.

38
39
FIGURE : PIN DIAGRAM OF ARDUINO UNO

RASPBERRY PI vs ARDUINO
Both Raspberry Pi 3 vs Arduino are popular choices in the market; let us discuss some
of the major Difference Between Raspberry Pi 3 vs Arduino:
1. The Raspberry Pi 3 is a series of single Board Computer. The single board
consists of a fully functional computer with its dedicated memory, processor
and it runs an operating system (runs on Linux). Whereas Arduino is a
Microcontroller board and this board is not as powerful as Raspberry Pi 3 single
board computers, but a microcontroller board can be great for quick setups.
2. The Raspberry Pi 3 is so faster than the Arduino, means Raspberry Pi 3 has 1.2
GHz whereas Arduino has only 16 MHz.This helps to process the tasks like
playing videos, surfing the web, listening to music, etc. very fast compared to
Arduino.
3. Arduino is a simple approach and more attractive for building a project. The
Arduino has a convenient and user-friendly time interfacing with analog
sensors, motor, or other components, whereas Raspberry Pi 3 has a very
40
complicated path to get sensor readings such as installing software, libraries,
etc.
4. The Raspberry Pi 3 is designed to run operating systems whereas Arduino is not
designed to run on operating systems.

41
Data transmission
Data transmission refers to the process of transferring data between two or
more digital devices. Data is transmitted from one device to another in analog
or digital format. Basically, data transmission enables devices or components
within devices to speak to each other.

 How does data transmission work between digital devices?

Data is transferred in the form of bits between two or more digital devices.
There are two methods used to transmit data between digital devices: serial
transmission and parallel transmission. Serial data transmission sends data
bits one after another over a single channel. Parallel data transmission sends
multiple data bits at the same time over multiple channels.

 What is serial transmission?

When data is sent or received using serial data transmission, the data bits are
organized in a specific order, since they can only be sent one after another.
The order of the data bits is important as it dictates how the transmission is
organized when it is received. It is viewed as a reliable data transmission
method because a data bit is only sent if the previous data bit has already
been received.

 Serial transmission has two classifications: asynchronous and


synchronous.

 Asynchronous Serial Transmission


Data bits can be sent at any point in time. Stop bits and start bits are
used between data bytes to synchronize the transmitter and receiver and
to ensure that the data is transmitted correctly. The time between
sending and receiving data bits is not constant, so gaps are used to
provide time between transmissions.

 The advantage of using the asynchronous method is that no


synchronization is required between the transmitter and receiver devices.
It is also a more cost effective method. A disadvantage is that data
transmission can be slower, but this is not always the case.

 Synchronous Serial Transmission


Data bits are transmitted as a continuous stream in time with a master
clock. The data transmitter and receiver both operate using a
42
synchronized clock frequency; therefore, start bits, stop bits, and gaps
are not used. This means that data moves faster and timing errors are
less frequent because the transmitter and receiver time is synced.
However, data accuracy is highly dependent on timing being synced
correctly between devices. In comparison with asynchronous serial
transmission, this method is usually more expensive.

 When is serial transmission used to send data?

Serial transmission is normally used for long-distance data transfer. It is also


used in cases where the amount of data being sent is relatively small. It
ensures that data integrity is maintained as it transmits the data bits in a
specific order, one after another. In this way, data bits are received in-sync with
one another.

 What is parallel transmission?

When data is sent using parallel data transmission, multiple data bits are
transmitted over multiple channels at the same time. This means that data can
be sent much faster than using serial transmission methods.

Advantages and Disadvantages of Using Parallel Data


Transmission
The main advantages of parallel transmission over serial transmission are:

 it is easier to program;
 and data is sent faster.

Although parallel transmission can transfer data faster, it requires more


transmission channels than serial transmission. This means that data bits can
be out of sync, depending on transfer distance and how fast each bit loads. A
simple of example of where this can be seen is with a voice over IP (VOIP) call
when distortion or interference is noticeable. It can also be seen when there is
skipping or interference on a video stream.

 When is parallel transmission used to send data?


Parallel transmission is used when:

 a large amount of data is being sent;


 the data being sent is time-sensitive;
43
 and the data needs to be sent quickly.

A scenario where parallel transmission is used to send data is video streaming.


When a video is streamed to a viewer, bits need to be received quickly to
prevent a video pausing or buffering. Video streaming also requires the
transmission of large volumes of data. The data being sent is also time-
sensitive as slow data streams result in poor viewer experience.

COMMUNICATION PROTOCOLS:

UART INTERFACE

Following are the features of UART interface.


• The full name is Universal Asynchronous Receiver/Transmitter.
• UART supports lower data rate.
44
• Receiver need to know baudrate of the transmitter before initiation of
reception i.e. before communication to be established.
• UART is simple protocol, it uses start bit (before data word), stop bits (one or
two, after data word), parity bit (even or odd) in its base format for data
formatting. Parity bit helps in one bit error detection.
➨UART Packet = 1 start bit(low level), 8 data bits including parity bit, 1 or 2
stop bit(high level)
• Data is transmitted byte by byte.
• UART generates clock internally and synchronizes it with data stream with
the help of transition of start bit.
• It is also referred by RS232 .
• For long distance communication, 5V UART is converted to higher voltages
viz. +12V for logic 0 and -12V for logic 1.

SPI INTERFACE

As shown in the figure one slave is connected with one master device. Clock is
generated by master device for synchronization of data transfer. It is also
possible to connected more than one slave device with single master for
communication. SPI interface operates in either half or full duplex mode. SPI is
the short form of Serial Peripheral interface. The figure-2 depicts SPI interface
between master and slave devices.

45
It has four main lines as described below.
MOSI - Master Output Slave Input, it is used to transfer data from master
device to slave device.
MISO - Master Input Slave Output, it is used to transfer data from slave device
to master device.
SCLK - Serial Clock, it is clock output from master and used for
synchronization.
SS - Slave Select, it is used by master device to select one slave out of
multiple slaves. It inserts active low signal to select the particular slave device.

I2C INTERFACE

• I2C stands for "inter-IC bus". It is also used as I2C for simplicity.
• I2C is a low speed and two wire serial data connection bus used in
IC(Integrated Circuit).
• It is used to run signals between ICs mounted on the same PCB (Printed
Circuit Board).
• It uses only two lines between multiple masters and multiple slaves viz. SDA
(Serial Data) and SCL (Serial Clock).
• I2C supports various data rates as per versions from 100 Kbps, 400 Kbps, 1
Mbps to 3.4 Mbps
• It is synchronous communication like SPI and unlike UART. Hence there is

46
common clock signal between masters and slaves.
• It uses start and stop bits and ACK bit for every 8 bits of data transfer.

Rules of Serial Transmission


The asynchronous serial protocol has a number of built-in rules - mechanisms
that help ensure robust and error-free data transfers. These mechanisms,
which we get for eschewing the external clock signal, are:

 Data bits,
 Synchronization bits,
 Parity bits,
 and Baud rate.

Through the variety of these signaling mechanisms, you'll find that there's no
one way to send data serially. The protocol is highly configurable. The critical
part is making sure that both devices on a serial bus are configured to use
the exact same protocols.
 Baud Rate
The baud rate specifies how fast data is sent over a serial line. It's usually
expressed in units of bits-per-second (bps). If you invert the baud rate, you can
find out just how long it takes to transmit a single bit. This value determines
how long the transmitter holds a serial line high/low or at what period the
receiving device samples its line.
Baud rates can be just about any value within reason. The only requirement is
that both devices operate at the same rate. One of the more common baud
rates, especially for simple stuff where speed isn't critical, is 9600 bps. Other
"standard" baud are 1200, 2400, 4800, 19200, 38400, 57600, and 115200.
The higher a baud rate goes, the faster data is sent/received, but there are
limits to how fast data can be transferred. You usually won't see speeds
exceeding 115200 - that's fast for most microcontrollers. Get too high, and
you'll begin to see errors on the receiving end, as clocks and sampling periods
just can't keep up.

47
 Bit Rate
Actual rate of transfer of Bits per second
 Framing the data
Each block (usually a byte) of data transmitted is actually sent in
a packet or frame of bits. Frames are created by appending
synchronization and parity bits to our data.

 Data chunk
The real meat of every serial packet is the data it carries. We ambiguously call
this block of data a chunk, because its size isn't specifically stated. The amount
of data in each packet can be set to anything from 5 to 9 bits. Certainly, the
standard data size is your basic 8-bit byte, but other sizes have their uses. A 7-
bit data chunk can be more efficient than 8, especially if you're just transferring
7-bit ASCII characters.
 Synchronization bits
The synchronization bits are two or three special bits transferred with each
chunk of data. They are the start bit and the stop bit(s). True to their name,
these bits mark the beginning and end of a packet. There's always only one
start bit, but the number of stop bits is configurable to either one or two (though
it's commonly left at one).
The start bit is always indicated by an idle data line going from 1 to 0, while the
stop bit(s) will transition back to the idle state by holding the line at 1.
 Parity bits
Parity is a form of very simple, low-level error checking. It comes in two flavors:
odd or even. To produce the parity bit, all 5-9 bits of the data byte are added
up, and the evenness of the sum decides whether the bit is set or not. For
example, assuming parity is set to even and was being added to a data byte
like 0b01011101, which has an odd number of 1's (5), the parity bit would be
set to 1. Conversely, if the parity mode was set to odd, the parity bit would
be 0.
UART VS USART:
UART > Universal Asynchronous Receiver Transmitter
USART > Universal Synchronous Asynchronous Receiver Transmitter

48
 A UART generates its data clock internally to the microcontroller and
synchronizes that clock with the data stream by using the start bit
transition. There is no incoming clock signal that is associated with the
data, so in order to properly receive the data stream the receiver needs
to know ahead of time what the baud rate should be.
 A USART can be set up to run in synchronous mode. In this mode the
sending peripheral will generate a clock that the receiving peripheral can
recover from the data stream without knowing the baud rate ahead of
time.
The use of the external clock allows the data rate of the USART to be much
higher than that of a standard UART, reaching up to rates of 4 Mbps.

49
SoFtWAreS

 CAYENNE
It is an app for smartphones and computers that allows you to control the
Raspberry Pi and soon also the Arduino through the use of an elegant
graphical interface and a solid nice communication protocol.

The features are:

 Add and remotely control sensors, motors, actuators, GPIO boards, and more
 Customizable dashboards with drag-and-drop widgets for connection devices
 Create triggers and threshold alerts for devices, events, and actions
 Schedule one-time or multi-device events for easy automation
 Quick and easy setup - connect your Pi in minutes

Step 1: Sign Up to Cayenne


Step 2: Download the App and Install Cayenne
STEP 3: To download and install myDevices Cayenne on your Pi, use the
Terminal on your Pi or SSH. Run the following commands:

wget
https://cayenne.mydevices.com/dl/rpi_4ithnypn
7p.sh
sudo bash rpi_4ithnypn7p.sh -v

50
Step 4: See Your Device on Cayenne Dashboard

You can personalize the Dashboard of Cayenne by using the widgets. The
default Dashboard have CPU, Temp and RAM widget . These are the values of
your Raspberry Pi. You can see the temp and the work flow of Raspberry pi.
Then you can see the GPIO schedule. In the GPIO you can set every pin of
GPIO of Raspberry. You can set the pin like Output or Input.
Then you can activate the pin or read the value of the pin. The two values
are HIGH or LOW. This is valid for Input and Output.

Proteus is a simulation and design software tool developed by Labcenter


Electronics for Electrical
and Electronic circuit design. It also possess 2D CAD drawing feature. It
deserves to bear the tagline “From concept to completion⠀ .

About Proteus

It is a software suite containing schematic, simulation as well as PCB


designing.
51
 ISIS is the software used to draw schematics an
andd simulate the circuits in real
time.The simulation allows human access during run time,thus providing real
time simulation.
 ARES Â is used for PCB designing.It has the feature ooff viewing output in 3D
view of the designed PCB along  with components.
 The designer can also develop 2D drawings for the product
product.

PROTEUS AND ARDUINO


 For simulation of Arduino in Proteus , get the hex file from Arduino software and
add it in your Proteus Arduino board.
 Once the hex file is uploaded in the Ar
Arduino
duino then run your Arduino Proteus
Simulation and if everything goes fine then your program will run successfully
su as
shown in below figure:

PythonAnywhere is an online integrated development environment (IDE)


and web hosting service (Platform
Platform as a service
service)) based on the Python
programming language

52
 It provides in-browser access to server-based Python and Bash command-
line interfaces, along with a code editor with syntax highlighting.
 Program files can be transferred to and from the service using the user's
browser.
 Web applications hosted by the service can be written using any WSGI-
based application framework.

 PythonAnywhere has various versions of Python installed, and each version


has its associated version of Flask.
 Flask is a real time server.
 Command to import flask library
>>python –m pip install flask

MIT App Inventor

It is an intuitive, visual programming environment that allows everyone even


children to build fully functional apps for smartphones and tablets. Those new
to MIT App Inventor can have a simple first app up and running in less than 30
minutes.

53
54
55
56

Вам также может понравиться