0% found this document useful (0 votes)
26 views74 pages

Embedded Systems & IoT Lab Manual 2025

The document outlines the curriculum and objectives for the Embedded Systems and IoT Laboratory for the academic year 2025-2026 at V.S.B. Engineering College. It includes the vision and mission of the institution and department, program educational objectives, program outcomes, and specific outcomes related to embedded systems and IoT. Additionally, it details practical exercises and experiments designed to enhance students' technical skills in embedded systems and IoT technologies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views74 pages

Embedded Systems & IoT Lab Manual 2025

The document outlines the curriculum and objectives for the Embedded Systems and IoT Laboratory for the academic year 2025-2026 at V.S.B. Engineering College. It includes the vision and mission of the institution and department, program educational objectives, program outcomes, and specific outcomes related to embedded systems and IoT. Additionally, it details practical exercises and experiments designed to enhance students' technical skills in embedded systems and IoT technologies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DEPARTMENT OF COMPUTER SCIENCE AND BUINESS SYSTEMS

EMBEDDED SYSTEM AND IOT LABORATORY

(Regulation 2023)

ACADEMIC YEAR: 2025-2026 (ODD )

III Year /V semester Lab Manual

1
V.S.B. ENGINEERING COLLEGE, KARUR
Department of Computer Science and Business Systems
ACADEMIC YEAR: 2025-2026 (ODD Semester)
VISION, MISSION, PEOs, POs and PSOs
Vision of the Institution:
We endeavor to impart futuristic technical education of the highest quality to the student
community and to inculcate discipline in them to face the world with self-confidence and thus we prepare them
for life as responsible citizens to uphold human values and to be of service at large .We strive to bring of the
Institution as an Institution of academic excellence of International standard.
Mission of the Institution:
We transform persons into personalities by the state-of the art infrastructure, time consciousness, quick response
and the best academic practices through assessment and advice.
Vision of the Department:
To produce professionals as industry ready in the field of computer science and business system with strong
human values to serve the nation.
Mission of the Department:
1. Offer a well-designed and updated curriculum that covers essential principles and practical skills in information
technology. This should include technical knowledge, programming expertise, database management, network
administration, cyber security, and emerging technologies. Ensure a balance between theoretical concepts and
hands-on experience through practical assignments, projects, and internships.
2. Provide opportunities for students to develop their soft skills, including effective communication, teamwork,
leadership, and emotional intelligence. Offer workshops and extracurricular activities that promote self-
confidence, creativity, and problem-solving abilities.
3. Encourage students and faculty members to engage in research and innovation in the field of information
technology. Provide resources and support for research projects, collaborations, and participation in
national/international conferences. This will foster a culture of continuous learning, creativity, and technological
advancement.
4. Embed the importance of ethical values, integrity, and social responsibility in the institution’s culture.
Encourage community service, social initiatives, and sustainable practices that contribute to the betterment of
Society.
Programme Educational Objectives (PEOs)
PEO1: Choose a specific engineering discipline or field based on personal interest and market demand.
Specializing in areas such as mechanical engineering, electrical engineering, civil
Engineering, chemical engineering, or computer engineering will allow for in-depth knowledge and
expertise.
PEO2: Embrace a mindset of continuous improvement. Seek feedback, learn from failures, and strive for
excellence in all aspects of engineering work. Continuously upgrade technical expertise, professional
skills, and knowledge to stay ahead in a competitive industry.
PEO3: Develop strong problem-solving skills, a critical attribute for engineers. Enhance analytical thinking,
logical reasoning, and systematic approaches to problem-solving through practice, case studies, and
projects. This helps in formulating effective and efficient solutions for industrial problems.
Program Outcomes (PO)
PO 1: Engineering knowledge
Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering
specialization to the solution of complex engineering problems.
PO2: Problem analysis
Identify, formulate, research literature, and analyze complex engineering problems reaching substantiated
conclusions using first principles of mathematics, natural sciences, and engineering sciences.
PO3: Design/development of solutions
Design solutions for complex engineering problems and design system components or processes that meet
the specified needs with appropriate consideration for the public health and safety, and the cultural,
societal, and environmental considerations.
PO4: Conduct investigations of complex problems
Use research-based knowledge and research methods including design of experiments, analysis and
interpretation of data, and synthesis of the information to provide valid conclusions.
PO5: Modern tool usage
Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including
prediction and modeling to complex engineering activities with an understanding of the limitations.
PO6: The engineer and society
Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural
issues and the consequent responsibilities relevant to the professional engineering
PO7: Environment and sustainability
Understand the impact of the professional engineering solutions in societal and environmental contexts,
and demonstrate the knowledge of, and need for sustainable development.
PO8: Ethics
Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
PO9: Individual and team work
Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary
settings.
PO10: Communication
Communicate effectively on complex engineering activities with the engineering community and with
society at large, such as, being able to comprehend and write effective reports and design documentation,
make effective presentations, and give and receive clear instructions.
PO11: Project management and finance
Demonstrate knowledge and understanding of the engineering and management principles and apply these
to one’s own work, as a member and leader in a team, to manage projects and in multidisciplinary
environments.
PO12: Life-long learning
Recognize the need for, and have the preparation and ability to engage in independent and life-long
learning in the broadest context of technological change.
Program Specific Outcome (PSO)
PSO1: Based on the identified requirements and process analysis, design BPM solutions that address the
specific needs of the industry or social sector. This involves defining the desired state of the processes,
documenting process flows, creating system specifications, and designing user interfaces.
PSO2: Develop the BPM solutions based on the defined design and system specifications. This may involve
custom development, configuration of BPM software, or integration with existing systems. Ensure a
systematic approach to development, including thorough testing, debugging, and quality assurance.
PSO3: Foster collaboration within the industry or social sector to share best practices and lessons learned in
BPM. Encourage collaboration among organizations, academia, and relevant stakeholders to collectively
seek innovative solutions and address common challenges. Alg orithms and randomized algorithms
EMBEDDED SYSTEMS AND IOT LABORATORY
LTPC
3 024

SYLLABUS

OBJECTIVES:

The student should be made:


 To learn the internal architecture and programming of an embedded processor.
 To introduce interfacing I/O devices to the processor.
 To introduce the evolution of the Internet of Things (IoT).
 To build a small low-cost embedded and IoT system using Arduino/Raspberry Pi/ open
 platform.
 To apply the concept of Internet of Things in real world scenario.

PRACTICAL EXERCISES:
1. Write 8051 Assembly Language experiments using simulator.
2. Test data transfer between registers and memory.
3. Perform ALU operations.
4. Write Basic and arithmetic Programs Using Embedded C.
5. Introduction to Arduino platform and programming.
6. Explore different communication methods with IoT devices (Zigbee, GSM, Bluetooth).
7. Introduction to Raspberry PI platform and python programming.
8. Interfacing sensors with Raspberry PI.
9. Communicate between Arduino and Raspberry PI using any wireless medium.
10. Setup a cloud platform to log the data.
11. Log Data using Raspberry PI and upload to the cloud platform.
12. . Design an IOT based system
TOTAL: 30 PERIODS

4
List of Experiments Mapping with COS, POS & PSOS CO-PO MAPPING

[Link] Name of the Experiment COS PO PSOS


S
Write 8051 Assembly PO1, PO2, PO3, PO4, PO8, PO9, PSO1,
1 CO1 PO11, PO12 PSO3
Language experiments using
simulator.

Test data transfer between PO1, PO2, PO3, PO4, PO8, PO9, PSO1,
2 CO2
PO11, PO12 PSO3
registers and memory.
Perform ALU operations. PO1, PO2, PO3, PO4, PO8, PO9, PSO1,
3 CO3
PO11, PO12 PSO3
Write Basic and arithmetic CO3, PO1, PO2, PO3, PO4, PO8, PO9, PSO1,
4
CO5 PO11, PO12 PSO3
Programs Using Embedded
C.
Introduction to Arduino PO1, PO2, PO3, PO4, PO8, PO9, PSO1,
5 CO3
PO11, PO12 PSO3
platform and programming
Explore different PO1, PO2, PO3, PO4, PO8, PO9, PSO1,
6 communication methods with CO5 PO11, PO12 PSO3
IoT devices (Zigbee, GSM,
Bluetooth)
7
Introduction to Raspberry PI CO3
PO1, PO2, PO3, PO4, PO5, PO8, PSO1,
platform and python PO9, PO11, PO12 PSO3
programming
8
Interfacing sensors with CO3
PO1, PO2, PO3, PO4, PO5, PO8, PSO1,
Raspberry PI PO9, PO11, PO12 PSO3

Communicate between PO1, PO2, PO3, PO4, PO5, PO8, PSO1,


9 CO3
Arduino and Raspberry PI PO9, PO11, PO12 PSO3
using any wireless medium
Setup a cloud platform to log PO1, PO2, PO3, PO4, PO5, PO8, PSO1,
10 CO4
the data PO9, PO11, PO12 PSO3
Log Data using Raspberry PI PO1, PO2, PO3, PO4, PO8, PO9, PSO1,
11 CO4
and upload to the cloud PO11, PO12 PSO3
platform
Design an IOT based system PO1, PO2, PO3, PO4, PO8, PO9, PSO1,
12 CO4
PO11, PO12 PSO3

5
Justification of the mapping: (Experiments with POS)
An in-depth knowledge of mathematics and engineering is required to understand the basics of
Image sampling and quantization (PO1) and design can be formulated and analyzed with the
Ex:No1 fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and individual and team work
(PO9) is needed to design environmental sustainable digital images. Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).
An in-depth knowledge of mathematics and engineering is required to understand the basics of
spatial and intensity resolution of images. (PO1) and design can be formulated and analyzed with
Ex:No2 the fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and individual and team
work(PO9) is needed to design environmental digital images . Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).
An in-depth knowledge of mathematics and engineering is required to understand the basics of
Intensity transformation of images. (PO1) and design can be formulated and analyzed with the
Ex:No3 fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and individual and team work
(PO9) is needed to design environmental digital images. Usage of image simulated design tools
is needed to indulge in persistent learning (PO12).
An in-depth knowledge of mathematics and engineering is required to understand the basics of
DFT analysis of images. (PO1) and design can be formulated and analyzed with the
Ex:No4 fundamentals learnt (PO2, PO3, PO4).Professional Ethics (PO8) and individual and team work
(PO9) is needed
to design environmental digital images. Usage of image simulated design tools is needed to indulge
in persistent learning (PO12).
An in-depth knowledge of mathematics and engineering is required to understand the basics of
Transforms (Walsh, Hadamard, DCT, Haar) (PO1) and design can be formulated and analyzed
Ex:No5 with the fundamentals learnt (PO2, PO3, PO4).Professional Ethics (PO8) and individual and team
work(PO9) is needed to design environmental digital images . Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).
An in-depth knowledge of mathematics and engineering is required to understand the basics of
Histogram Processing and Basic Thresholding functions (PO1) and design can be formulated and
Ex:No6 analyzed with the fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and
individualand team work (PO9) is needed to design environmental digital images . Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).
An in-depth knowledge of mathematics and engineering is required to understand the basics of
Image Enhancement-Spatial filtering (PO1) and design can be formulated and analyzed with the
Ex:No7 fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and individual and team work
(PO9) is needed to design environmental digital images . Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).
An in-depth knowledge of mathematics and engineering is required to understand the basics of
Image Enhancement- Filtering in frequency domain (PO1) and design can be formulated and
Ex:No8 analyzed with the fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and
individualand team work (PO9) is needed to design environmental digital images . Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).
An in-depth knowledge of mathematics and engineering is required to understand the basics of
Image segmentation – Edge detection, line detection and point detection. (PO1) and design can be
Ex:No9 formulated and analyzed with the fundamentals learnt (PO2, PO3, PO4). Professional Ethics
(PO8)
and individual and team work (PO9) is needed to design environmental digital images. Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).

6
An in-depth knowledge of mathematics and engineering is required to understand the basics of
Basic Morphological operations. Region based Segmentation (PO1) and design can be formulated
Ex:No10 and analyzed with the fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and
individual and team work (PO9) is needed to design environmental digital images . Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).

An in-depth knowledge of mathematics and engineering is required to understand the basics of


Segmentation using watershed transformation. (PO1) and design can be formulated and analyzed
Ex:No11 with the fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and individual and
teamwork (PO9) is needed to design environmental digital images . Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).

An in-depth knowledge of mathematics and engineering is required to understand the basics of


Analysis of images with different color models (PO1) and design can be formulated and analyzed
Ex:No12 with the fundamentals learnt (PO2, PO3, PO4). Professional Ethics (PO8) and individual and
teamwork (PO9) is needed to design environmental digital images . Usage of
image simulated design tools is needed to indulge in persistent learning (PO12).

7
INDEX
[Link] Name of the Experiment Page Marks Signatureof the
No Obtained faculty member.
1 Write 8051 Assembly Language
experiments using simulator.
2 Test data transfer between registers
and memory.
3 Perform ALU operations.
4 Write Basic and arithmetic
Programs Using Embedded C.
5 Introduction to Arduino platform
and programming
6 Explore different communication
methods with IoT devices (Zigbee,
GSM, Bluetooth)
7 Introduction to Raspberry PI
platform and python programming
8 Interfacing sensors with Raspberry
PI
9 Communicate between Arduino and
Raspberry PI using any wireless
medium
10 Setup a cloud platform to log the
data
11 Log Data using Raspberry PI and
upload to the cloud platform
12 Design an IOT based system

8
EXPERIMENT 1: ARITHMETIC OPERATION-ADDITION, SUBTRACTION,
MULTIPLICATION AND DIVISION. SQUARE AND CUBE
OPERATIONS FOR 16 BIT NUMBERS.

AIM:
To write 8051 Assembly Language experiments using simulator.

1 A) Write an ALP to perform Addition (16-bit by 16-bit)

using 8051
PROGRAM:

MOV R0, #50H //Initialize input1 memory pointer


MOV R1, #60H // Initialize input2 memory pointer and store output also same
memory pointer
MOV R2, #02H // Initialize iteration count
BACK: MOV A, @R0 //Get lower bytes data in first iteration, upper bytes data in
second iteration, add them with carry and store in memory
pointer2.
ADDC A, @R1
MOV @R1, A
INC R0 // Increment memory pointer1 & 2 to get upper bytes
INC R1

DJNZ R2, BACK /* Decrement iteration count and if it is not zero, go to relative
address and repeat the same process until count become zero.*/
CLR A //Store the carr
ADDC A, #00H
MOV @R1, A
END

Memory Window
Before execution :
D:0x50H : FA F3
D:0X60H: 02 14
After execution :
D:0x50H : FA F3
D:0X60H: FC 07 01
ADDITION MANUAL CALCULATION :
INPUT1 : F3(51H) FA(50H)
INPUT2 : 14(61H) 02(60H)

Output in memory

9
1. b) Write an ALP to perform subtraction (16-bit by 16-bit) using 8051
PROGRAM:
MOV R0, #50H //Initialize input1 memory pointer
MOV R1, #60H // Initialize input2 memory pointer and store output also same
memory pointer
MOV R2, #02H // Initialize iteration count
BACK: MOV A, @R0 /*Get lower bytes data in first iteration, upper bytes data in
SUBB A, @R1 second iteration ,subtract from minuend to subtrahend with borrow
and store in memory pointer2.*/
MOV @R1, A
INC R0 // Increment memory pointer1 & 2 to get upper bytes
INC R1
DJNZ R2, BACK /* Decrement iteration count and if it is not zero, go to relative
address and repeat the same process until count become zero.*/
CLR A //Store t
ADDC A, #00H
MOV @R1, A
END
Memory Window
Before execution :
D:0x50H : FA F4
D:0X60H: 02 F5
After execution :
D:0x50H : FA F4
D:0X60H: F8 FF 01
SUBTRACTION MANUAL CALCULATION :
INPUT1 : F4(51H) FA(50H)
INPUT2 : F5(61H) 02(60H)
Answer

Output in memory

Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total
RESULT:

10
Experiment 2: TEST DATA TRANSFER BETWEEN MEMORY
AND REGISTER
Aim :

To test the data transfer between memory and register

Procedure:

Data transfer instructions are the instructions that are used to transfer data into micro-
controller.
Register to Memory: In this data transfer, Data will be transferred from register to
the given memory location. consider an example where given location is 201k and you have
to copy data from the accumulator. Example: STA 201K

Memory to Register: In this data transfer, Data will be transferred from memory to the
register. consider an example where given location is 201k and you have to load data from this
memory location to the accumulator.
Example:
LDA 2020k
Constant to Register: In this data transfer, Data will be transferred to the immediately given
register. consider an example where the given Data is 05 and you have to load data to the
accumulator.
Example:
MVI A, 05
The following table shows different transfer instructions :
Instruction Operand Explanation Example

MOV D, S D=S MOV D, S

D, K(memory
LDS D = Value at K LDS D, K
location)

D = Value at memory location stored


LD D, S LD D, S
in S

LDI D, K(constant) D=K LDI D, K

Store the value in register Z from


D, Z(flash
LPM flash memory into the memory LPM D, Z
memory)
location stored in the D register

Stores the value in register A in D.


IN D, A where A is from [0, 63](64 I/O IN D, A
Registers)

OUT A, D Stores the value in register D in A. OUT A, D

11
Instruction Operand Explanation Example

where A is from [0, 63](64 I/O


Registers)

Stores the value in register S into


STS K, S STS K, S
memory location K.

Store the value in register S into the


ST D, S memory location stored in the D ST D, S
register

Pushes the content of D on the top of


PUSH D PUSH D
the stack

Removes the topmost entry from the


POP D POP D
stack and transfers that value to D

D and S are registers. PUSH and POP instructions are strict to maintain the stack.

Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

12
EXPERIMENT 3: PERFORM ALU OPERATIONS

Aim:
To perform arithmetic and logical operations
Theory:
Inside a computer, there is an Arithmetic Logic Unit (ALU), which is capable of performing
logical operations (e.g. AND, OR, Ex-OR, Invert etc.) in addition to the arithmetic operations (e.g.
Addition, Subtraction etc.). The control unit supplies the data required by the ALU from memory,
or from input devices, and directs the ALU to perform a specific operation based on the instruction
fetched from the memory. ALU is the “calculator” portion of the computer.

An arithmetic logic unit(ALU) is a major component of the central processing unit of the a
computer system. It does all processes related to arithmetic and logic operations that need to be
done on instruction words. In some microprocessor architectures, the ALU is divided into the
arithmetic unit (AU) and the logic unit (LU).
An ALU can be designed by engineers to calculate many different operations. When the operations
become more and more complex, then the ALU will also become more and more expensive and
also takes up more space in the CPU and dissipates more heat. That is why engineers make the
ALU powerful enough to ensure that the CPU is also powerful and fast, but not so complex as to
become prohibitive in terms of cost and other disadvantages.
ALU is also known as an Integer Unit (IU). The arithmetic logic unit is that part of the CPU that
handles all the calculations the CPU may need. Most of these operations are logical in nature.
Depending on how the ALU is designed, it can make the CPU more powerful, but it also consumes
more energy and creates more heat. Therefore, there must be a balance between how powerful and
complex the ALU is and how expensive the whole unit becomes. This is why faster CPUs are
more expensive, consume more power and dissipate more heat.
Different operation as carried out by ALU can be categorized as follows –
 logical operations − These include operations like AND, OR, NOT, XOR, NOR,
NAND, etc.

13
 Bit-Shifting Operations − This pertains to shifting the positions of the bits by a
certain number of places either towards the right or left, which is considered a
multiplication or division operations.
 Arithmetic operations − This refers to bit addition and subtraction. Although
multiplication and division are sometimes used, these operations are more expensive
to make. Multiplication and subtraction can also be done by repetitive additions and
subtractions respectively.

Procedure:

Design of ALU
ALU or Arithmetic Logical Unit is a digital circuit to do arithmetic operations like addition,
subtraction,division, multiplication and logical oparations like and, or, xor, nand, nor etc. A simple
block diagram of a 4 bit ALU for operations and,or,xor and Add is shown here :

The 4-bit ALU block is combined using 4 1-bit ALU block


Design Issues :
The circuit functionality of a 1 bit ALU is shown here, depending upon the control signal S 1 and
S0 the circuit operates as follows:
for Control signal S1 = 0 , S0 = 0, the output is A And B,
for Control signal S1 = 0 , S0 = 1, the output is A Or B,
for Control signal S1 = 1 , S0 = 0, the output is A Xor B,
for Control signal S1 = 1 , S0 = 1, the output is A Add B.

The truth table for 16-bit ALU with capabilities similar to 74181 is
shown here:

14
MODE SELECT FN FOR ACTIVE HIGH OPERANDS

INPUTS LOGIC ARITHMETIC (NOTE 2)

S3 S2 S1 S0 (M = H) (M = L) (Cn=L)

L L L L A' A

L L L H A'+B' A+B

L L H L A'B A+B'

L L H H Logic 0 minus 1

L H L L (AB)' A plus AB'

L H L H B' (A + B) plus AB'

L H H L A⊕B A minus B minus 1

L H H H AB' AB minus 1

H L L L A'+B A plus AB

H L L H (A ⊕ B)' A plus B

H L H L B (A + B') plus AB

H L H H AB AB minus 1

H H L L Logic 1 A plus A (Note 1)

H H L H A+B' (A + B) plus A

H H H L A+B (A + B') plus A

H H H H A A minus 1

Required functionality of ALU (inputs and outputs are active high)

The L denotes the logic low and H denotes logic high.

15
Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

16
Experiment4: Write Basic and arithmetic Programs Using Embedded C.

Aim:
Objective: To know the different arithmetic operators using Embedded C and Arduino UNO
board.
Components Used: Arduino Uno board-1, Arduino IDE DSO and laptop with windows and
IDE installed.

Theory: Arduino IDE is capable of doing basic arithmetic operations. Arduino has the
following five arithmetic operators for basic mathematical operations:
Operators Operator Symbol Example
Addition + a = b + 2017
Subtraction - b = 2017 - a
Multiplication * d = 2.5 * e

Division / e = d / 2.5
Remainder % f = d % 2.5
Different arithmetic operators in embedded C:
Addition Operator (+):
The addition operator is used for adding two numbers.
Subtraction Operator (-):
The subtraction operator subtracts one number from another. It is represented by the plus sign.
Multiplication operator (*):
The multiplication operator multiplies one number with another. It is represented by the
asterisk
Division operator (/):
The division operator divides one number by another. It is represented by the division sign.
Remainder operator (%):
The remainder operator calculates the remainder after one number is divided by another
number. It is represented by the percentage sign.
Procedure:
(1) Make the hardware connections as shown in Figure 2.1.
(2) Use the Arduino IDE for programming the Arduino UNO board in embedded C
language.
(3) Then compile the program and upload the Hex file in the Atmega328p microcontroller
of the board.
(4) Check the appropriate output on the computer screen the Arduino UNO board attached
with.

Programs for different arithmetic operators in embedded C:


(1) Program for Addition:

int Num1 = 15; int


Num2 = 3; int Sum;

17
void setup(){
[Link](9600);
Sum = Num1 + Num2;
[Link]("Addition of Num1 and Num2 is ");
[Link](Sum);
} void loop()
{
}
Output: Serial Monitor Response is Addition of Num1 and Num2 is 18.
(2) Program for Subtraction:
int Num1 = 15;
int Num2 = 3;
int Result; void
setup(){
[Link](9600);
Result = Num1 - Num2;
[Link]("Subtraction of Num1 and Num2 is ");
[Link](Result);
} void loop()
{
}
Output: Serial Monitor Response is Subtraction of Num1 and Num2 is 12.
(3) Program for Multiplication:
int Num1 = 15;
int Num2 = 3;
int Result; void
setup(){
[Link](9600);
Result = Num1 * Num2;
[Link]("Multiplication of Num1 and Num2 is ");
[Link](Result);
} void loop()
{
}
Output: Serial Monitor Response is Multiplication of Num1 and Num2 is 15.
(4) Program for Division:
int Num1 = 15; int
Num2 = 3; int
Result;

void setup(){
[Link](9600);
Result = Num1 / Num2;
[Link]("Division of Num1 and Num2 is ");
[Link](Result);
} void loop()
{
}
Output: Serial Monitor Response is Division of Num1 and Num2 is 5.
(5) Program for remainder:
18
int Num1 = 6;
int Num2 = 5;
int Result; void
setup(){
[Link](9600);
Result = Num1 % Num2;
[Link]("Remainder of Num1 and Num2 is ");
[Link](Result);
} void loop()
{
}
Output: Serial Monitor Response: Remainder of Num1 and Num2 is 1.
Precautions:
(1) Handle the hardware properly as it is the sensitive device.
(2) Make the connections properly on the Arduino UNO board.
(3) Check all the connections before power on all the equipment’s.
(4) Beware of using any liquid near the setup.

Evaluation Details
Marks allotted
Marks Scored
Preparation

Observation

Record

Viva-voce

Total
RESULT:

19
EXPERIMENT 5: INTRODUCTION TO ARDUINO AND PROGRAMMING

AIM:

To study about Arduino and basic programming


Theory:
he Arduino platform has since its start in 2005, grown to become one of the most
recognizable brands in the space of electronics and embedded design.

But what are the cornerstones of Arduino? What is a "board", how do I write code to it,
and what are the tools needed to create my own project? The goal with this guide is to
provide you with an overview to the Arduino project.

Arduino Hardware

In this section, we will dedicate some time to learn about some fundamentals in
electronics, and about the basic operation of an Arduino board.

 Anatomy of an Arduino Board


 Basic Operation
 Circuit Basics
 Electronic Signals
 Analog Signal
 Digital Signal
 Sensors & Actuators
 Serial Communication Protocols
 Memory
 Embedded Sensors
 Internet of Things (IoT)

Arduino API

In this section you will learn what the Arduino API is, and how to create code that can
run on your Arduino board.

 Main Parts
 Program Structure
 The "Sketch"
 Example Sketch
 Libraries
 Core Specific API

Arduino Software Tools

In this section you will learn how to set up your development environment as well as
learning about what options there are.

 A Typical Workflow
 Arduino IDE 1.8.x
 Arduino IDE 2
20
 Arduino IoT Cloud
 Web Editor
 Library Manager
 Arduino CLI

Quick Reference

The quick reference is an extract from the full Arduino API, containing popular functions,
structures and methods.

 General
 Serial Communication
 GPIO / Pin Management
 Structure

Arduino Hardware
Over the years, Arduino has released hundreds of hardware designs in many shapes
and forms.

Anatomy of an Arduino Board

While all Arduino boards differ from each other, there are several key components that
can be found on practically any

Ard u
ino. Let's take a look at the image below:

Key components of an Arduino board.

 1. Microcontroller - this is the brain of an Arduino, and is the component that we


load programs into. Think of it as a tiny computer, designed to execute only a
specific number of things.
 2. USB port - used to connect your Arduino board to a computer.
 3. USB to Serial chip - the USB to Serial is an important component, as it helps
translating data that comes from e.g. a computer to the on-board microcontroller.
This is what makes it possible to program the Arduino board from your computer.

21
 4. Digital pins - pins that use digital logic (0,1 or LOW/HIGH). Commonly used for
switches and to turn on/off an LED.
 5. Analog pins - pins that can read analog values in a 10 bit resolution (0-1023).
 6. 5V / 3.3V pins- these pins are used to power external components.
 7. GND - also known as

ground

negative

or simply

, is used to complete a circuit, where the electrical level is at 0 volt.

 8. VIN - stands for Voltage In, where you can connect external power supplies.

Depending on the Arduino board, you will find many more components. The items listed
above are generally found on any Arduino board.

Basic Operation

Most Arduino boards are designed to have a single program running on the
microcontroller. This program can be designed to perform one single action, such as
blinking an LED. It can also be designed to execute hundreds of actions in a cycle. The
scope varies from one program to another.

The program that is loaded to the microcontroller will start execution as soon as it is
powered. Every program has a function called "loop". Inside the loop function, you can
for example:

 Read a sensor.
 Turn on a light.
 Check whether a condition is met.
 All of the above.

The speed of a program is incredibly fast, unless we tell it to slow down. It depends on
the size of the program and how long it takes for the microcontroller to execute it, but it
is generally in microseconds (one millionth of a second).

22
The basic operation of an Arduino.

Circuit Basics

Circuits consist of at least one active electronic component, and a conductive material,
such as wires, so that current can pass through. When working with an Arduino, you will
in most cases build a circuit for your project.

A simple example of a circuit, is an LED circuit. A wire is connected from a pin on the
Arduino, to an LED via a resistor (to protect the LED from high current), and finally to the
ground pin (GND). When the pin is set to a HIGH state, the microcontroller on the
Arduino board will allow an electric current to flow through the circuit, which turns on the
LED. When the pin is set to a LOW state, the LED will turn off, as an electric current is
not flowing through the circuit.

LED circuit with an Arduino.

23
An Circuits are typically represented as schematics, which are the blueprints for your
circuit. The image below shows the schematic's representation of the same circuit shown
in the image above.

Schematics of a circuit.

Evaluation Details Marks allotted


Marks
Scored
Preparation

Observation

Record

Viva-voce

Total

RESULT:

24
EXPERIMENT 6: EXPLORE THE DIFFERENT COMMUNICATION METHODS
WITH IOT (ZIGBEE, GSM,BLUETOOTH)

AIM:

To explore the different communication methods with iot like zigbee,gsm,Bluetooth.

Theory:
IoT Communication: IoT is the connection of devices over the internet, where
these smart devices communicate with each other , exchange data , perform some tasks
without any human involvement. These devices are embedded with electronics, software,
network and sensors which help in communication. Communication between smart
devices is very important in IOT as it enables these devices to gather, exchange data
which contribute in success of that IOT product/project.
Types of Communications in IOT:
The following are some communication types in IoT:-
1. Human to Machine (H2M):
In this human gives input to IOT device i.e as speech/text/image etc. IOT device
(Machine) like sensors and actuators then understands input, analyses it and responds
back to human by means of text or Visual Display. This is very useful as these machines
assist humans in every everyday tasks. It is a combo of software and hardware that
includes human interaction with a machine to perform a task.

H2M communication

Merits: This H2M has a user-friendly interface that can be quickly accessed by following
the instructions. It responds more quickly to any fault or failure. Its features and
functions can be customized.
Examples:
 Facial recognition.
 Bio-metric Attendance system.
 Speech or voice recognition.
2. Machine to Machine (M2M):
The process of exchanging information or messages between two or more machines or
devices is known as Machine to Machine (M2M) communication.
25
It is the communication among the physical things which do not need human intervention.
M2M communication is also named as Machine Type communication in 3GPP(3rd
Generation Partnership Project).
In this the interaction or communication takes place between machines by automating
data/programs. In this machine level instructions are required for communication. Here
communication takes place without human interaction. The machines may be either
connected through wires or by wireless connection. An M2M connection is a point-to-
point connection between two network devices that helps in transmitting information
using public networking technologies like Ethernet and cellular networks. IoT uses the
basic concepts of M2M and expands by creating large “cloud” networks of devices that
communicate with one another through cloud networking platforms.

M2M communication

Advantages –
This M2M can operate over cellular networks and is simple to manage. It can be used
both indoors and outdoors and aids in the communication of smart objects without the
need for human interaction. The M2M contact facility is used to address security and
privacy problems in IoT networks. Large-scale data collection, processing, and security
are all feasible.
Disadvantages –
However, in M2M, use of cloud computing restricts versatility and creativity. Data
security and ownership are major concerns here. The challenge of achieving
interoperability between cloud/M2M IoT systems is daunting. M2M connectivity
necessitates the existence of a reliable internet connection.
Examples:
 Smart Washing machine sends alerts to the owners’ smart devices after
completion of washing or drying of clothes.
 Smart meters tracks amount of energy used in household or in companies and
automatically alert the owner.
3. Machine to Human (M2H) :
In this machine interacts with Humans. Machine triggers information(text
messages/images/voice/signals) respective / irrespective of any human presence. This type
of communication is most commonly used where machines guide humans in their daily
life. It is way of interaction in which humans co-work with smart systems and other
machines by using tools or devices to finish a task.

26
M2H communication

Examples:
 Fire Alarms
 Traffic Light
 Fitness bands
 Health monitoring devices
4. Human to Human (H2H) :
This is generally how humans communicate with each other to exchange information by
speech, writing, drawing, facial expressions, body language etc. Without H2H, M2M
applications cannot produce the expected benefits unless humans can immediately fix
issues, solve challenges, and manage scenarios.
The process of exchanging information
or messages between two or more people is known as human to human (H2H)
communication. This can be done through various means such as verbal,
non-verbal, or written communication.

H2H communication

For, communication of IoT devices many protocols are used. These IoT protocols are
modes of communication which give security to the data being exchanged between IoT
connected devices. Example bluetooth, wifi, zigbee etc.
BLUETOOTH:
Bluetooth is universal for short-range wireless voice and data communication. It
is a Wireless Personal Area Network (WPAN) technology and is used for exchanging data
over smaller distances. This technology was invented by Ericson in 1994. It operates in
the unlicensed, industrial, scientific, and medical (ISM) band from 2.4 GHz to 2.485 GHz.
Maximum devices that can be connected at the same time are 7. Bluetooth ranges up to 10
meters. It provides data rates up to 1 Mbps or 3 Mbps depending upon the version. The
spreading technique that it uses is FHSS (Frequency-hopping spread spectrum). A

27
Bluetooth network is called a piconet and a collection of interconnected piconets is
called scatternet.

What is Bluetooth?

Bluetooth simply follows the principle of transmitting and receiving data using radio
waves. It can be paired with the other device which has also Bluetooth but it should be
within the estimated communication range to connect. When two devices start to share
data, they form a network called piconet which can further accommodate more than five
devices.
Points to remember for Bluetooth:
 Bluetooth Transmission capacity 720 kbps.
 Bluetooth is Wireless.
 Bluetooth is a Low-cost short-distance radio communications standard.
 Bluetooth is robust and flexible.
 Bluetooth is cable replacement technology that can be used to connect almost
any device to any other device.
 The basic architecture unit of Bluetooth is a piconet.

ZIGBEE:
ZigBee is a Personal Area Network task group with low rate task group 4. It is a
technology of home networking. ZigBee is a technological standard created for
controlling and sensing the network. As we know that ZigBee is the Personal Area
Network of task group 4 so it is based on IEEE 802.15.4 and is created by Zigbee
Alliance.
ZigBee is an open, global, packet-based protocol designed to provide an easy-to-use
architecture for secure, reliable, low power wireless networks. Flow or process control
equipment can be place anywhere and still communicate with the rest of the system. It can
also be moved, since the network doesn’t care about the physical location of a sensor,
pump or valve.
IEEE802.15.4 developed the PHY and MAC layer whereas, the ZigBee takes care of
upper higher layers.
ZigBee is a standard that addresses the need for very low-cost implementation of Low
power devices with Low data rates for short-range wireless communications.
IEEE 802.15.4 supports star and peer-to-peer topologies. The ZigBee specification
supports star and two kinds of peer-to-peer topologies, mesh and cluster tree. ZigBee-
compliant devices are sometimes specified as supporting point-to-point and point-to-
multipoint topologies.

28
Why another short-range communication standard??

Features of Zigbee:

1. Stochastic addressing: A device is assigned a random address and announced.


Mechanism for address conflict resolution. Parents node don’t need to maintain assigned
address table.
2. Link Management: Each node maintains quality of links to neighbors. Link quality is
used as link cost in routing.
3. Frequency Agility: Nodes experience interference report to channel manager, which
then selects another channel
4. Asymmetric Link: Each node has different transmit power and sensitivity. Paths may
be asymmetric.
5. Power Management: Routers and Coordinators use main power. End Devices use
batteries.
Advantages of Zigbee:
1. Designed for low power consumption.
2. Provides network security and application support services operating on the top
of IEEE.
3. Zigbee makes possible completely networks homes where all devices are able
to communicate and be
4. Use in smart home
5. Easy implementation
6. Adequate security features.
7. Low cost: Zigbee chips and modules are relatively inexpensive, which makes it
a cost-effective solution for IoT applications.
8. Mesh networking: Zigbee uses a mesh network topology, which allows for
devices to communicate with each other without the need for a central hub or
router. This makes it ideal for use in smart home applications where devices
need to communicate with each other and with a central control hub.
9. Reliability: Zigbee protocol is designed to be highly reliable, with robust
mechanisms in place to ensure that data is delivered reliably even in adverse
conditions.
Disadvantages of Zigbee :

29
1. Limited range: Zigbee has a relatively short range compared to other wireless
communications protocols, which can make it less suitable for certain types of
applications or for use in large buildings.
2. Limited data rate: Zigbee is designed for low-data-rate applications, which
can make it less suitable for applications that require high-speed data transfer.
3. Interoperability: Zigbee is not as widely adopted as other IoT protocols, which
can make it difficult to find devices that are compatible with each other.
4. Security: Zigbee’s security features are not as robust as other IoT protocols,
making it more vulnerable to hacking and other security threats.

GSM:
GSM stands for Global System for Mobile Communication. GSM is an open and
digital cellular technology used for mobile communication. It uses 4 different frequency
bands of 850 MHz, 900 MHz, 1800 MHz and 1900 MHz . It uses the combination of
FDMA and TDMA. This article includes all the concepts of GSM architecture and how it
works.
GSM is having 4 different sizes of cells are used in GSM :
1. Macro : In this size of cell, Base Station antenna is installed.
2. Micro : In this size of cell, antenna height is less than the average roof level.
3. Pico : Small cells’ diameter of few meters.
4. Umbrella : It covers the shadowed (Fill the gaps between cells) regions.
Features of GSM are :
1. Supports international roaming
2. Clear voice clarity
3. Ability to support multiple handheld devices.
4. Spectral / frequency efficiency
5. Low powered handheld devices.
6. Ease of accessing network
7. International ISDN compatibility.
8. Low service cost.
9. New features and services.
GSM security:
 GSM offers several security using confidential information stored in the AUC
and in the individual SIM.
 The SIM stores personal secret data and is protected with a pin against
unauthorized use.

Advantages:

Compatibility: GSM is widely used around the world, so it is compatible with many
different networks and devices.
Security: GSM offers enhanced security features such as authentication, encryption and
confidentiality, which helps to protect the user’s privacy and data.
Efficient use of bandwidth: GSM uses a time-division multiplexing (TDM) technique
which enables many users to share the same frequency channel at different times, making
it an efficient use of the available bandwidth.
Roaming: GSM allows users to roam internationally and use their mobile phones in other
countries that use the same GSM standard.

30
Wide range of features: GSM supports a wide range of features, including call
forwarding, call waiting, voicemail, conference calling, and more.

Disadvantages:

Limited coverage: GSM networks may have limited coverage in some remote areas,
which can make it difficult for users to make calls or access the internet.
Network congestion: GSM networks may become congested during peak hours, which
can lead to dropped calls or poor call quality.
Security vulnerabilities: Although GSM offers enhanced security features, it is still
vulnerable to certain types of attacks, such as eavesdropping and spoofing.
Data transfer speed: GSM networks offer relatively slow data transfer speeds compared
to newer technologies such as 3G and 4G.
Limited capacity: GSM networks have a limited capacity for handling large volumes of
data, which can be a disadvantage for users who require high-speed internet access or
other data-intensive applications.

Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

31
7. INTRODUCTION TO RASPBERRY PI PLATFORM AAND PYTHON
PROGRAMMING

Aim:
To study about Raspberry PI platform and python programming

Description:
Raspberry Pi is a credit-card sized, single-board computer developed by
the Raspberry Pi Foundation, a UK-based charity that works to ensure global
access of computing and digital technology. It was initially developed as a low-cost
microcomputer to impart digital skills to kids. It comes without any power supply or
peripherals as it’s meant to be programmed in Python (hence, the “Pi” in its name).

Raspberry Pi (RPi) is not the only single-board computer but it’s


currently the most popular. It offers several features, including:

 A powerful ARM processor


 Ethernet
 Onboard Wi-Fi and Bluetooth
 HDMI ports
 DSI display port
 CSI camera port
 Stereo audio and composite video port
 USB ports
 A 40-pin GPIO header

RPi is an all-in-one package that can be used for desktop programming,


networking, web development, embedded systems programming, the Internet of
things (IoT), robotics, automation — and for anything that falls within a desktop,
server, or embedded domain. It can run any Debian-based Linux distribution, as well
as Wind

What can RPi be used for?


Raspberry Pi is a low-power, general-purpose microcomputer built on a single board.
The board includes its processor, GPU, RAM, and input/output peripherals. It also
offers several unique hardware features that can be used for multiple applications,
which are independent of any computing domain (desktop, mobile, server, or
embedded), operating system, or programming language.

different types of apps on Raspberry Pi. Any general-purpose application on any


programming language can be developed on an RPi computer.

The 40-pin GPIO header (of which 28 are available) on the tiny RPi board can be
used to interface sensors and actuators for embedded systems programming, robotics,
32
and automation. The advantage of using Raspberry Pi for embedded systems: it will
have an operating system running on it. This allows for complex embedded
applications that may require sophisticated software. Another plus: embedded scripts
or apps can be easily be upgraded or developed to upgrade when necessary via an
Internet connection.

Operating systems
It’s possible to run any Debian-based Linux distribution on Raspberry Pi as well as
Windows or Android. However, Raspbian is the official Linux distribution that’s
developed and maintained by the Raspberry Pi Foundation.

Other popular Linux distributions that can be run on RPi include Ubuntu, Kali Linux,
CentOS, Arch Linux ARM, Gentoo, openSUSE, OSMC, OpenMediaVault,
Recalbox, RetroPie, Lakka, and many others.

Programming languages
Python is the primary programming language on Raspberry Pi. Scratch is another
primary language available on RPi that can be used for basic computing. There is no
limitation on the use of any programming language on the RPi board. Any
programming language that is supported by the operating system running on it can be
used for software development. Other popular programming languages that can be
used on Raspberry Pi include C, C++, Java, HTML5, JavaScript, JQuery, Pearl,
Erlang, etc.

Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

33
EXP NO 8 : MEASURING DISTANCE USING ARDUINO AND
ULTRASONIC SENSORS

AIM :
To measure the distance of an object using Ultrasonic Sensors and Arduino.
Components Required:

Circuit Diagram:

34
Code:
#include <LiquidCrystal.h> // includes the LiquidCrystal Library
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable,
d4, d5, d6, d7)
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;
void setup() {
[Link](16,2); // Initializes the interface to the LCD screen, and specifies the
dimensions (width and height) of the display
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;
[Link](0,0); // Sets the location at which subsequent text written to the LCD
will be displayed
[Link]("Distance: "); // Prints string "Distance" on the LCD
[Link](distanceCm); // Prints the distance value from the sensor
[Link](" cm");
delay(10);
[Link](0,1);
[Link]("Distance: ");
[Link](distanceInch);
[Link](" inch");
delay(10);
}

35
OUTPUT :

Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

36
[Link] 9. Communicate between Arduino and Raspberry PI
using any wireless medium

Aim:

To study about the communication between Arduino and Raspberry PI using any
wireless medium
Description:

1. Summary:

 This blog walks you through the process of how to communicate an Arduino
and a Raspberry Pi with nRF24L01 module. To Start off We will be learning Some
basics of Raspberry Pi then we will have a look at Headless Raspberry Pi setup. For
the Implementation firstly, we will understand the simple communication of Arduino
to Arduino then we will learn Arduino to the raspberry pi.

 I found many guides to accomplish this around the Internet, but none of them
was complete or fully worked for me. Here we will understand step by step guide of
this process. And at the end will be showing a working example for the same

2. Required Components:

 Ultrasonic Sensor

 2 Arduino Uno

 Raspberry Pi 3
37
 2 nRF24l01 transmitter and receiver

 Jump wires

 Arduino cable

 MINI USB 2.0 for Pi

 Breadboard

3. Required Software:

 Raspbian for pi

 Arduino IDE or Visual Studio

 Putty on a remote computer for SSH

 VNC viewer on a remote computer

4. Introduction to Raspberry Pi 3:

4.1. Components Specifications:

 1.4 GHz 64-bit quad-core ARM Cortex-A53, 1GB RAM


38
 2.4/5Ghz dual-band 802.11ac Wireless LAN, 10/100/1000Mbps Ethernet
Bluetooth 4.2

 4 USB ports, Full HDMI port, Combined 3.5mm audio jack and composite
video port, 40 GPIO pins

 Micro SD card slot, Video Core IV 3D graphics core, Camera interface (CSI),
Display interface (DSI)

4.2 Raspberry Pi Pinout:

4.3. Headless Raspberry Pi Setup:

 Say, I just bought a raspberry pi and wish to check out how it works. But all I
have is my Laptop, the Pi, a micro SD card, and my Wi-Fi network. How do I connect
and control the Pi?

1) Download Raspbian:

 Your Pi needs an OS. Download Raspbian from [Link] ‘s download


section:

 [Link]

39
2) Download SD Memory Card Formatter:

 It is used to format the SD card as it is needed that the SD card should be empty
before the flashing image you downloaded. You can download it
from [Link]

3) Flash it onto an SD card:

 You need to flash this downloaded image to the micro SD card. Assuming your
laptop has an SD card slot or a micro Sd card reader, you need a flashing software like
etcher. Go ahead and download from [Link]

40
4) Configure Wi-Fi:

 It’s easier to make two devices talk to each other if they are in the same
network. An ethernet cable can easily make your laptop’s network available to the Pi.
But we don’t have one. So, we are going to add a file to the SD card so that the Pi
boots with a wifi pre-configured.

 The SD card mounts as two volumes boot and rootfs . Open the boot volume
and create a file named wpa_supplicant.conf on booting the RPi, this file will be
copied to /etc/wpa_supplicant directory in /rootfs partition. The copied file tells the Pi
the WIFI setup information. This would overwrite any existing WIFI configuration,
so if you had already configured WIFI on the pi, then that will be overwritten.

 A typical wpa_supplicant.conf file is as follows:


ctrl_interface=DIR=/var/run/wpa_supplicant
GROUP=netdevupdate_config=1country=US
network={ ssid="«your_SSID»" psk="«your_PSK»" key_mgmt=WPA-PSK}

NOTE: Your SSID is your WIFI’s name. And psk is the password of the WI-FI.

5) Enable SSH

 We will later access the Pi using a secured shell (SSH), SSH is disabled by
default in Raspbian. To enable SSH, create a file named ssh in the boot partition. If
you are on Linux, use the touch command to do that.

41
6) Find Pi’s Ip address:

 Before switching on your raspberry pi, we need to find out the existing devices
connected to the network. Make sure your laptop is connected to the same WIFI
network as the one you configured on pi above.

 Download the Advanced IP Scanner to scan the IP of our raspberry pi. You can
download it from here [Link]

7) SSH into your Pi:

 To create a secured shell connection in Linux we can use the ssh command. If
you are on windows, try downloading Putty from [Link]

42
Default credentials are:
username: pipassword: raspberry

8) Access Pi remotely:

 Sometimes it doesn’t feel right if we can’t use the mouse. For that, we need to
look into the Raspbian desktop.

 We need to setup VNC (Virtual Network Connection) to see and control Pi


graphically. Let’s do that.

43
 To access the remote desktop, you need VNC-viewer (client) for your laptop.
Fortunately, RealVNC is available for a lot of OSes, pick one for your OS
from [Link]

9) Commands for vnc server:

10) Now open VNC Viewer on your remote computer:

44
5. Implementation and Working:

5.1. Wireless communication of Arduino to Arduino with nRF24L01:

 In this, we will learn how to make wireless communication between two


Arduino boards using the NRF24L01. And measure distance with ultrasonic sensor
and transmit it to another Arduino with transceiver module.

Wiring Instructions:

To wire your NRF24L01+ wireless Sender to your Arduino, connect the following
pins:

 Connect the VCC pin to 3.3 Volts

 Connect the GND pin to ground (GND)

 Connect the CE pin to Arduino 9

 Connect the CSN pin to Arduino 10

 Connect the SCK pin to Arduino 13

 Connect the MOSI pin to Arduino 11

 Connect the MISO pin to Arduino 12

To wire your ultrasonic sensor to your Arduino, connect the following pins:

 Connect the VCC pin to Arduino 5Volts

 Connect the GND pin to ground (GND)

 Connect the Trig pin to Arduino 4

 Connect the Echo pin to Arduino 3

45
Schematic Diagram for wiring of Arduino Uno with ultrasonic sensor and NRF24L01

To wire your NRF24L01+ wireless sender to your Arduino, connect the following
pins:

 Connect the VCC pin to 3.3 Volts

 Connect the GND pin to ground (GND)

 Connect the CE pin to Arduino 9

 Connect the CSN pin to Arduino 10

 Connect the SCK pin to Arduino 13

 Connect the MOSI pin to Arduino 11

 Connect the MISO pin to Arduino 12

46
Schematic Diagram for wiring of Arduino Uno NRF24L01

NOTE: RF24 module is mandatory for the code to run so you can add the library
accordingly

 Start Arduino IDE then add the Downloaded Library from Here :

47
5.2. Code:

Sender Side code:

Receiver Side code:

Sending the Data

Receiving the data:

48
6. Wireless communication of Arduino to Raspberry Pi with nRF24L01:

6.1: Installation of RF24 Module on Raspberry Pi:

 It is the most important and foremost step for any Communication to work
between Arduino and Raspberry Pi as we have used RF24 library in Arduino for
communication so the same Library is needed on Pi.

 Further are the steps to which involve the installation of the Library. It took me
almost one week to install it as no clear idea about it is present.

=> Way to go:

1. Login to Raspberry Pi using Putty.

2. Go to the VNC server for GUI.

3. In the terminal type:


sudo raspi-config

49
Turn on SPI from Interfacing options in config

4. Reboot the Pi. In the terminal, type:


sudo reboot

5. In the terminal type:


sudo apt-get update

6. Download the [Link] file


from [Link] or Run this on terminal:
50
wget [Link]

7. Make it executable:
chmod +x [Link]

8. Run it and choose your options:

9. Run an example from one of the libraries:


cd rf24libs/RF24/examples_linux
make
sudo ./gettingstarted

Run Following Commands to run the program.

10. Further, if we want to run Python Programs for the same purpose, we can do this:

Running the Example Edit the pingpair_dyn.py example to configure the appropriate
pins per the above documentation:
nano pingpair_dyn.py

 Configure another device, Arduino or RPi with the pingpair_dyn example

 Run the example


sudo python pingpair_dyn.py

51
6.2. Wireless communication of Arduino to Arduino with nRF24L01:

 In this, we will learn how to make wireless communication between Arduino


and Raspberry Pi using the NRF24L01. And measure distance with an ultrasonic
sensor with the help of Arduino Uno and transmit it to Raspberry Pi and Data is
received.

Wiring Instructions:

To wire your NRF24L01+ wireless Sender to your Arduino, connect the following
pins:

 Connect the VCC pin to 3.3 Volts

 Connect the GND pin to ground (GND)

 Connect the CSN pin to Arduino 10

 Connect the CE pin to Arduino 9

 Connect the SCK pin to Arduino 13

 Connect the MISO pin to Arduino 12

 Connect the MOSI pin to Arduino 11


52
To wire your ultrasonic sensor to your Arduino, connect the following pins:

 Connect the VCC pin to Arduino 5Volts

 Connect the GND pin to ground (GND)

 Connect the Trig pin to Arduino 4

 Connect the Echo pin to Arduino 3

Schematic Diagram:

Schematic Diagram for wiring of Arduino Uno with ultrasonic sensor and NRF24L01

To wire your NRF24L01+ Wireless Receiver to your Raspberry Pi, connect the
following pins:

 Connect the VCC pin to 3.3 Volts (Pin 1)

 Connect the GND pin to ground (GND) (Pin 6)

53
 Connect the CE pin to Raspberry GPIO 22

 Connect the CSN pin to Raspberry GPIO 8

 Connect the SCK pin to Raspberry GPIO 11

 Connect the MOSI pin to Raspberry GPIO 10

 Connect the MISO pin to Raspberry GPIO 09

Schematic Diagram:

Schematic Diagram for wiring of Raspberry Pi and NRF24L01

6.3. Code:

Sender Side Code:

Receiver Side Code:

54
 It's not mandatory to use this code as it is tweaked by me as per my
requirement.

To check the proper functioning of your connection and code you can run the
examples present in the library like pingpair_dyn.ino on your Arduino and
pingpair_dyn.py on Raspberry Pi

 The snippet of my running communication:

55
Conclusion: It will be always fun experimenting and playing with the IoT Devices
such as learning about Headless Raspberry Pi set-up, Arduino, and Raspberry pi by
making them communicating with each other and sending data and to overcome the
errors and challenges like one I faced while installing RF24 module. The purpose of
this tutorial is to serve you with a step-by-step process and hope that it was easy to
follow and learn as well.

Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

56
[Link] 10. SETUP A CLOUD PLATFORM TO LOG THE DATA

Aim:

To setup a cloud platform to log the data


STEPS INVOLVED:
Step 1: Prepare Raspberry Pi

57
1. Download the operating system for RPi. I recommend a full version of
Raspbian, like this here .
2. Assume that you have a working computer running on Windows, download
Rufus software to write the image to the SD card. Scroll down and get rufus
3.0 (June 2018)
3. Unzip Raspbian file (4.6 GB), and carefully select your target SD card. It takes
about 3 minutes to complete writing the image to the card.
4. Insert the SD card the slot, plug in power cable to the micro USB port, a
Display with HDMI cable, a keyboard, a mouse is optional.
5. Wait until the RPi boot up and show the desktop, press Window key, go to
Accessories/Terminal and Enter.
6. Configure RPi by type:

sudo raspi-config
7. Change couple of thing in RPi configuration:

58
 In 1. Change password

 In 2. Network Option: Change hostname (something unique, mine is rpi1001),


and wifi SSID and password.

 In 4. Locatisation Options: Change Timezone, Keyboard, locale


 In 5. Interfacing Options: Enable SSH (to log in via command line), Enable
VNC (for desktop remote)
 In 7: Advance Option: Expand Filesystems:
 Reboot
 After booting up: note IP address by running

sudo ifconfig
If Ethernet is using, the IP should the be first block, if Wifi is used, the IP is on the
third block, something like [Link], run this command to update the Linux
distro:

sudo apt-get update && sudo apt-get upgrade –y && sudo poweroff
The last one will power off the RPi after done with the updates

8. If you forgot the note the IP of RPi, or it is changed recently, use PowerShell (type
PowerShell to search box in Windows)

In PowerShell to ping the Rpi: ping [Link] –4 get something like this
[Link]. rpi1001 is my hostname for my Rpi.

9. Install VNCViewer , this software works like TeamViewer, or Desktop Remote on


Windows (only Win 10 Pro has Desktop Remote feature).

Install on your Windows machine, in the search box on the top of VNCViewer, type
in the RPi’s IP ([Link]) or RPi’s hostname (mine is [Link]) and Enter.
Enter your name RPi’s password, select ‘Remember password’ if desired so. If
everything went well, you should see the pop-up Rpi desktop.

10. To transfer file from or to TeamView, the simplest way to use built-in file
transfer by VNCView:

And that it, you can use a Raspberry to collect data for you, and log in to get data
when needed.

59
Add TipAsk QuestionCommentDownload
Step 2: Prepare Simple Example to Collect Data From Arduino

Let say you want to collect the temperature from 4 sensors. In this example, I used
18B20, a popular temperature sensor. Other options are the TMP35,36 family or a
thermistor.

60
The wiring is included above. The 18B20s share the wire (or bus), and here is the
Arduino code on Github. The attachment in below file contains the codes and wiring
map as well.

Also, install the USB driver for Arduino in Windows. Most ‘clone’ Arduino use
CH341 USB driver. The driver is here.

Install driver, when plugging the Arduino to your Windows’ USB, it should
recognize the driver and assign a COM port (mine is COM4)

The Serial Monitor should output like the photo above.

Add TipAsk Question Comment Download


Step 3: Boot Up RPi by Unplug and Plug Power to RPi. Start VNCViewer, Log in
Your RPi

61
 to install python Serial, type this line to Linux terminal

sudo apt-get install python3-serial

 in Windows: type this PowellShell:


 [Link] install pyserlal

Then download the script and save it to the RPi's desktop

To run the script, first make it executable by:

sudo chown u+x [Link]


Upload the Arduino code to the Arduino board, then plug your USB cable with USB
into, check the port by:

 On Linux, type this to the terminal: ls /dev/ttyUSB*


 On Wndows: go to Device Manager, check COM #

If the script is modified on Windows, you may need to run the Python script
to dos2unix to remove weird line ending character by Windows. Install it by

sudo apt-get install dos2unix

62
, and convert the script by running this in the terminal

dos2unix [Link]
Modified the actual port in the script by a text editor:

sudo nano [Link]


then run ./[Link] [Link]
The Python script will save the data from the RAM to the disk for every 10 lines,
which can be adjusted.

To stop recording, press Ctrl + C,

The script can be run on Windows (double click), the name of log data is the default
which includes a timestamp

If you PowerShell, you could enter your customized filename,

[Link] [Link] [Link]


Not all 18B20s are the same. See the readout!

I pushed the code to GitHub as well.

Hope this tutorial is helpful!

Attachments

 script_code.rar
Download
Add TipAsk QuestionCommentDownload

63
Step 4: Install Samba to Share Folder

3 More Images
This step will walk you through some basic setup to have a shared folder hosted on
Raspberry Pi that can be accessed to from other computers.

First, install samba, a program to share and manage sharing folder across the
network:

sudo apt-get install samba

64
make a shared folder

mkdir ~/Desktop/sambaShare
modify the configuration file for the samba by:

sudo samba /etc/samba/[Link]


add the following lines to the end of the file:

[sambaShare]<br> comment = share Folder on Research RPI


path = /home/pi/Desktop/sambaShare
browseable = yes
read only = no
writable = yes
public = yes
create mask = 0777
rectory mask = 0777
guest ok = yes
If you have the problem with writing on windows, force it by adding this line to the
end of the file: force user = pi

sudo smbpasswd -a pi
then enter a password for the samba (can be the same or different than the password
for pi user on the system)

test if the config file is okay

testparm
press Ctrl+X to save, and then restart samba service by:

sudo systemctl restart smbd


On the host computer, let say Linux:

if not yes install samba plus sambaclient, and cifs to support the share drive, please
do so by running:

sudo apt-get installs samba smbclient cifs-utils


Check if the shared folder on RPI is ready by:

65
sudo smbclient -L yourRPI_IP
if you see the share drive, then create a mount point on Linux:

sudo mkdir /mnt/researchRPi


sudo chown user:usergroup -R /mnt/researchRPI
user, usergroup is your Linux user and group name

then mount the share by:

sudo mount -f cifs -o username=pi //your_rpi_IP/sambaShare /mnt/researchRPi


enter your passwords, and make a soft link to your desktop:

sudo ln -s /mnt/researchRPi ~/Desktop/researchRPi


if you have problem with read-write permission on the share folder, experiment with
a weak permission:

on PI:

sudo chmod -R 776 ~/Desktop/sambaShare


On Windows, it is even easier,

Go to My Computer, and map a folder, then enter the IP of RPI, the shared folder
should appear. I believe there is something on Mac that you can browse the shared
folder on the network.

Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

66
[Link] 11. Log Data using Raspberry PI and upload to the cloud platform

AIM:

To Log Data using Raspberry PI and upload to the cloud platform

Descripton:
The software running on Raspberry Pi is like any (production) system which
benefits from proper logs. Logs are crucial to debugging, monitoring, alerting, and
just keeping the systems up and running without interruptions. Depending on your
setup, you might have several Raspberry Pis (other any IoT devices) so the logs from
all the devices need to be aggregated and accessible in a single place.

There are many alternatives for centralized logging and Google Cloud Logging
is one of the options. But why choose it? Well, it’s practically free at least on a small
scale and it provides centralized logging with easy integration. You can also easily
create log-based metrics and alerts based on these which provides visibility to your
devices.

Create a service account

First, you need to create a service account to allow writing the logs from Raspberry
Pi. You can create the service account from GCP
console: [Link] The “Log Writer”
permissions are needed at least.

Once the service account is ready, you need to create a new key and download it as a
JSON file. This file contains the authentication credentials for the logging driver and
you need to provide the JSON file to it by setting the
GOOGLE_APPLICATION_CREDENTIALS environment variable. I’m running the
application using Docker, so the easiest way to configure Docker using systemd.
Many Linux distributions use systemd to start the Docker daemon so you can override
the environment variables by adding configuration file to
/etc/systemd/system/[Link].d/.

Example: /etc/systemd/system/[Link].d/[Link]:
67
[Service]
Environment="GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-
[Link]"

This will pass the correct environment variable for all the Docker containers and to
the logging driver. Remember to restart the Docker after this:
sudo systemctl daemon-reload
sudo systemctl restart docker

Using the Google Cloud Logging driver

There are different ways of uploading the logs to GCP. An easy way is to use the
Google Cloud Logging driver which can set as a default logging driver for the Docker
containers. You can do it with the --log-driver option:
docker run --log-driver=gcplogs ...

Or just by adding the following JSON to/etc/docker/[Link] so this logging


driver will be used by all the Docker containers.
{
"log-driver": "gcplogs",
"log-opts": {
"gcp-meta-name": "10000000c8ac179f",
"gcp-project": "my-gcp-project",
"mode": "non-blocking",
"max-buffer-size": "2m"
}
}

gcp-meta-name specifies the name of the instance where the logs are coming from. If
you have multiple Raspberry Pi devices sending logs to the same log bucket, you can
use Raspberry Pi’s serial number to differentiate the devices. Run the following
command on Raspberry Pi and add the output as gcp-meta-name.
cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2

Using Fluentd

Another way is to use Fluentd, which can forward the logs to various places,
including to Google Cloud Logging.
68
Setting up Fluentd requires a bit more work though. I decided to build a separate
Docker image for Fluentd which contains the necessary configurations.

I’m using the ARMv7 specific image of Fluentd as the base image and install fluent-
plugin-google-cloud output plugin to it. This plugin allows pushing the logs to Cloud
Logging API.

I also got plenty of permission issues with the Fluentd plugins unless I gave updated
permission to all of them. Didn’t really understand why this happens but changing the
file permissions to 644 fixed the issue.
FROM fluent/fluentd:v1.11.2-debian-armhf-1.0USER rootRUN apt-get update
RUN apt-get install -y make gcc g++ libc6-dev ruby-dev libffi-dev \
ca-certificates \
liblz4-1 \
rubyRUN echo 'gem: --no-document' >> /etc/gemrc
RUN gem install fluent-plugin-google-cloud -v 0.6.25.1RUN chmod 644
/usr/local/bundle/gems/fluent-plugin-google-cloud-[Link]/lib/fluent/plugin/*.rbCOPY
./config/fluent/[Link] /fluentd/etc/[Link] fluent

The configuration file is quite simple. I’m also using the JSON filter plugin as the
applications are logging everything as JSON.
<source>
@type forward
port 24224
bind [Link]
</source><filter **>
@type parser
key_name log
reserve_data true
<parse>
@type json
</parse>
</filter>
<filter **>
@type add_insert_ids
</filter><match **>
@type google_cloud
enable_metadata_agent false
vm_id "<GCP_PROJECT_ID>"

69
zone "<GCP_ZONE>"
split_logs_by_tag false
use_metadata_service false
detect_json true buffer_type file
buffer_path /fluentd/log/[Link]
buffer_queue_full_action block num_threads 2
use_grpc true
</match>

The docker-compose files starts the application container(s) and the Fluentd instance.
services:
fluentd:
image: myfluentimage
container_name: fluentd
ports:
- "24224:24224" mycontainer:
image: mycontainer
container_name: mycontainer
depends_on:
- fluentd
logging:
driver: fluentd
options:
fluentd-address: [Link]:24224
fluentd-async-connect: "true"

There you go! Logs are automatically uploaded from the Raspberry Pi and available
on GCP:

70
Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

71
[Link] 12: Design an IoT Based System

AIM :
Task: A LED and a piezo speaker are supposed to blink or beep continuously

ALGORITHM:
1. Initialize the LED and piezo speaker pins as OUTPUT.
2. Enter a loop that runs indefinitely (the main loop).
3. Inside the main loop:
a. Turn ON the LED.
b. Generate a beep on the piezo speaker.
c. Wait for a specific duration (blink and beep time).
d. Turn OFF the LED.
e. Stop the piezo speaker sound.
f. Wait for a specific duration (the interval between blinks and beeps).
g. Go back to step 3 (repeat the loop).
COMPONENTS REQUIRED:
Required equipment: Microcontroller / one LED / resistor with 200 Ohm /
Breadboard / piezo speaker / cables
Setup:

72
CODE :
int LED=4; //this time we also going to use the first part of the program. Here
//we are going to put in variables. This means that there will be a letter or a
//word standing for a number. In this example the LED is connected to pin 4 and
//the speaker to pin 5, so we rename pin 4 and pin 5, to avoid confusion. The
//word “LED” now stands for the number 4 and the word “beep” for the number 5.
int beep=5;
void setup()
{ //We are starting with the setup
pinMode(LED, OUTPUT); //pin 4 (pin “LED”) is supposed to be an output
pinMode(beep, OUTPUT); //Pin 5 (pin “beep”) is supposed to be an output
}
void loop()
{ //The main part starts
digitalWrite(LED, HIGH); //turn on the LED
digitalWrite(beep, HIGH); //turn on the speaker
delay(1000); //wait for 1000 milliseconds (sound and light)
digitalWrite(LED, LOW); //turn off the LED
digitalWrite(beep, LOW); //turn off the speaker
delay(1000); //wait for 1000 milliseconds (no sound and no light)
} //Here at the end of the loop the program starts again from the beginning of
//the loop. So it will beep and light up again. If you change the break (delay)
//it will be either beep and light up faster or slower.

Evaluation Details Marks allotted Marks Scored

Preparation

Observation

Record

Viva-voce

Total

RESULT:

73

You might also like