0% found this document useful (0 votes)
249 views125 pages

ESIOT Lab Manual - 240503 - 132515

The document provides information about the syllabus for the course CS3691 - Embedded Systems and IoT Laboratory. It includes details like course objectives, regulations, vision and mission statements of the institution and department, program outcomes, program educational objectives, course outcomes and mapping with program outcomes. The document also contains general instructions for students in the laboratory.

Uploaded by

rolexman398
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)
249 views125 pages

ESIOT Lab Manual - 240503 - 132515

The document provides information about the syllabus for the course CS3691 - Embedded Systems and IoT Laboratory. It includes details like course objectives, regulations, vision and mission statements of the institution and department, program outcomes, program educational objectives, course outcomes and mapping with program outcomes. The document also contains general instructions for students in the laboratory.

Uploaded by

rolexman398
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
You are on page 1/ 125

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CS3691-EMBEDDED SYSTEMS AND IOT

FOR VI SEMESTER B.E. DEGREE COURSE

[REGULATION-2021]

As per the prescribed syllabus by

ANNAUNIVERSITY

CHENNAI-600025
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

LABORATORY MANUAL

SUBJECT CODE : CS3691

SUBJECT NAME : EMBEDDED SYSTEM & IOT

REGULATION : 2021

ACADEMIC YEAR : 2023 – 2024

YEAR/SEMESTER : III/VI

BATCH : 2021- 2025

Prepared by: Verified by: Approved by:


Name: Name: Name:
Date: Date: Date:

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VISION AND MISSION OF THE INSTITUTION

VISION

Emerge as a premier institute producing globally competent engineers.

MISSION

1. Achieve academic diligence through effective and innovative teaching – learning


processes using ICT tools

2. Make students employable through rigorous career guidance and training programs.

3. Strengthen Industry Institute Interaction through MOUs and collaborations.

4. Promote Research & Development by inculcating creative thinking through


innovative projects incubation.

VISION AND MISSION OF THE DEPARTMENT

VISION

To develop competent Computer Science Engineers, capable of meeting the challenges


in the globalized technological society.

MISSION

DM 1: To provide good quality academic and infrastructure environment that would


help the students acquire deep knowledge and skills in Computer Science and
Engineering.

DM 2: To prepare students for careers in IT Industry, encourage Entrepreneurship and


mould them to take leadership for the betterment of the society.

DM 3: To produce competent graduates with human values, for carrying out research in
cutting edge technologies in Computer Science and Engineering.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM EDUCATIONAL OBJECTIVES (PEOS)
PEO 1: Prospective Career: To exhibit knowledge and skills in the various domain
areas of Computer Science and Engineering with an awareness in different disciplines
for a prospective career and to undertake novel research as per the needs of the society,
government and industries.

PEO 2: Higher Education: To be strong in fundamentals of Computer Science and


Engineering
for successfully pursuing higher education and research in reputed institutions.

PEO 3: Product Development: To apply their knowledge and innovative ideas to design
and develop products in interdisciplinary areas for real time problems and to emerge as
entrepreneurs

PROGRAMME SPECIFIC OUTCOME (PSOs)


PSO 1: Able to analyze and develop solutions to complex engineering problems in IT
such as Operating Systems, Networks, Data Structure, Database Management Systems,
Cloud Computing and Mobile computing, to meet the society and industrial needs.

PSO 2: Able to solve the industry problems with knowledge in recent technology and
tools such as Machine Learning, Internet of Things, Oracle, Java Programming etc with
good team skills and ethical values.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
.PROGRAM OUTCOMES (POS)

PO 1 Engineering knowledge: Apply the knowledge of mathematics, science,


engineering fundamentals, and an engineering specialization to the solution of
complex engineering problems.
PO 2 Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences.
PO 3 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
PO 4 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.
PO 5 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.
PO 6 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 practice.
PO 7 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.
PO 8 Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
PO 9 Individual and Team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.
PO 10 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.
PO 11 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.
PO 12 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.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
COURSE OBJECTIVE

The student should be made to:

 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

COURSE OUTCOME

At the end of this course, the students will be able to:

CO1: Understand and apply the fundamentals of assembly level programming and ALU operations

CO2: Apply skills to conduct interfacing of embedded boards with components, actuators and
sensors
CO3: Implementation of IoT using Raspberry Pi & Python Programming.

CO4: Develop Programming skills in embedded systems for various applications.

CO5: Design IOT device and systems using cloud storage.

CO-PO&PSO MAPPING

PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO1 3 1 2 1 1 2 3 1

CO2 3 1 2 1 2 2 2 1

CO3 3 2 3 1 2 2 2 2

CO4 3 2 2 1 2 2 2 2

CO5 3 2 3 1 2 2 2 2

Avg 3 2 2 1 2 2 2 2

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
GENERAL INSTRUCTIONS TO THE STUDENTS

1. No food or drink is to be brought into the lab, including gum and candy.

2. No cell phones or electronic devices at the lab stations (i pods, MP3 Players, etc.,).

3. Students must proceed immediately to their assigned position.

4. Students should maintain silence during the Lab session.

5. Students must inspect their position for possible damage and report immediately to the faculty any

damage that may be found.

6. Students must follow the faculty’s instructions explicitly concerning all uses of the lab equipment.

7. Leave your shoes in the shoes rack before entering into the lab.

8. Shut down the computer properly before leaving from the lab.

9. Do not bring college bag inside the lab.

10. Arrange your chairs properly before leaving from the lab.

11. Students must wear lab coat during lab session.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
SYLLABUS
CS3691 EMBEDDED SYSTEM AND IOT LABORATORY LTPC

0 0 3 1.5
COURSE OBJECTIVES:
 Learn the working of ARM processor
 Understand the Building Blocks of Embedded Systems
 Learn the concept of memory map and memory interface
 Write programs to interface memory, I/Os with processor
 Study the interrupt performance

LIST OF EXPERIMENTS:

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

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
COURSE OUTCOMES:

At the end of this course, the students will be able to:


CO1: Analyze the architecture, instruction set and programming of embedded processors.
CO2: Apply the concept of embedded C programming in embedded system devices and
understand the operating system concepts, types and choosing RTOS.

CO3: Understand the basic components and building blocks of Internet of Things and apply skills
to conduct interfacing of arduino boards with embedded components.

CO4: Apply the characteristics and high level requirements to design new IoT devices and
summarize different communication technologies and protocols of IoT.

CO5: Ability to implement real field problem by gained knowledge of Embedded Systems with
IoT applications using Arduino/Raspberry Pi /open platform.
.

LIST OF EXPERIMENTS – CO MAPPING


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

Topic Beyond The Syllabus


13 Interfacing Arduino to control stepper motor CO3, CO4
14 Interfacing flame sensor with Raspberry PI CO4, CO5

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
INDEX
Exp. Page Faculty
Date Experiment Marks
No. No. Signature

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 1 (a) 8051 ASSEMBLY LANGUAGE PROGRAM USING KEIL
Date SIMULATOR (ADDITION)

AIM:
To write 8051 Assembly Language Program for an 8-bit addition using Keil simulator and
execute it.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

THEORY:

A simulator is software that will execute the program and show the results exactly to the
program running on the hardware, if the programmer finds any errors in the program while
simulating the program in the simulator, he can change the program and re-simulate the code
and get the expected result, before going to the hardware testing. The programmer can
confidently dump the program in the hardware when he simulates his program in the
simulator and gets the expected results.
8051 controller is a most popular 8-bit controller which is used in a large number of
embedded applications and many programmers write programs according to their
application. So testing their programs in the software simulators is a way. Simulators will
help the programmer to understand the errors easily and the time taken for the testing is also
decreased. These simulators are very useful for students because they do need not to build the
complete hardware for testing their program and validate their program very easily in an
interactive way.

List of 8051 Simulators:


The list of simulators is given below with their features:
1. MCU 8051: MCU 8051 is an 8051 simulator that is very simple to use and has an
interactive IDE (Integrated Development Environment). It is developed by Martin Osmera
and most important of all is that it is completely free. There are many features for this IDE
they are

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
 It supports both C and assembly language for compilation and simulation
 It has an in-built source code editor, graphical notepad, ASCII charts, Assembly symbol
viewer, etc. It also supports several 8051 ICs like at89c51, A89S52, 8051, 8052, etc.
 It will support certain electronic simulations like LED, 7segment display, LCD etc. which
will help in giving the output when you interface these things to the hardware directly.
 It has tools like hex decimal editors, base converters, special calculator, file converters,
inbuilt hardware programmers, etc.
 It has syntax validation, pop base auto-completion etc.

2. EDSIM 51: This is a virtual 8051 interfaced with virtual peripherals like 7 segment display,
motor, keypad, UART etc. This simulator is exclusively for students developed by James
Rogers,. The features of this simulator are
 Have virtual peripherals like ADC, DAC with scope to display, comparator etc.
 Supports only assembly language
 IDE is completely written in JAVA and supports all the OS.
 Completely free and with user guide, examples, etc.

3. 8051 IDE: This simulation software is exclusively for the Windows operating system (98/xp).
The features of this simulator are
 Text editor, assembler, and software simulate in one single program.
 Has facilities like Breakpoint setter, execute to break point, predefined simulator watch
window, etc.
 It is available in both free version and paid version.

4. KEIL µVision: KEIL is the most popular software simulator. It has many features like
interactive IDE and supports both C and assembly languages for compilation and
simulation.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE:

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.8.

PROGRAM:

ORG 0000H
CLR C
MOV A,
#20HADD
A, #21H
MOV R0, A
END

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT:

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS:

1. What are the arithmetic instructions in microcontroller?


Arithmetic instructions are operations in computing that manipulate numerical values.
Common arithmetic instructions include addition, subtraction, multiplication, division,
increment, decrement, negation, absolute value, modulo and shifting.

2. How to perform higher byte arithmetic operations?


In the 8051 microcontroller, to perform higher byte arithmetic operations, typically use
the accumulator (ACC) and carry flag (CY) along with instructions such as ADDC (add with
carry) and SUBB (subtract with borrow). These instructions allows to handle multi-byte
arithmetic by carrying over the carry from lower bytes to higher bytes and vice versa, enabling
operations on multi-byte values.

3. What are the flags involved in addition?


Carry Flag (CY): Set if there's a carry-out from the most significant bit (MSB) during addition.
Overflow Flag (OV): Set if there's a signed overflow in the result (e.g., adding two positive
numbers and getting a negative result, or adding two negative numbers and getting a positive
result).
Auxiliary Carry Flag (AC): Set if there's a carry-out from bit 3 to bit 4 during addition, useful
for BCD (Binary Coded Decimal) arithmetic.

4. Compare add and increment instruction.


The "add" instruction performs addition between two operands, allowing for any value
to be added to another. The "increment" instruction specifically adds one to a single operand.
"Add" is more versatile, taking two operands, while "increment" is simpler, taking only one
operand and always adding one.

5. What is the function of stack pointer?


A stack pointer is a small register that stores the memory address of the last data element,
added to the stack or in some cases, the first available address in the stack.

RESULT:
Thus the 8051 Assembly Language Program for an 8-bit addition using Keil simulator was
executed successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 1(b) 8051 ASSEMBLY LANGUAGE PROGRAM USING KEIL
Date SIMULATOR (SUBTRACTION)

AIM:
To write 8051 Assembly Language Program for an 8-bit subtraction using Keil simulator and
execute it.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

THEORY:

A simulator is software that will execute the program and show the results exactly to the
program running on the hardware, if the programmer finds any errors in the program while
simulating the program in the simulator, he can change the program and re-simulate the code
and get the expected result, before going to the hardware testing. The programmer can
confidently dump the program in the hardware when he simulates his program in the
simulator and gets the expected results.
8051 controller is a most popular 8-bit controller which is used in a large number of
embedded applications and many programmers write programs according to their
application. So testing their programs in the software simulators is a way. Simulators will
help the programmer to understand the errors easily and the time taken for the testing is also
decreased. These simulators are very useful for students because they do need not to build the
complete hardware for testing their program and validate their program very easily in an
interactive way.

List of 8051 Simulators:


The list of simulators is given below with their features:
1. MCU 8051: MCU 8051 is an 8051 simulator that is very simple to use and has an
interactive IDE (Integrated Development Environment). It is developed by Martin Osmera
and most important of all is that it is completely free. There are many features for this IDE
they are

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
 It supports both C and assembly language for compilation and simulation
 It has an in-built source code editor, graphical notepad, ASCII charts, Assembly symbol
viewer, etc. It also supports several 8051 ICs like at89c51, A89S52, 8051, 8052, etc.
 It will support certain electronic simulations like LED, 7segment display, LCD etc. which
will help in giving the output when you interface these things to the hardware directly.
 It has tools like hex decimal editors, base converters, special calculator, file converters,
inbuilt hardware programmers, etc.
 It has syntax validation, pop base auto-completion etc.

2. EDSIM 51: This is a virtual 8051 interfaced with virtual peripherals like 7 segment
display, motor, keypad, UART etc. This simulator is exclusively for students developed by
James Rogers,. The features of this simulator are
 Have virtual peripherals like ADC, DAC with scope to display, comparator etc.
 Supports only assembly language
 IDE is completely written in JAVA and supports all the OS.
 Completely free and with user guide, examples, etc.

3. 8051 IDE: This simulation software is exclusively for the Windows operating system
(98/xp).The features of this simulator are
 Text editor, assembler, and software simulate in one single program.
 Has facilities like Breakpoint setter, execute to break point, predefined simulator watch
window, etc.
 It is available in both free version and paid version.

4. KEIL µVision: KEIL is the most popular software simulator. It has many features like
interactive IDE and supports both C and assembly languages for compilation and
simulation.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE:

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.8.

PROGRAM:

ORG 0000H
CLR C
MOV 40H,#87H
MOV 41H,#37H
MOV A,40H ; To subtract smaller no. from bigger no.
SUBB A,41H
MOV 60H,A
MOV A,41H ; To subtract bigger no. from smaller no.
SUBB A,40H
JC NEXT
SJMP OVER
NEXT: CPL A
ADD A,#01
MOV R0, #01 ; to indicate the no .is negative
MOV 62H,A
OVER: NOP
END

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT:

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS:

1. How to perform signed arithmetic in 8051 microcontroller?


To perform signed arithmetic in an 8051 microcontroller, use signed data types such as signed
integers and utilize arithmetic instructions like ADD and SUBB. Ensure to handle overflow conditions
properly, which are indicated by the overflow flag (OV).

2. What is the role of PSW in arithmetic operations?


The program status word register is a 8bit register. It is also referred to as the flag register.
Although the PSW register is 8 bits wide, only 6 bits of it are used by the 8051.

3. How can store a data in a memory location?


Data is stored in memory in a binary format, which means that it is represented by a series of
0s and 1s. Each 0 or 1 is called a bit, and a group of bits is called a byte. The number of bits in a byte
can vary, but most modern computers use 8 bits per byte.

4. What is the function of JNC instruction?


The JNC instruction transfers program control to the specified address if the carry flag is 0.
Otherwise, execution continues with the next instruction. No flags are affected by this instruction.

5. What is the difference between conditional and unconditional jump instruction?


Unconditional Jump Instructions: Transfers the program sequence to the described memory
address.
Conditional Jump Instructions: Transfers the program sequence to the described memory
address only if the condition in satisfied.

RESULT:
Thus the 8051 Assembly Language Program for an 8-bit subtraction using Keil simulator was
executed successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 2 TEST DATA TRANSFER BETWEEN REGISTERS AND
Date MEMORY

AIM:
To write and execute an Assembly language program to transfer data between registers and
memory.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

THEORY

Data transfer instructions are used to transfer data between an internal RAM location and
SFR location without going through the accumulator. Data can also be transferred between the
internal and external RAM by using indirect addressing. In the 8051 microcontroller architecture,
data transfer between registers and memory is essential for executing instructions and
manipulating data. The primary instructions for data transfer between registers and memory
include:
 MOV (Move) Instruction
 MOVC (Move Code) Instruction
 MOVX (Move External) Instruction
 PUSH and POP Instructions
 Direct and Indirect Addressing

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create a New Project Select Device for
the Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM:

TYPE-I:
ORG 0000H
CLR C
MOV R0, #55H
MOV R1, #6FH
MOV A, R0
MOV 30H, A
MOV A, R1
MOV 31H, A
END

OUTPUT:

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM:
TYPE-II:
ORG 0000H
CLR C
MOV R0, #30H
MOV R1, #40H
MOV R7, #06H
BACK: MOV A, @R0
MOV @R1, A
INC R0
INC R1
DJNZ R7, BACK
END

OUTPUT:

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS
1. How you can read a data from a memory location?
To read the data from a memory location,
 Specify the memory address where the data is stored.
 Fetch the content stored at that address.

2. What is meant by memory unit?


Memory is a storage device. Data and instruction entered in to a computer system through
input unit have to be stored inside the computer before actual processing starts.

3. What is meant by Register?


Registers are temporary storage area in micro controller It can hold a value of 1byte memory
space.

4. What are the various types of memories used in microcontroller/microprocessor?


 ROM - Read Only Memory
 RAM - Random Access Memory
 PROM - Programmable Read Only Memory
 EPROM - Erasable Programmable Read Only Memory
 EPROM - Electrically Erasable Programmable Read Only Memory

5. What is Special Function Registers (SFR)?


The 8051 provides 128 bytes of memory (80H to 0FFH) for Special Function Registers (SFRs).
SFRs are bit, byte, or word-sized registers that are used to control timers, counters, serial I/O, port I/O,
and peripherals.

RESULT
Thus the Assembly language program to transfer data between registers and memory was
executed successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 3
PERFORM ALU OPERATIONS
Date

AIM
To write and execute the Arithmetic and Logic Unit(ALU) program using the Keil simulator.

SOFTWARE TOOLS REQUIRED:

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

THEORY

ALU conducts arithmetic and logic operations. It is a major component of the CPU in a
computer system. An integer unit (IU) is just an integrated circuit within a GPU or GPU that performs
the last calculations in the processor. It can execute all arithmetic and logic operations, including
Boolean comparisons, such as subtraction, addition, and shifting (XOR, OR, AND, and NOT
operations). Binary numbers can also perform bitwise and mathematical operations. AU (arithmetic
unit) and LU (logic unit) are two types of arithmetic logic units. The ALU’s operands and code
instruct it on which operations to perform based on the incoming data. When the ALU has finished
processing the data, it sends the result to the computer memory.
Although the ALU is a critical component of the CPU, the design and function of the ALU
may vary amongst processors. Some ALUs, for example, are designed solely to conduct integer
calculations, whereas others are built to perform floating-point computations. Some processors have a
single arithmetic logic unit that performs operations, whereas others have many ALUs that conduct
calculations. ALU’s operations are as follows: 1. Arithmetic Operators: It refers to bit subtraction and
addition, despite the fact that it does multiplication and division. Multiplication and division processes,
on the other hand, are more expensive to do. Addition can be used in place of multiplication, while
subtraction can be used in place of division. 2. Bit-Shifting Operators: It is responsible for a
multiplication operation, which involves shifting the locations of a bit to the right or left by a
particular number of places. 3. Logical Operations: These consist of NOR, AND, NOT, NAND, XOR,
OR, and more.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM:

ORG 0000H
CLR C
//ADDITION
MOV A, #20H
ADD A, #21H
MOV 41H, A

//SUBTRACTION
MOV A, #20H
SUBB A, #18H
MOV 42H, A

//MULTIPLICATION
MOV A, #03H
MOV B, #04H
MUL AB MOV
43H, A

//DIVISION
MOV A, #95H
MOV B, #10H
DIV AB
MOV 44H, A
MOV 45H, B

//AND
MOV A, #25H
MOV B, #12H
ANL A, B
MOV 46H, A

//OR
MOV A, #25H
MOV B, #15H
ORL A, B
MOV 47H, A

//XOR
MOV A, #45H
MOV B, #67H

//NOT
MOV A, #45H
CPL A
MOV 49H, A
END

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS:

1. What are the addressing modes of 8051?


 Direct addressing
 Register addressing
 Register indirect addressing
 Implicit addressing
 Immediate addressing
 Index addressing
 Bit addressing

2. Why in the 8051 all arithmetic operations must use the accumulator?
Because the 8051 is an accumulator-based architecture, all arithmetic operations must use the
accumulator, e.g. ADD A, 020h will add the value in memory location 0x20 in the internal RAM to
the accumulator.

3. Define DA A?
This is a decimal adjust instruction It adjusts the 8-bit value in ACC resulting from operations
like ADD or ADDC and produces two 4-bit digits (in packed Binary Coded Decimal (BCD) format
Effectively, this instruction performs the decimal conversion by adding 00H, 06H, 60H or 66H to the
accumulator, depending on the initial value of ACC and PSW.

4. Define Logical EX OR?


This instruction performs the logical XOR (Exclusive OR) operation on the source and
destination operands and stores the result in the destination variable. No flags are affected.

5. Define RRC A instruction?


The instruction rotates the accumulator contents one bit to the right through the carry flag.
The original value of carry flag will move into Bit 7 of the accumulator and Bit 0 rotated into carry
flag. No other flags are affected If ACC=C3H (11000011), and the carry flag is 0, the instruction
results in ACC=61H (01100001) with the carry.

RESULT
Thus the Arithmetic and Logic Unit(ALU) program using the Keil simulator was executed
successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 4 (a)
WRITE BASIC PROGRAMS USING EMBEDDED C
Date

AIM
To write a basic embedded C program to control a port 0 pin connected to an 8051
microcontroller using a Keil simulator.

SOFTWARE REQUIRED

S.No Software Requirements Quantity


1 Keil μvision5 IDE 1

THEORY
Embedded C programming is the discipline of writing software for embedded systems using
the C programming language. Embedded systems are specialized computing systems designed to
perform dedicated functions within a larger system or product. They are typically constrained by
factors such as processing power, memory, and size, and are commonly found in a wide range of
devices including microcontrollers, sensors, industrial machines, consumer electronics, and more.

PROCEDURE

1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create a New Project Select Device for the
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM
#include<REG51.>

int i,j;
sbit LED = 2^0;
void main()
{
while(1)
{
LED = 0;
for(j=0;j<10000;j+ +);
LED = 1;
for(j=0;j<10000;j++);
}
}

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS
1. What is Embedded C Programming?
Embedded C is a programming language that is an extension of C programming. It uses the
same syntax as C and it is called “embedded” because it is used widely in embedded systems.
Embedded C supports I/O hardware operations and addressing, fixed-point arithmetic operations,
memory/address space access, and various other features that are required to develop fool-proof
embedded systems.

2. What is Void Pointer in Embedded C and why is it used?


Void pointers are those pointers that point to a variable of any type. It is a generic pointer as it
is not dependent on any of the inbuilt or user-defined data types while referencing. During
dereferencing of the pointer, we require the correct data type to which the data needs to be referenced.

3. What are the steps to build an Embedded C Program?


There are different steps involved in designing an embedded c program like the following.
 Comments
 Directives of Processor
 Configuration of Port
 Global variables
 Core Function/Main Function
 Declaration of Variable
 The logic of the Program

4. Differences between C Program and Embedded C Program.

C Language Embedded C Language

Generally, this language is used to develop Embedded C language is used to develop


desktop-based applications microcontroller-based applications.
It processes native development in nature It processes cross development in nature
The compilers of C language depends on the
operating system Embedded C compilers are OS independent
In C language, the standard compilers are used In embedded C language, specific compilers are
for executing a program used.
It is very easy to modify & read It is not easy to modify & read
Bug fixing is easy Bug fixing of this language is complicated

RESULT
Thus the basic embedded C program to control a port 0 pin connected to an 8051
microcontroller using a Keil simulator was executed successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 4 (b)
ARITHMETIC PROGRAMS USING EMBEDDED C
Date

AIM
To write an embedded C program for addition, subtraction, multiplication, and division
using the Keil simulator.

SOFTWARE REQUIRED

S. No Software Requirements Quantity


1 Keil μvision5 IDE 1

THEORY
Arithmetic programs using Embedded C are foundational components in the development of
embedded systems, which are specialized computing systems designed to perform dedicated tasks
within larger devices or systems. These programs implement mathematical operations such as
addition, subtraction, multiplication, and division, critical for a wide range of functionalities including
sensor data processing, control algorithms, and signal processing. Embedded C provides a framework
for implementing arithmetic operations efficiently, leveraging various data types like integers,
floating-point numbers, and fixed-point numbers. The choice of data type significantly impacts
arithmetic precision, memory usage, and computational efficiency. Integer arithmetic, favored for its
deterministic behavior and efficiency, is commonly employed in embedded systems, while floating-
point arithmetic may introduce precision errors due to limited precision representation.

PROCEDURE
1. Create a new project, go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project and Create New Project Select Device for
Target.
3. Select the device AT89C51ED2 or AT89C51 or AT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with the .asm extension.
6. Add this source file to Group and click on “Build Target” or F7.
7. Go to debugging mode to see the result of the simulation by clicking Run or Step run

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM:
#include<REG51.H>
unsigned char a, b;
void main()
{
a=0x10;
b=0x04;
P0=a-b;
P1=a+b;
P2=a*b;
P3=a/b;
while(1);
}

OUTPUT:

Port P0=

Port P1=

Port P2=

Port P3=

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS:
1. Explain the concept of arithmetic operations in Embedded C.
Arithmetic operations in Embedded C involve performing mathematical calculations such as
addition, subtraction, multiplication, and division on numerical data types like integers or floating-
point numbers.

2. How do you handle overflow conditions in arithmetic operations?


Overflow conditions can be handled by checking the result against the maximum and minimum
values of the data type being used. Additionally, some processors provide overflow flags that can be
checked to detect overflow conditions programmatically.

3. What precautions are necessary for arithmetic operations on embedded systems?


When performing arithmetic operations on embedded systems, it's essential to consider data
types, overflow conditions, and memory constraints. Ensure that the chosen data types can
accommodate the expected range of values and handle overflow conditions appropriately.

4. What is fixed-point arithmetic in Embedded C?


Fixed-point arithmetic in Embedded C involves representing and performing arithmetic
operations on numbers with a fixed number of fractional bits. It's commonly used in embedded
systems to handle calculations with integer arithmetic while preserving precision.

5. How can you optimize arithmetic operations in Embedded C programs?


Optimizing arithmetic operations involves techniques such as using bitwise operations,
minimizing memory usage, and optimizing algorithms to ensure efficient resource utilization in
embedded systems.

RESULT
Thus the embedded C program for addition, subtraction, multiplication, and division
using the Keil simulator was executed successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 5 (a)
INTRODUCTION TO THE ARDUINO PLATFORM
Date

AIM

To study about the basics of Arduino Uno board and Arduino IDE 2.0 software.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No. Hardware & Software Requirements Quantity


1 Arduino IDE 2.0 1
2 Arduino Uno Board 1

INTRODUCTION TO ARDUINO

Arduino is a project, open-source hardware, and software platform used to design and build
electronic devices. It designs and manufactures microcontroller kits and single-board interfaces
for building electronics projects. The Arduino boards were initially created to help students with
the non-technical background. The designs of Arduino boards use a variety of controllers and
microprocessors. Arduino is an easy-to-use open platform for creating electronic projects.
Arduino boards play a vitalrole in creating different projects.
The various components present on the Arduino boards are a Microcontroller, Digital
Input/output pins, USB Interface and Connector, Analog Pins, reset buttons, Power buttons,
LEDs, Crystal oscillators, and Voltage regulators. Some components may differ depending on
the type of board. The most standard and popular board used over time is Arduino UNO. The
ATmega328 Microcontroller present on the UNO board makes it rather powerful than other
boards. There are various types of Arduino boards used for different purposes and projects. The
Arduino Boards are organized using the Arduino (IDE), which can run on various platforms.
Here, IDE stands for Integrated Development Environment.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
TYPES OF ARDUINO BOARDS
1) Arduino UNO
Arduino UNO is based on an ATmega328P microcontroller. It is easy to use compared to
other boards, such as the Arduino Mega board, etc. The Arduino UNO includes 6 analog pin
inputs, 14 digital pins, a USB connector, a power jack, and an ICSP (In-Circuit Serial
Programming) header. It is the most used and of standard form from the list of all available
Arduino Boards.

2) Arduino Nano
The Arduino Nano is a small Arduino board based on ATmega328P or ATmega628
Microcontroller. The connectivity is the same as the Arduino UNO board. The Nano board is
defined as a sustainable, small, consistent, and flexible microcontroller board. It is small in size
compared to the UNO board. The devices required to start our projects using the Arduino Nano
board are Arduino IDE and mini- USB. The Arduino Nano includes an I/O pin set of 14 digital
pins and 8 analog pins. It also includes6 Power pins and 2 Reset pins.

3) Arduino Mega
The Arduino Mega is based on the ATmega2560 Microcontroller. The ATmega2560 is an
8-bit microcontroller. We need a simple USB cable to connect to the computer and the AC to
DC adapter or battery to get started with it. It has the advantage of working with more memory
space. The Arduino Mega includes 54 I/O digital pins and 16 Analog Input/Output (I/O), ICSP
header, a reset button, 4 UART (Universal Asynchronous Reciever/Transmitter) ports, USB
connection, and a power jack.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
4) Arduino Micro
The Arduino Micro is based on the ATmega32U4 Microcontroller. It consists of 20 sets of
pins. The 7 pins from the set are PWM (Pulse Width Modulation) pins, while 12 pins are analog
input pins. The other components on board are a reset button, a 16MHz crystal oscillator, an
ICSP header, and a micro-USB connection. The USB is built in the Arduino Micro board.

5) Arduino Leonardo
The basic specification of the Arduino Leonardo is the same as the Arduino Micro. It is
also based on the ATmega32U4 Microcontroller. The components present on the board are 20
analog and digital pins, a reset button, a 16MHz crystal oscillator, an ICSP header, and a micro
USB connection.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
6) Arduino Due
The Arduino Due is based on the 32-bit ARM core. It is the first Arduino board that has
been developed based on the ARM Microcontroller. It consists of 54 Digital Input/Output pins
and 12 Analog pins. The Microcontroller present on the board is the Atmel SAM3X8E ARM
Cortex-M3 CPU. It has two ports, namely, a native USB port and a Programming port. The
micro side of the USB cable should be attached to the programming port.

7) Arduino Lilypad
The Arduino LilyPad was initially created for wearable projects and e-textiles. It is based
on the ATmega168 Microcontroller. The functionality of Lilypad is the same as other Arduino
Boards. It is a round, lightweight board with a minimal number of components to keep the size of
the board small.The Arduino Lilypad board was designed by Sparkfun and Leah. It was developed
by Leah Buechley.It has 9 digital I/O pins.

8) Arduino Bluetooth
The Arduino Bluetooth board is based on ATmega168 Microcontroller. It is also named as
Arduino BT board. The components present on the board are 16 digital pins, 6 analog pins,
reset button, 16MHz crystal oscillator, ICSP header, and screw terminals. The screw terminals are
used for power. The Arduino Bluetooth Microcontroller board can be programmed over the
Bluetooth as a wireless connection.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
9) Arduino Diecimila
The Arduino Diecimila is also based on the ATmeg628 Microcontroller. The board consists
of 6 analog pin inputs, 14 digital Input/Output pins, a USB connector, a power jack, an ICSP (In-
Circuit Serial Programming) header, and a reset button. We can connect the board to the
computer using the USB and can power on the board with the help of an AC to DC adapter. The
Diecimila was initially developed to mark the 10000 delivered boards of Arduino. Here,
Diecimila means 10,000 in Italian.

10) Arduino Robot


The Arduino Robot is called as the tiny computer. It is widely used in robotics. The board
comprises of the speaker, five-button, color screen, two motors, an SD card reader, a digital
compass, two potentiometers, and five floor sensors. The Robot Library can be used to control
the actuators and the sensors.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
11) Arduino Ethernet
The Arduino Ethernet is based on the ATmega328 Microcontroller. The board consists of
6 analog pins, 14 digital I/O pins, crystal oscillator, reset button, ICSP header, a power jack, and
an RJ45 connection. With the help of the Ethernet shield, we can connect our Arduino board to
the internet.

12) Arduino Zero


The Arduino Zero is generally called as the 32-bit extension of the Arduino UNO. It is
based on ATmel's SAM21 MCU. The board consists of 6 analog pin inputs, 14 digital
Input/Output pins, a USB connector, a power jack, and an ICSP (In-Circuit Serial Programming)
header, UART port pins, a power header, and AREF button. The Embedded debugger of Atmel is
also supported by the Arduino Zero. The function of Debugger is to provide a full debug
interface, which does not requireadditional hardware.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
13) Arduino Esplora
The Arduino Esplora boards allow easy interfacing of sensors and actuators. The outputs
and inputs connected on the Esplora board make it unique from other types of Arduino boards.
The board includes outputs, inputs, a small microcontroller, a microphone, a sensor, a joystick,
an accelerometer, a temperature sensor, four buttons, and a slider.

14) Arduino Pro Micro


The structure of Arduino Pro Micro is similar to the Arduino Mini board, except the
Microcontroller ATmega32U4. The board consists of 12 digital Input/output pins, 5 PWM (Pulse
Width Modulation) pins, Tx and Rx serial connections, and 10-bit ADC (Analog to Digital
Converter).

INTRODUCTION TO ARDUINO UNO


The Arduino UNO is a standard board of Arduino. Here UNO means 'one' in Italian. It was
named UNO to label the first release of Arduino Software. It was also the first USB board
released by Arduino. It is considered a powerful board used in various projects. Arduino. cc
developed the Arduino UNO board. Arduino UNO is based on an ATmega328P microcontroller.
It is easy to use compared to other boards, such as the Arduino Mega board, etc. The board
consists of digital and analog Input/Output pins (I/O), shields, and other circuits. The Arduino
UNO includes 6 analog pin inputs, 14 digital pins, a USB connector, a power jack, and an ICSP

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
(In-Circuit Serial Programming) header. It is programmed based on IDE, which stands for
Integrated Development Environment. It can run on both online and offline platforms. The IDE is
common to all available boards of Arduino. The Arduino board is shown below:

The components of Arduino UNO board are shown below:

o ATmega328 Microcontroller- It is a single-chip Microcontroller of the ATmel family.


The processor code inside it is of 8-bit. It combines Memory (SRAM, EEPROM, and
Flash), Analog to Digital Converter, SPI serial ports, I/O lines, registers, timers,
external and internal interrupts, and oscillator.
o ICSP pin - The In-Circuit Serial Programming pin allows the user to program using the
firmware of the Arduino board.
o Power LED Indicator- The ON status of the LED shows the power is activated. When
the power is OFF, the LED will not light up.
o Digital I/O pins- The digital pins have the value HIGH or LOW. The pins numbered
from D0 to D13 are digital pins.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
o TX and RX LED's- The successful flow of data is represented by the lighting of these
LED's.
o AREF- The Analog Reference (AREF) pin is used to feed a reference voltage to the
Arduino UNO board from the external power supply.
o Reset button- It is used to add a Reset button to the connection.
o USB- It allows the board to connect to the computer. It is essential for the programming
of the Arduino UNO board.
o Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz, which makes the
Arduino UNO a powerful board.
o Voltage Regulator- The voltage regulator converts the input voltage to 5V.
o GND- Ground pins. The ground pin acts as a pin with zero voltage.
o Vin- It is the input voltage.
o Analog Pins- The pins numbered from A0 to A5 are analog pins. The function of Analog
pins is to read the analog sensor used in the connection. It can also act as GPIO (General
Purpose Input Output) pin.

TECHNICAL SPECIFICATIONS OF ARDUINO UNO


The technical specifications of the Arduino UNO are listed below:
o There are 20 Input/Output pins present on the Arduino UNO board. These 20 pins include 6
PWM pins, 6 analog pins, and 8 digital I/O pins.
o The PWM pins are Pulse Width Modulation capable.
o The crystal oscillator present in Arduino UNO comes with a frequency of 16MHz.
o It also has an Arduino-integrated WIFI module. Such Arduino UNO board is based on
the Integrated WIFI ESP8266 Module and ATmega328P microcontroller.
o The input voltage of the UNO board varies from 7V to 20V.
o Arduino UNO automatically draws power from the external power supply. It can also
draw power from the USB.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
ARDUINO UNO PINOUT
The Arduino UNO is a standard board of Arduino, which is
based on an ATmega328P microcontroller. It is easier to use than other types of Arduino
Boards. The Arduino UNO Board, with the specification of pins, is shown below:

ATmega328 Microcontroller: It is a single chip Microcontroller of the ATmel family. The


processor core inside it is of 8-bit. It is a low-cost, low powered, and a simple microcontroller. The
Arduino UNO and Nano models are based on the ATmega328 Microcontroller.
Voltage Regulator: The voltage regulator converts the input voltage to 5V. The primary function
of voltage regulator is to regulate the voltage level in the Arduino board. For any changes in the
input voltage of the regulator, the output voltage is constant and steady.
GND - Ground pins. The ground pins are used to ground the circuit.
TXD and RXD: TXD and RXD pins are used for serial communication. The TXD is used for
transmitting the data, and RXD is used for receiving the data. It also represents the successful flow
of data.
USB Interface: The USB Interface is used to plug-in the USB cable. It allows the board to

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
connect to the computer. It is essential for the programming of the Arduino UNO board.
RESET: It is used to add a Reset button to the connection.
SCK: It stands for Serial Clock. These are the clock pulses, which are used to synchronize the
transmission of data.

MISO: It stands for Master Input/ Slave Output. The save line in the MISO pin is used to send
the data to the master.

VCC: It is the modulated DC supply voltage, which is used to regulate the IC's used in the
connection. It is also called as the primary voltage for IC's present on the Arduino board. The Vcc
voltage value can be negative or positive with respect to the GND pin.

Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz, which makes the Arduino
UNO a powerful board.

ICSP: It stands for In-Circuit Serial Programming. The users can program the Arduino board's
firmware using the ICSP pins. The program or firmware with the advanced functionalities is
received by microcontroller with the help of the ICSP header.
SDA: It stands for Serial Data. It is a line used by the slave and master to send and receive data.
It is called as a data line, while SCL is called as a clock line.

SCL: It stands for Serial Clock. It is defined as the line that carries the clock data. It is used to
synchronize the transfer of data between the two devices. The Serial Clock is generated by the
device and it is called as master.

SPI: It stands for Serial Peripheral Interface. It is popularly used by the microcontrollers to
communicate with one or more peripheral devices quickly. It uses conductors for data receiving,
data sending, synchronization, and device selection (for communication).

MOSI: It stands for Master Output/ Slave Input. The MOSI and SCK are driven by the Master.
SS: It stands for Slave Select. It is the Slave Select line, which is used by the master. It acts as the
enable line.

I2C: It is the two-wire serial communication protocol. It stands for Inter Integrated Circuits. The
I2C is a serial communication protocol that uses SCL (Serial Clock) and SDA (Serial Data) to
receive and send data between two devices.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
INTRODUCTION TO ARDUINO IDE 2.0
The Arduino IDE 2.0 is an open-source project, currently in its beta-phase. It is a big step
from it's sturdy predecessor, Arduino IDE 2.0, and comes with revamped UI, improved board &
library manger, autocomplete feature and much more.
In this tutorial, we will go through step by step, how to download and install the software.
Download the editor
Downloading the Arduino IDE 2.0 is done through the Arduino Software page. Here you
will also find information on the other editors available to use.
Requirements
 Windows - Win 10 and newer, 64 bits
 Linux - 64 bits
 Mac OS X - Version 10.14: "Mojave" or newer, 64 bits

Installation
Windows
Download URL: https://www.arduino.cc/en/software

To install the Arduino IDE 2.0 on a Windows computer, simply run the file downloaded from the
software page.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Now use the Arduino IDE 2.0 on the windows computer!

How to use the board manager with the Arduino IDE 2.0
The board manager is a great tool for installing the necessary cores to use your Arduino
boards. In this quick tutorial, we will take a look at how to install one, and choosing the right core
for your board!
Requirements
 Arduino IDE 2.0 installed.
Why use the board manager?
The board manager is a tool that is used to install different cores on your local computer.
So whatis a core, and why is it necessary that I install one?
Simply explained, a core is written and designed for specific microcontrollers. As Arduino have
several different types of boards, they also have different type of microcontrollers.

For example, an Arduino UNO has an ATmega328P, which uses the AVR core, while an Arduino
Nano 33 IoT has a SAMD21 microcontroller, where we need to use the SAMD core.

In conclusion, to use a specific board, we need to install a specific core.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Installing a core
Installing a core is quick and easy, but let's take a look at what we need to do.
1. Open the Arduino IDE 2.0.
2. With the editor open, let's take a look at the left column. Here, we can see a couple of
icons.Let's click the on the "computer chip" icon.

3. A list will now appear of all available cores. Now let's say we are using an Nano
33 IoT board, and we want to install the core. Simply enter the name in the search field,
and the right core (SAMD) will appear, where the Nano 33 IoT features in the
description. Click on the "INSTALL" button.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
4. This will begin an installation process, which in some cases may take several minutes.

5. When it is finished, we can take a look at the core in the boards manager column, where it
should say "INSTALLED".

You have now successfully downloaded and installed a core on your machine, and you can start
using your Arduino board!

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
How to upload a sketch with the Arduino IDE 2.0
In the Arduino environment, we write sketches that can be uploaded to Arduino boards. In this
tutorial, we will go through how to select a board connected to your computer, and how to
uploada sketch to that board, using the Arduino IDE 2.0.
Requirements
 Arduino IDE 2.0 installed.
Verify VS Upload
There are two main tools when uploading a sketch to a board: verify and upload. The verify tool
simply goes through your sketch, checks for errors and compiles it. The upload tool does the
same, but when it finishes compiling the code, it also uploads it to the board.
A good practice is to use the verifying tool before attempting to upload anything. This is a quick
way of spotting any errors in your code, so you can fix them before actually uploading the code.
Uploading a sketch
Installing a core is quick and easy, but let's take a look at what we need to do.
1. Open the Arduino IDE 2.0.
2. With the editor open, let's take a look at the navigation bar at the top. At the very left,
there is a checkmark and an arrow pointing right. The checkmark is used to verify,
and the arrow is used to upload.

3. Click on the verify tool (checkmark). Since we are verifying an empty sketch, we can be sureit is
going to compile. After a few seconds, we can see the result of the action in the console (black box
in the bottom).

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
4. Now we know that our code is compiled, and that it is working. Now, before we can upload the
code to our board, we will first need to select the board that we are using. We can do this by
navigating to Tools > Port > {Board}. The board(s) that are connected to your computer should
appear here, and we need to select it by clicking it. In this case, our board is displayed as COM44
(Arduino UNO).

5. With the board selected, we are good to go! Click on the upload button, and it will start
uploading the sketch to the board.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
6. When it is finished, it will notify you in the console log. Of course, sometimes there are some
complications when uploading, and these errors will be listed here as well.

Now uploaded a sketch to your Arduino board!

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS
1. What is Arduino?
Arduino is an open-source electronics platform based on easy-to-use hardware and software.
It’s intended for anyone making interactive projects.

2. How does the Arduino Uno compare to other Arduino models?


The Arduino Uno is one of the most popular Arduino models and is often used as a starting
point for people new to Arduino. It is a microcontroller board based on the ATmega328P. It has 14
digital input/output pins, a USB connection, a power jack, an ICSP header, and a reset button. It is
relatively simple to use and is a good choice for projects that do not require a lot of power.

3. What is serial communication in context with Arduino?


Serial communication is a method of communication between two devices where data is
transferred one bit at a time. In the context of Arduino, serial communication is often used in order to
transfer data between the Arduino board and a computer.

4. What is an IDE (Integrated Development Environment)?


An IDE is a software application that provides comprehensive facilities to computer
programmers for software development. An IDE normally consists of a source code editor, build
automation tools, and a debugger. When working with Arduino, you would use the Arduino IDE,
which is a cross-platform application (meaning it can be used on Windows, Mac, and Linux) that
is specifically designed for programming Arduino boards.

5. What is the purpose of PWM in Arduino?


PWM is a technique for getting an analog output from a digital device. By rapidly
switching the output on and off, the digital device can create an analog signal. This is often used
to control motors or LEDs, where a varying voltage is used to create a varying level of brightness.

RESULT
Thus studied the basics of Arduino Uno board and Arduino IDE 2.0 software.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 5 (b)
INTRODUCTION TO ARDUINO PROGRAMMING
Date

AIM

To write and execute the Arduino programming for LED blink with Arduino UNO

HARDWARE & SOFTWARE TOOLS REQUIRED

S. No Hardware & Software Requirements Quantity


1 Arduino IDE 2.0 1
2 Arduino UNO Development Board 1
3 Jumper Wires & Patch Cords few

4 Arduino USB Cable 1

THEORY

Arduino Pins: Arduino UNO has digital pins that can be configured as either input or output. Digital
pins can output either a HIGH (5V) or LOW (0V) voltage.

LED Connection: Connect the longer leg (anode) of the LED to a digital pin on the Arduino, and
connect the shorter leg (cathode) to ground (GND). A resistor should be connected in series with the
LED to limit the current flow and prevent damage to the LED and the Arduino. A resistor value of
around 220-470 ohms is usually safe for most LEDs.

Blinking Logic: To blink the LED, it will turn the pin it's connected to ON for a certain period, then
turn it OFF for another period, creating an ON-OFF cycle. By repeating this cycle, achieve the
blinking effect.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE:

1. Switch ON the Kit & Make the connections as per the procedure.
2. Write the program code in Arduino IDE 2.0
3. Now connect D13 of UNO to LED (any one out of 4) or loop all LEDs.
4. Now select sketch & upload the Program (After uploading the program message will appear---done
uploading At the bottom of the Arduino IDE software)
5. After successful uploading, the LED Starts blinking.

CONNECTION
Arduino UNO Pin Arduino Development Board
13 LED

PROGRAM

void setup ( )
{
pinMode (13, OUTPUT); //pin 13 is set as output pin
}
void loop( ) // The loop function runs again and again
{
digitalWrite (13,HIGH); // Turn ON the LED on pin 13
delay (1000); //Wait for 1sec
digitalWrite (13, LOW); //Turn OFF the LED on pin 13
delay (1000); //Wait for 1sec
}

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS
1. What is LED?
LED stands for Light Emitting Diode. It's a semiconductor device that emits light when an
electric current passes through it.

2. What is the purpose of digital output in Arduino?


Digital output in Arduino refers to the ability to set a pin to either a high voltage (usually 5
volts) or a low voltage (usually 0 volts). This is achieved using the digital Write() function.

3. What is the purpose of the setup() function in Arduino?


The setup() function is called when a sketch starts. It is used to initialize variables, pin modes,
libraries, etc., and runs only once.

4. How do you make an LED blink using Arduino?


It can make an LED blink by turning it on and off repeatedly in a loop. This is typically done
by setting the pin to HIGH to turn on the LED, then adding a delay, and finally setting the pin to LOW
to turn it off.

5. What are the limitations of powering an LED directly from an Arduino pin?
Arduino pins can supply only a limited amount of current. If too many LEDs are connected
directly to the pins without appropriate current limiting resistors, it can draw more current than the pin
can handle, potentially damaging the Arduino.

RESULT
Thus executed the Arduino programming for LED blink with Arduino UNO successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 6(a) EXPLORE BLUETOOTH COMMUNICATION METHODS WITH
Date IOT DEVICES

AIM
To make Communication with Android Mobile with Arduino using Bluetooth Module ( HC-
05) to control LED/Relay using IOT Trainer Kit.
.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware & Software Requirements Quantity


1 IoT Kit 1
2 Arduino IDE 2.0 1
3 Arduino UNO Development Board 1

4 Arduino USB Cable 1

5 HC-05 Bluetooth Module 1

6 Jumper Wires & Patch cords Few

THEORY

Bluetooth is a short-range wireless communication technology that operates on the 2.4


GHz frequency band. It is commonly used for connecting IoT devices to smartphones, tablets, and
other nearby devices. Bluetooth Low Energy (BLE) is a power-efficient version of Bluetooth that
is ideal for battery-powered IoT devices. Bluetooth is widely used in applications such as wearable
devices,healthcare monitoring, and home automation.

Each communication method has its advantages and limitations, and the choice depends on
the specific requirements of the IoT application. Factors to consider include range, power
consumption, data rate, security, and interoperability with other devices or systems.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE
 Switch ON the Kit & Make the connections as per the procedure
 Write the program code in Arduino IDE 2.0
 Download the Mobile app called Arduino Blue Control
 Open the app Blue control (It will automatically turn on the device’s Bluetooth).
 Go to options. Click on “Connect to Robot”. Choose device – HC 05.
 When connecting to the Bluetooth module for the first time, Enter password. 0000 OR
1234.
 When the device gets successfully paired with the sensor, the LED /Relay will be ON
 Sensor will start blinking/chattering at a slower rate than usual

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
CONNECTIONS

Arduino UNO Pin Bluetooth Module Arduino Development Board


VCC 5V -
GND GND -
2 Tx -
3 Rx -
4 - LED

PROGRAM

void setup() {
Serial.begin(9600);
pinMode(8, OUTPUT); // put your setup code here, to run once:
}void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0)
{
char data= Serial.read(); // reading the data received from the bluetooth module
switch(data)
{
case 'a': digitalWrite(8, HIGH);break; // when a is pressed on the app on your smart phone
case 'd': digitalWrite(8, LOW);break; // when d is pressed on the app on your smart phone
default : break;
}
Serial.println(data);
}
delay(50);
}

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS
1. What is Bluetooth communication?
Bluetooth communication is a wireless technology standard for exchanging data over short
distances using radio waves. It allows devices to communicate and transfer data between each
other without the need for wires.

2. How can Bluetooth be utilized in IoT devices?


Bluetooth can be used in IoT devices for wireless communication between the device and
other devices such as smart phones, tablets, or other IoT devices. It enables control, monitoring,
and data exchange between these devices.

3. What are the common Bluetooth modules used with Arduino for IoT applications?
Common Bluetooth modules used with Arduino for IoT applications include HC-05, HC-
06, HM-10, and HM-11 modules. These modules provide Bluetooth connectivity and can be
easily interfaced with Arduino boards.

4. What is the AT command mode of Bluetooth modules?


The AT command mode of Bluetooth modules allows you to configure various parameters
of the module, such as the baud rate, device name, pairing PIN, etc., using a series of AT
commands sent via the serial interface.

5. What are the advantages of using Bluetooth for IoT communication?


Advantages of using Bluetooth for IoT communication includes low power consumption
(especially with BLE), compatibility with a wide range of devices, ease of use, and the ability to
establish ad-hoc connections without the need for a centralized network infrastructure.

RESULT
Thus executed the program to control an LED using a Bluetooth communication with IOT
devices.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 6(b) EXPLORE ZIGBEE COMMUNICATION METHODS WITH IOT
Date DEVICES

AIM

To make wireless communication with Arduino using zigbee Module to control LED/Relay
using IOT Trainer Kit.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware & Software Requirements Quantity


1 IoT Trainer Kit 1
2 Arduino IDE 2.0 1
3 Arduino UNO Development Board 1

4 Jumper Wires, Path Cords few

5 Arduino USB Cable 2

6 Zigbee with Zigbee breakout shield 2

THEORY
Zigbee is a low-power wireless communication protocol designed for short-range
communication between devices. It operates on the 2.4 GHz frequency band and supports mesh
networking, allowing devices to communicate with each other through intermediate nodes.
Zigbee iscommonly used in home automation, industrial control, and smart energy applications.

PROCEDURE

 After starting the hardware and connecting keyboard, mouse, and monitor.
 Connect Arduino UNO via USB to IOT Trainer Kit.
 Make the connections as follows:
 Before connection, Configure zigbee using XCTU Software making one Zigbee as End-user or
router & another zigbee as co-ordinator.
 Connect the zigbee to Arduino using zigbee shield
 Open the program in Arduino IDE
 Check the Program, we have connected D13 of Arduino to LED or to Relay. So connect a
patch cord
 From D13 to Either LED or to Relay.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
CONNECTIONS
1. Tx (pin2)of XBee -> Tx of Arduino board
2. Rx(pin3) of Xbee -> Rx of Arduino board
3. Gnd(pin10) of Xbee -> GND of Arduino board
4. Vcc (Pin1) of Xbee -> 3.3v of Arduino board

PROGRAM
TRANSMITTER SIDE

#include<SoftwareSerial.h>

SoftwareSerial

mySerial(2,3); //rx,tx

void setup() {
mySerial.begin(9600);
Serial.begin(9600);
}

void loop() {
mySerial.write('A');

Serial.println('A');

delay(100);

mySerial.write('B');

Serial.println('B');

delay(100);
}

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM
RECEIVER SIDE
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx
void setup() {
mySerial.begin(9600);
Serial.begin(9600);
pinMode(4, OUTPUT);
}

void loop() {
if(mySerial.available()>0)
{
char
data=mySerial.read();
Serial.println(data);
if(data=='A')
digitalWrite(4,HIGH);
else if(data=='B')
digitalWrite(4,LOW);
}
}

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. What is Zigbee ommuniation?


Zigbee is a wireless communication protocol designed for low-power, low-data-rate
applications. It operates on the IEEE 802.15.4 standard and is optimized for short-range
communication with low power consumption.
2. How does Zigbee differ from other wireless communication protocols like Bluetooth or Wi-Fi?
Unlike Bluetooth, which is often used for point-to-point communication over short distances,
Zigbee is more suitable for mesh networking and home automation applications. Wi-Fi, on the other
hand, is optimized for higher data rates and longer ranges, making it less suitable for low-power IoT
devices.
3. How do you configure the Zigbee Module for communication with the Arduino?
The Zigbee Module needs to be configured with the appropriate settings such as baud rate,
channel, PAN ID, and addressing mode to ensure compatibility and secure communication with the
Arduino. Configuration can typically be done using a computer and terminal software or through
programming using AT commands sent from the Arduino.
4. What is the role of coordinators and routers in a Zigbee network?
Coordinator: The coordinator initiates and maintains the network, controls access to the network, and
assigns addresses to devices. There is only one coordinator in a Zigbee network.
Router: Routers serve as intermediate nodes that facilitate communication between devices. They
participate in routing data between source and destination nodes, enhancing the network's reliability
and coverage.
5. What are the advantages of using Zigbee for IoT applications compared to other wireless protocols?
Zigbee offers several advantages for IoT applications, including:
 Low power consumption, making it suitable for battery-operated devices.
 Mesh networking capability, enabling robust and scalable communication networks.
 Support for various topologies, including star, mesh, and cluster tree, offering flexibility in
network design.
 Reliability in noisy environments and interference immunity due to its low-duty-cycle
 operation.

RESULT
Thus executed the wireless communication with Arduino using Zigbee Module to control
LED/Relay using IOT Trainer Kit.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 6(c) EXPLORE GSM COMMUNICATION METHODS WITH IOT
Date DEVICES

AIM

To make Communication with Mobile with Arduino using GSM 800LModule to control
LED/Relay using IOT Trainer Kit.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware & Software Requirements Quantity


1 Arduino IDE 2.0 1
2 Arduino UNO Development Board 2
3 Jumper Wires few

4 Arduino USB Cable 2

5 GSM 1

THEORY
GSM communication methods play a pivotal role in enabling IoT devices to establish
wireless connectivity over cellular networks. Leveraging the Global System for Mobile
Communications (GSM) standard, IoT devices integrate GSM modems or modules equipped with
Subscriber Identity Module (SIM) cards for network authentication. These modules enable IoT
devices to transmit data packets over GSM networks using protocols like TCP/IP or UDP,
facilitated by technologies such as GPRS, EDGE, 3G, or 4G/LTE. Additionally, GSM enables IoT
devices to exchange Short Message Service (SMS) messages for command and control, status
updates, or alarm notifications. To ensure data security during transmission, encryption protocols
like SSL/TLS can be employed, with VPN tunnels establishing secure communication channels.
While GSM networks offer wide coverage and roaming capabilities, IoT deployments must
consider factors such as power consumption, network costs, regulatory compliance, and
integration with IoT platforms for effective implementation and management. Overall, GSM
communication methods provide a robust framework for IoT devices to seamlessly communicate,
facilitating diverse applications across industries and domains.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

 Before Uploading Code or making Connections as per the diagram.


 Insert Microsim Card as shown in the Diagram.
 Once the SIM Card is Inserted , GSM800L will Search for Network & Once the Network is
 detected, the LED in the GSM 800L will Start Glowing Slowly every 3 seconds.
 Double click gsm_parsex-e_ok2.ino and the program will automatically open in Arduino ide.
 Now add the Mobile No (Inserted SIM Card) in the code.
 Connect TX and RX on GSM to Arduino uno.
 Pins of D7 to TX and D8 to RX of GSM 800L connect relay pin to D4.

CONNECTION PROCEDURE
 Connect Arduino RX Pin to GSM TX Pin
 Connect Arduino TX Pin to GSM RX Pin
 Connect Arduino GND to GSM GND Pin

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM

// Set up a new SoftwareSerial object


void setup()
{
Serial.begin(9600); //Baud rate of the GSM Module
delay(1000);
Serial.println("ATD +919042591157;\r");
delay(1000);
}
void loop()
{
}

PROGRAM FOR SEND AND RECEIVE SMS

void setup()
{
Serial.begin(9600);
delay(2000);
Serial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(2000); // Delay of 1000 milli seconds or 1 second
Serial.println("AT+CMGS=\"+919042591157\"\r"); // Replace x with mobile number
delay(2000);
Serial.println("HELLO FROM SIM");// The SMS text you want to send
delay(500);
Serial.write(26);
}
void loop()
{
// put your main code here, to run repeatedly:
}

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS
1. What is GSM?
GSM stands for Global System for Mobile Communications, a standard for cellular
communication widely used for mobile phones and IoT devices.

2. How do IoT devices utilize GSM for communication?


IoT devices integrate GSM modules to connect to cellular networks, enabling data
transmission and SMS communication.

3. What role does the SIM card play in GSM communication?


The SIM card authenticates IoT devices on the GSM network, allowing them to establish
connections and transmit data.

4. What protocols are commonly used for data transmission over GSM networks?
IoT devices typically use TCP/IP or UDP protocols for data transmission over GSM
networks.

5. What are some security measures implemented in GSM communication?


Encryption protocols like SSL/TLS are used to secure data transmission, and VPN
tunnels can establish secure communication channels.

RESULT
Thus executed the Communication with Mobile with Arduino using GSM 800LModule to
control LED/Relay using IOT Trainer Kit.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 7(a)
INTRODUCTION TO THE RASPBERRY PI PLATFORM
Date

AIM
To study about the Raspberry PI platform.

Introduction to Raspberry Pi Pico W

Raspberry Pi is a small single board computer. By connecting peripherals like Keyboard,


mouse, display to the Raspberry Pi, it will act as a mini personal computer.
Raspberry Pi is popularly used for real time Image/Video Processing, IoT based
applications and Robotics applications.
Raspberry Pi is slower than laptop or desktop but is still a computer which can provide all
the expected features or abilities, at a low power consumption.T he Raspberry Pi Pico W is a
compact and affordable microcontroller board developed by the Raspberry Pi Foundation.
Building upon the success of the Raspberry Pi Pico, the Pico W variant brings wireless
connectivity to the table, making it an even more versatile platform for embedded projects.
Features
 RP2040 microcontroller with 2MB of flash memory
 On-board single-band 2.4GHz wireless interfaces (802.11n)
 Micro USB B port for power and data (and for reprogramming the flash)
 40 pins 21mmx51mm ‘DIP’ style 1mm thick PCB with 0.1″ through-hole pins also with
edgecastellations
 Exposes 26 multi-function 3.3V general purpose I/O (GPIO)
 23 GPIO are digital-only, with three also being ADC-capable
 Can be surface mounted as a module
 3-pin ARM serial wire debug (SWD) port
 Simple yet highly flexible power supply architecture
 Various options for easily powering the unit from micro-USB, external supplies, or batteries
 High quality, low cost, high availability
 Comprehensive SDK, software examples, and documentation
 Dual-core Cortex M0+ at up to 133MHz
 On-chip PLL allows variable core frequency

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Raspberry Pi Pico W:
The Raspberry Pi Pico W is based on the RP2040 microcontroller, which was designed by
Raspberry Pi in-house. It combines a powerful ARM Cortex-M0+ processor with built-in Wi-Fi
connectivity, opening up a range of possibilities for IoT projects, remote monitoring, and wireless
communication. The Pico W retains the same form factor as the original Pico, making it compatible
with existing Picoaccessories and add-ons.

RP2040 Microcontroller
At the core of the Raspberry Pi Pico W is the RP2040 microcontroller. It features a dual-
core ARM Cortex-M0+ processor running at 133MHz, providing ample processing power for a
wide range of applications. The microcontroller also includes 264KB of SRAM, which is essential
for storing and manipulating data during runtime. Additionally, the RP2040 incorporates 2MB of
onboard flash memory for program storage, ensuring sufficient space for code and firmware.

Wireless Connectivity
The standout feature of the Raspberry Pi Pico W is its built-in wireless connectivity. It
includes an onboard Cypress CYW43455 Wi-Fi chip, which supports dual-band (2.4GHz and
5GHz) Wi-Fi 802.11b/g/n/ac. This allows the Pico W to seamlessly connect to wireless networks,
communicate with other devices, and access online services. The wireless capability opens up new
avenues for IoTprojects, remote monitoring and control, and real-time data exchange.

GPIO and Peripherals:


Similar to the Raspberry Pi Pico, the Pico W offers a generous number of GPIO pins,
providing flexibility for interfacing with external components and peripherals. It features 26 GPIO
pins, of which 3 are analog inputs, and supports various protocols such as UART, SPI, I2C, and

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PWM. The Pico W also includes onboard LED indicators and a micro-USB port for power and data
connectivity.

MicroPython and C/C++ Programming:


The Raspberry Pi Pico W can be programmed using MicroPython, a beginner-friendly
programming language that allows for rapid prototyping and development. MicroPython provides
a simplified syntax and high-level abstractions, making it easy for newcomers to get started.
Additionally, the Pico W is compatible with C/C++ programming, allowing experienced
developers to leverage the rich ecosystem of libraries and frameworks available.

Open-Source and Community Support


As with all Raspberry Pi products, the Pico W benefits from the vibrant and supportive
Raspberry Pi community. Raspberry Pi provides extensive documentation, including datasheets,
pinout diagrams, and programming guides, to assist developers in understanding the board’s
capabilities. The community offers forums, online tutorials, and project repositories, allowing users
to seek help, shareknowledge, and collaborate on innovative projects.

The Raspberry Pi Pico W brings wireless connectivity to the popular Raspberry Pi Pico
microcontroller board. With its powerful RP2040 microcontroller, built-in Wi-Fi chip, extensive

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
GPIO capabilities, and compatibility with MicroPython and C/C++ programming, the Pico W
offers a versatile and affordable platform for a wide range of embedded projects. Whether you are
a beginner or an experienced developer, the Raspberry Pi Pico W provides a user-friendly and
flexible platform to bring your ideas to life and explore the exciting world of wireless IoT
applications.
Programmable Input/Output (PIO) State Machines:
One of the unique features of the RP2040 microcontroller is the inclusion of
Programmable Input/Output (PIO) state machines. These state machines provide additional
processing power and flexibility for handling real-time data and timing-critical applications. The
PIO state machines can be programmed to interface with custom protocols, generate precise
waveforms, and offload tasks from the main processor, enhancing the overall performance of the
system.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. What is Raspberry Pi?


Raspberry Pi is a small, affordable, single-board computer developed by the Raspberry Pi
Foundation. It's designed for educational purposes and DIY projects.

2. What are the key features of Raspberry Pi?


Raspberry Pi features include a Broadcom SoC (System on Chip), various connectivity options
(USB, HDMI, Ethernet, GPIO pins), and support for different operating systems like Raspbian (based
on Debian Linux).

3. What programming languages are supported on Raspberry Pi?


Raspberry Pi supports various programming languages, including Python, C/C++, Java,
Scratch, and many others.

4. What is the GPIO (General Purpose Input/Output) on Raspberry Pi used for?


GPIO pins on Raspberry Pi allow users to interact with external hardware components like
sensors, LEDs, motors, and more, making it suitable for IoT and electronics projects.

5. What are some popular Raspberry Pi projects?


Popular Raspberry Pi projects include retro gaming consoles, media centers, home automation
systems, weather stations, and security cameras.

RESULT
Thus studied about the Raspberry PI platform.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 7(b)
INTRODUCTION TO PYTHON PROGRAMMING
Date

AIM

To make LED BLINK using Raspberry Pi using IoT Trainer Kit.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware & Software Requirements Quantity


1 Thonny IDE 1
2 Raspberry Pi IoT Trainer Kit 1
3 Jumper Wires few
4 Micro USB Cable 1
5 Power Cords 1

THEORY

MicroPython is a Python 3 programming language re-implementation targeted for


microcontrollers and embedded systems. MicroPython is very similar to regular Python. Apart
from a few exceptions, the language features of Python are also available in MicroPython. The
most significant difference between Python and MicroPython is that MicroPython was designed to
work under constrained conditions.
Because of that, MicroPython does not come with the entire pack of standard libraries. It
only includes a small subset of the Python standard libraries, but it includes modules to easily
control andinteract with the GPIOs, use Wi-Fi, and other communication protocols.
Thonny IDE:

Thonny is an open-source IDE which is used to write and upload MicroPython programs to
different development boards such as Raspberry Pi Pico, ESP32, and ESP8266. It is extremely
interactive and easy to learn IDE as much as it is known as the beginner-friendly IDE for new
programmers. With the help of Thonny, it becomes very easy to code in Micropython as it has a
built-in debugger that helps to find any error in the program by debugging the script line by line.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

1. Switch ON the kit and make the connections as per the diagram.
2. Connect GP12 from Raspberry Pi to LED (any one out of 4) or loop all LEDs
3. Now to run the Program click the RUN Image as shown.
4. After successful uploading the program, the LED starts blinking.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
CONNECTIONS

Raspberry Pi Pico Raspberry Pi IoT


Pin Trainer Kit
GP12 LED

PROGRAM
from machine import Pin

import time

LED = Pin(12, Pin.OUT)


while True:
LED.value(1)
time.sleep(1)
LED.value(0)
time.sleep(1)

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
CONNECTIONS

Raspberry Pi Pico Raspberry Pi Pico


Pin Development Board
(RGB)
GP16 R
GP17 G
GP18 B
GND COM

RGB:

from machine import Pin


from time import
sleep_ms,sleep

r=Pin(16, Pin.OUT)
y=Pin(17, Pin.OUT)
g=Pin(18, Pin.OUT)
while True: r.value(1)
sleep_ms(1000)
r.value(0)
sleep_ms(1000)
y.value(1) sleep(1)
y.value(0) sleep(1)
g.value(1) sleep(1)
g.value(0) sleep(1)

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. What is the purpose of an IoT Trainer Kit for LED blinking experiments with Raspberry Pi?
An IoT Trainer Kit facilitates hands-on learning of IoT concepts, providing necessary
components and interfaces for prototyping, such as LEDs and GPIO pins.

2. Write the basic concept behind LED blinking with Raspberry Pi.
LED blinking involves controlling the state of a GPIO pin on the Raspberry Pi to turn an
LED on and off, creating a blinking effect.

3. How do you set up the hardware for LED blinking on the IoT Trainer Kit?
Connect the LED's anode to a GPIO pin with a current-limiting resistor and the cathode to
the ground (GND) pin.

4. What is GPIO, and how do you control it using Python?


GPIO (General Purpose Input/Output) pins allow communication between Raspberry Pi
and external devices. Python libraries like RPi.GPIO enable control of GPIO pins
programmatically.

5. What does the time.sleep() function do in the code?


It pauses program execution for the specified duration (in seconds), creating the blinking
effect by toggling the LED state at intervals.

RESULT

Thus executed the LED BLINK using Raspberry Pi using IOT Trainer Kit with python
programming successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 8
INTERFACING SENSORS WITH RASPBERRY PI
Date

AIM

To interface the Ultrasonic sensor and IR sensor with Raspberry Pi using IoT Trainer Kit.

HARDWARE & SOFTWARE TOOLS REQUIRED:

S.No Hardware & Software Requirements Quantity

1 Thonny IDE 1
2 Raspberry Pi IoT trainer Kit 1
3 Jumper Wires few

4 Micro USB Cable 1

5 IR Sensor 1

6 Ultrasonic sensor HCSR04 1

THEORY

Ultrasonic sensors emit short, high-frequency sound pulses at regular intervals. These
propagate in the air at the velocity of sound. If they strike an object, then they reflected back as an
echo signal to the sensor, which itself computes the distance to the target based on the time-span
between emitting the signal and receiving the echo. As the distance to an object is determined by
measuring the time of flight and not by the intensity of the sound, ultrasonic sensors are excellent at
suppressing background interference. Virtually all materials which reflect sound can be detected,
regardless of their colour. Even transparent materials or thin foils represent no problem for an
ultrasonic sensor.

An infrared sensor is an electronic device, which emits in order to sense some aspects of the
surroundings. An IR sensor can measure the heat of an object as well as detects the motion. These
types of sensors measure only infrared radiation, rather than emitting it that is called a passive IR
sensor. Usually, in the infrared spectrum, all the objects radiate some form of thermal radiation. The
working principle of an infrared sensor is similar to the object detection sensor. This sensor includes
an IR LED & an IR Photodiode, so by combining these two can be formed as a photo-coupler
otherwise optocoupler. The physics laws used in this sensor are planks radiation, Stephan Boltzmann
& weins displacement.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

Ultrasonic Sensor

1. Switch ON the Kit and make the Connections as per the diagram.
2. Connect ECHO of Ultrasonic Sensor to GP12 of Raspberry Pi using Patch.
6. Connect TRIG of Ultrasonic Sensor to GP16 of Raspberry Pi using Patch cord.
7. Now Click RUN on the Thonny IDE.
8. After successful uploading the program, message will appear at the bottom of the Thonny IDE.
9. A message appears Calibrating wait and Place the object to measure the Distance.
10. Now place an small sheet(Cardboard) in front & near to the Ultrasonic Sensor.
11. Now it shows the distance from the sensor, move the sheet slowly and observe the different
measurement shown at the bottom of the Thonny IDE.

IR Sensor

1. Switch ON the Kit & Make the connections as per the diagram.
2. Connect IR Sensor to GP16 of Raspberry Pi using Patch cord.
3. Connect Buzzer Pin to GP12 of Raspberry Pi using Patch cord
4. Now Click RUN on the Thonny IDE and After successful uploading the program, message will
appear at the bottom of the Thonny IDE.
5. A message appears IR Sensor Ready.
6. Take a Cardboard & take it near the IR LED, the sensor will sense it and a message appears,
Object Detected & Buzzer sounds. When remove the card Board near from IR LED, the
Buzzer stops & Another Message appears. NO Object Detected.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
ULTRASONIC SENSOR

CONNECTIONS

Raspberry Pi Pico Raspberry Pi Pico


Ultrasonic Sensor Module
Pin Development Board
GP13 BUZZER -
GP12 - ECHO
GP16 - TRIG
- 5V VCC
- GND GND

PROGRAM

from machine import Pin, PWM


import utime
trigger = Pin(14, Pin.OUT)
echo = Pin(15, Pin.IN)
buzzer = Pin(16, Pin.OUT)

def measure_distance():
trigger.low()
utime.sleep_us(2)
trigger.high()
utime.sleep_us(5)
trigger.low()
while echo.value() == 0:
signaloff = utime.ticks_us()
while echo.value() == 1:
signalon = utime.ticks_us()

timepassed = signalon - signaloff


distance = (timepassed * 0.0343) / 2
return distance

while True:
dist = measure_distance()
print(f"Distance : {dist} cm")
if dist <= 10:
buzzer.value(1)
utime.sleep(0.01)
else:

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
buzzer.value(0)
utime.sleep(0.01)
utime.sleep(0.5)

IR SENSOR

CONNECTIONS

Raspberry Pi Pico Raspberry Pi Pico


IR Sensor Module
Pin Development Board
GP12 BUZZER -
GP16 - OUT
- 5V VCC
- GND GND

PROGRAM

from machine import Pin


from time import sleep
buzzer=Pin(16,Pin.OUT)
ir=Pin(15,Pin.IN)
while True:
ir_value=ir.value()
if ir_value== True:
print("Buzzer OFF")
buzzer.value(0)
else:
print("Buzzer ON")
buzzer.value (1)
sleep(0.5)

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS
1. What is an Ultrasonic sensor?
An Ultrasonic sensor is a device that emits ultrasonic waves and measures their reflection to
determine the distance to an object.

2. How does an Ultrasonic sensor work?


It emits ultrasonic waves and measures the time taken for the waves to reflect off an object and
return. By knowing the speed of sound, it calculates the distance to the object.

3. What are the pins on an Ultrasonic sensor, and how do you connect it to a Raspberry Pi?
Ultrasonic sensors typically have VCC, GND, Trigger, and Echo pins. VCC and GND connect to
the respective power and ground pins on the Raspberry Pi, while Trigger and Echo connect to GPIO
pins for sending and receiving signals.

4. What is the working principle of an IR sensor?


An IR sensor detects infrared radiation emitted by objects in its field of view. When an object is
detected, the sensor outputs a signal indicating its presence.

5. How do you connect an IR sensor to a Raspberry Pi?


The IR sensor usually has VCC, GND, and OUT pins. VCC and GND connect to the Raspberry Pi's
power and ground pins, while OUT connects to a GPIO pin to read the sensor's output.

RESULT
Thus interfaced the Ultrasonic sensor and IR sensor with Raspberry Pi using IoT Trainer Kit
successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 9 COMMUNICATE BETWEEN ARDUINO AND RASPBERRY PI
Date USING WIRELESS MEDIUM

AIM

To write and execute the program to communicate DHT11 Sensor Data from Arduino wirelessly
and to Receive DHT11Sensor Data in Raspberry pi Using Zigbee.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware & Software Requirements Quantity

1 Thonny IDE 1
2 Raspberry Pi IoT Trainer Kit 1
3 Arduino Uno Development Board 1
4 Micro USB Cable 1
5 Zigbee with shield 1
6 Zigbee adaptor(S2C,S2,S2CPro) 1
7 Jumper Wires few

THEORY

To enable communication between an Arduino and a Raspberry Pi wirelessly, various wireless


mediums can be utilized, such as Wi-Fi, Bluetooth, or Zigbee. Each medium offers distinct advantages
and is chosen based on factors like range, data rate, and power consumption. For instance, Wi-Fi
provides high data rates over a considerable range but may consume more power. Bluetooth offers
moderate data rates and is suitable for short-range communication. Zigbee, on the other hand, is ideal
for low-power, low-data-rate applications over longer distances. Once the appropriate wireless
medium is selected, both the Arduino and Raspberry Pi need compatible wireless modules. These
modules are configured to establish a wireless connection between the two devices. Communication
protocols such as TCP/IP or MQTT can be employed for data exchange, depending on the application
requirements. With the wireless connection established, the Arduino can transmit sensor data or
receive commands wirelessly from the Raspberry Pi, enabling various IoT, automation, or remote
sensing applications. The most important factors like power consumption, range, and data rate ensures
an efficient and reliable wireless communication link between the Arduino and Raspberry Pi.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

1. Connect Zigbee with shield as shown with Arduino as per the diagram.
2. Also Connect DHT11 (D1) Sensor Pin to Digital Pin 7 of Arduino.
3. Connect another Zigbee with Zigbee adaptor with USB Cable to Raspberry Pi
4. Connect small USB cable of Arduino to Raspberry Pi
5. Switch ON the Kit after making all connections
6. Now the Arduino & Raspberry pi are connected with USB and Zigbee is connected with Arduino
(Remove Tx Pin and Rx Pin from Arduino before Uploading the Program). Also DHT11 is connected
in PIN D7 digital Pin.
9 Now upload the code and open the HyperTerminal of Arduino and it will appear the temperature in
Kelvin and humidity in percentage continuously running on the display
11 Now minimize the Screen ( DO Not Close the Arduino Program) and go to /home/pi/ Scientronic
scien files/comm RPI with Arduino.
12 Right click commarduino RPI.py and open it in Thonny IDE
13 Before running the program, check & check in which port is the Zigbee USB port adaptor is
plugged in Raspberry Pi.( Go to Arduino, Right Click Tools.., Search the Port (“dev/ttyUSBO”, or
devttyUSB1 or dev/ttyUSB2)
14. Note down the port and make the changes in the commarduino.py program and save the program
15. Now run the program in Raspberry Pi and observe the same temperature in kelvin and humidity in
percentage will be continuously running on the bottom of Thonny IDE

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
CONNECTIONS

1. Tx (pin2)of XBee -> Tx of Arduino board


2. Rx(pin3) of Xbee -> Rx of Arduino board
3. Gnd(pin10) of Xbee -> GND of Arduino board
4. Vcc (Pin1) of Xbee -> 3.3v of Arduino board
5. DHT11 Pin to Digital Pin 7 of Arduino board

PROGRAM

ARDUINO

#diyprojectslab,com
#include "DHT.h"
#define DHTPIN 7 // define the
digital I/O pin
#define DHT11TYPE DHT11 //
DHT 11
DHT dht11(DHTPIN,
DHT11TYPE);
void setup() {
Serial.begin(9600);
dht11.begin();
}
void loop() {
float h11 = dht11.readHumidity();
float t11 =
dht11.readTemperature();
Serial.print("Temperature = ");
Serial.print(t11 + 273.15);
Serial.println(" Kelvin");
Serial.print("Humidity = ");
Serial.print(h11);
Serial.println(" %");
delay(1000);
}

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM

RASPBERRY PI PICO

import serial
import RPi.GPIO as GPIO
import os, time
ser = serial.Serial('/dev/ttyUSB0',9600, timeout=.5)
while True:
read_serial=ser.readline()
print(read_serial)

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. What is Zigbee?
Zigbee is a wireless communication protocol designed for low-power, short-range applications
such as home automation, sensor networks, and IoT devices.

2. Why choose Zigbee for communication between Arduino and Raspberry Pi?
Zigbee is suitable for low-power consumption and offers reliable communication over
moderate distances, making it ideal for connecting Arduino and Raspberry Pi wirelessly.

3. How do Raspberry Pi and Arduino Serial Communication Work?


Raspberry Pi and Arduino serial communication is a simple way for sharing data between computers
and microcontrollers. Serial communication enables two devices to exchange data using a simple
single-wire interface or Serial via GPIOs pins.

4. What are the advantages of using Zigbee for this application?


Zigbee provides low-power consumption, robust communication, and scalability for
connecting multiple devices, making it suitable for IoT projects and sensor networks.

5. How can you ensure reliable communication over Zigbee?


Implement error-checking mechanisms, such as checksums or acknowledgments, in the
communication protocol to ensure data integrity.

RESULT
Thus executed the program to communicate DHT11 Sensor Data from Arduino wirelessly and to
Receive DHT11Sensor Data in Raspberry pi Using Zigbee sucessfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 10
SETUP A CLOUD PLATFORM TO LOG THE DATA
Date

AIM

To set up a cloud platform to log the data from IoT devices.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No. Software Requirements Quantity

1 ThingSpeak Platform 1

CLOUD PLATFORM-BLYNK

Blynk is a smart platform that allows users to create their Internet of Things applications
without the need for coding or electronics knowledge. It is based on the idea of physical
programming & provides a platform to create and control devices where users can connect physical
devices to the Internet andcontrol them using a mobile app.

Setting up Blynk 2.0 Application


To control the LED using Blynk and Raspberry Pi Pico W, you need to create a Blynk
project and set up a dashboard in the mobile or web application. Here’s how you can set up the
dashboard:

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE
Step 1: Signup for ThingSpeak
For creating the channel on ThingSpeak, first need to sign up on ThingSpeak open platform with
new user id and password.

Step 2: Create a Channel for Your Data

Once sign in after account verification, Create a new channel by clicking “New Channel” button
After clicking on “New Channel”, enter the Name and Description of the data to be upload on this
channel.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Step 3: Getting API Key in ThingSpeak
To send data to ThingSpeak, Need an unique API key, which will use later in our python code to
upload CPU data to ThingSpeak Website.
Click on “API Keys” button to get the unique API key for uploading CPU data.

Step 4: Python Code for Raspberry Pi


Complete code is given at the end of this tutorial, just make a file with any name and .py
extension and copy-paste the code and save the file. Don’t forget to replace the created API key. Then
run the python file any time using below command:
python /path/filename.py

Assuming the already installed python in Raspberry pi using this command

sudo apt-get install python

Case 1: If using monitor screen then just use the given code. Now install all libraries:
sudo apt-get install httplib sudo apt-get install urllib

After installing libraries run with python code (python /path/filename.py)


If the code runs properly, will get some CPU temperature values as shown in below image.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
If there are any errors uploading the data, you will receive “connection failed” message.

Case 2: If using “Putty” then you should follow these commands: First update your pi using:
sudo apt-get update
After this make a file cpu.py using:
nano cpu.py
After creating this file copy your code to this file and save it using CTRL + X and then ‘y’ and
Enter. After this install all libraries using:
sudo apt-get install httplib sudo apt-get install
urllib
After installing libraries run your python code using:
python cpu.py
If the code runs properly you will see some CPU temperature values as shown in above image.

Step 6: Check ThingSpeak site for Data Logging


After completing these steps open the channel and will see the CPU temperature data is
updating into ThingSpeak website.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROEDURE
1. Open Google Play Store App on an android phone
2. Open ThingSpeak.App
3. Log In to your account (using the same email and password)
4. Switch to Developer Mode
5. Find the “Raspberry Pi Pico Pico W” template we created on the web and tap on it
6. Tap on the “Raspberry Pi Pico Pico W” template (this template automatically comes because
and created it on our dashboard).
7. tap on plus icon on the left-right side of the window
8. Add one button Switch
9. Now successfully Created an android template for ThingSpeak platform.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM

import httplib
import urllib
import time
key = "ABCD" # Put your API Key here
def thermometer():
while True:
#Calculate CPU temperature of Raspberry Pi in Degrees C
temp = int(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1e3 # Get Raspberry Pi CPU
temp
params = urllib.urlencode({'field1': temp, 'key':key })
headers = {"Content-typZZe": "application/x-www-form-urlencoded","Accept": "text/plain"}
conn = httplib.HTTPConnection("api.thingspeak.com:80")
try:
conn.request("POST", "/update", params, headers)
response = conn.getresponse()
print temp
print response.status, response.reason
data = response.read()
conn.close()
except:
print "connection failed"
break
if __name__ == "__main__":
while True:
thermometer()

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. What is the purpose of setting up a cloud platform for IoT devices?


The purpose is to store, manage, and analyze data generated by IoT devices, enabling real-time
monitoring, insights, and decision-making.

2. Which cloud platforms are commonly used for IoT data logging?
Common platforms include AWS IoT, Google Cloud IoT, Microsoft Azure IoT, IBM Watson IoT,
and open-source platforms like MQTT brokers (e.g., Mosquitto).

3. How does data logging work in an IoT cloud platform?


IoT devices send data to the cloud platform using communication protocols such as MQTT,
HTTP, or CoAP. The platform stores this data in databases or data streams for further processing and
analysis.

4. How does the cloud platform ensure data security and privacy?
Cloud platforms implement security measures such as data encryption, access control,
authentication mechanisms, and compliance with industry standards and regulations (e.g., GDPR) to
protect data from unauthorized access and breaches.

5. What types of data storage options are available in IoT cloud platforms?
Storage options include relational databases, NoSQL databases, time-series databases, data
lakes, and cloud storage services like Amazon S3 or Google Cloud Storage, depending on the type and
volume of data.

RESULT

Thus set up the cloud platform to log the data from IoT devices successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 11 LOG DATA USING RASPBERRY PI AND UPLOAD TO THE
Date CLOUD PLATFORM

AIM

To write and execute the program Log DHT11 sensor data using Raspberry PI and upload it to
the cloud platform using ThingSpeak.

HARDWARE & SOFTWARE TOOLS REQUIRED

S. No Hardware & Software Requirements Quantity


1 Thonny IDE 1
2 Raspberry Pi IoT Trainer Kit 1

3 DHT 11 sensor 1

4 Jumper Wires few

5 Micro USB Cable 1

THEORY
ThingSpeak is an IoT platform in the cloud that provides sensor data collection services,
transmission, processing, visualization, and analytics on the cloud by using API keys. Furthermore, it
provides these services in real-time, which means that users can operate their services for monitoring
and control applications in real-time. There are two methods for saving sensor readings in
ThingSpeak—either in a public channel or a private channel. A channel consists of eight fields for data
storage, three fields for recording the geophysical location, and a status field. To access these services,
a user needs to be signed in. Integration with MATLAB guarantees users access to rich visualization
and sensor data analytics tools. The platform accepts raw sensor data and users use equations and
algorithms to transform that data into a usable form.

PROCEDURE

1. Switch ON the Kit

2. Make connections as per the diagram.

3. Connect DHT11 Sensor to GP4 of Raspberry Pi using Patch cord

4. Enter the channel ID (Channel Created in Thingspeak) and Writekey for DHT11 Sensor ( to be

Created in Things speak)

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM

import sys
import Adafruit_DHT
import urllib.request
import time

# Set your API key and ThingSpeak URL


apiKey = 'YOUR_THINGSPEAK_API_KEY'
baseUrl = 'https://api.thingspeak.com/update?api_key='

# Set the pin connected to the DHT11 sensor


sensor_pin = 4 # GPIO pin
def read_sensor_data():
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, sensor_pin)
if humidity is not None and temperature is not None:
return {'temperature': temperature, 'humidity': humidity}
else:
print("Failed to read sensor data.")
return None

def upload_to_thingspeak(data):
url = baseUrl + apiKey + "&field1=" + str(data['temperature']) + "&field2=" + str(data['humidity'])
try:
response = urllib.request.urlopen(url)
print("Data uploaded to ThingSpeak successfully.")
except Exception as e:
print("Failed to upload data to ThingSpeak:", str(e))

def main():
try:
while True:
sensor_data = read_sensor_data()
if sensor_data:
upload_to_thingspeak(sensor_data)
time.sleep(15) # Upload data every 15 seconds
except Keyboard Interrupt:
print("Exiting...")
sys.exit(0)

if __name__ == '__main__':
main()

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. How is the sensor connected to the Raspberry Pi?


The sensor is connected to one of the GPIO pins of the Raspberry Pi.

2. Which library is used to interact with the DHT11 sensor?


The Adafruit_DHT library is used to read data from the DHT11 sensor.

3. What is the purpose of the cloud platform in this program?


The cloud platform is used to store and analyze the sensor data remotely. In this case, ThingSpeak
is used as the cloud platform.

4. How is the data uploaded to the cloud platform?


The data is uploaded to the cloud platform using HTTP GET requests with a specific URL
containing the ThingSpeak API key and the sensor data.

5. How often is the data uploaded to the cloud platform?


In this example, the data is uploaded every 15 seconds. This interval can be adjusted according
to requirements.

RESULT

Thus executed the program Log DHT 11 sensor data using Raspberry PI and upload it to the
cloud Platform successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 12
DESIGN AN IOT-BASED SYSTEM
Date

AIM

To design a Smart Home Automation IOT-based system

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware & Software Requirements Quantity


1 Thonny IDE 1
2 Raspberry Pi IoT Trainer Kit 1

3 Jumper Wires few

4 Micro USB Cable 1

5 LED or Relay 1

THEORY
Smart Home automation refers to the use of technology to control and automate various
functions in a home, such as lighting, heating, air conditioning, and security. In the context of IoT
(Internet of Things) and M2M (Machine-to-Machine) communications, home automation systems can
be controlled and monitored remotely through a network connection. One of the key benefits of IoT-
enabled home automation is the ability to control and monitor a wide range of devices and systems
from a single, centralized location, such as a smartphone or tablet. This can include everything from
lighting and temperature control to security cameras and alarm systems. Another advantage of IoT-
enabled home automation is the ability to remotely monitor and control devices, even when away from
home. This can be useful for controlling energy consumption and ensuring the safety and security of
the home.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

1. Define desired functionalities and components for the smart home system.
2. Choose an IoT trainer kit with necessary sensors, actuators, and communication modules.
3. Connect sensors and actuators to the IoT trainer kit as per the provided instructions.
4. Install required development tools and software for programming the kit.
5. Write firmware code to control sensors, actuators, and communication.
6. Configure communication protocols (e.g., Wi-Fi, Bluetooth) for data transfer.
7. Integrate the kit with an IoT platform for data storage and remote access.
8. Design a simple user interface for device control and monitoring.
9. Test the system functionality and debug any issues encountered.
10. Deploy the system in the desired environment and perform regular maintenance as needed.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM

import Adafruit_DHT
import requests
import RPi.GPIO as GPIO
import time

# ThingSpeak API endpoint and API key


WRITE_API_KEY = 'YOUR_THINGSPEAK_API_KEY'
WRITE_URL = 'https://api.thingspeak.com/update'

# GPIO pin for controlling LED


LED_PIN = 18
# Set up GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
def read_sensor_data():
# Read temperature and humidity from DHT11 sensor
sensor = Adafruit_DHT.DHT11
pin = 4 # GPIO pin
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
return humidity, temperature
def upload_to_thingspeak(data):
payload = {'api_key': WRITE_API_KEY, field1': data['temperature'], 'field2': data['humidity']}
try:
response = requests.post(WRITE_URL, data=payload)
print("Data uploaded to ThingSpeak successfully.")
except Exception as e:
print("Failed to upload data to ThingSpeak:", str(e))
def control_led_based_on_temperature(temperature):
if temperature > 25:
GPIO.output(LED_PIN, GPIO.HIGH) # Turn on LED
else:
GPIO.output(LED_PIN, GPIO.LOW) # Turn off LED
def main():
try:
while True:
humidity, temperature = read_sensor_data()
if humidity is not None and temperature is not None:
print("Temperature: {:.2f}°C, Humidity: {:.2f}%".format(temperature, humidity))
# Upload data to ThingSpeak
data = {'temperature': temperature, 'humidity': humidity}
upload_to_thingspeak(data)

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
# Control LED based on temperature

control_led_based_on_temperature(temperature)
else:
print("Failed to read sensor data.")

time.sleep(15) # Upload data every 15


seconds
except KeyboardInterrupt:
print("Exiting...")
finally:
GPIO.cleanup() # Clean up GPIO on program exit

if __name__ == '__main__':
main()

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. What is the purpose of a Smart Home Automation IoT-based system?


The purpose is to automate various tasks and control devices within a home remotely using
internet-connected devices and sensors.

2. What are the main components of a Smart Home Automation IoT-based system?
The main components include sensors (e.g., temperature, motion), actuators (e.g., lights, locks), a
microcontroller or development board, communication modules (e.g., Wi-Fi, Bluetooth), and an IoT
platform for data management.

3. How do sensors contribute to a Smart Home Automation system?


Sensors detect changes in the environment (e.g., temperature, motion) and provide data to the
system, enabling it to make decisions and trigger actions accordingly.

4. What role do actuators play in Smart Home Automation?


Actuators are devices that perform physical actions based on commands received from the
system. For example, turning on/off lights, locking doors or adjusting thermostats.

5. How does remote access work in a Smart Home Automation system?


Remote access allows users to control and monitor devices in their home from anywhere using
internet-connected devices such as smartphones or computers, via a user-friendly interface provided
by the IoT platform.

RESULT

Thus designed the smart home automation IoT based system successfully.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
Exp. No. 13
INTERFACING ARDUINO TO CONTROL STEPPER MOTOR
Date
AIM

To interface and control the stepper motor with Arduino UNO using IoT Trainer Kit.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware & Software Requirements Quantity


1 Arduino IDE 2.0 1
2 ARduino UNO Board

3 IoT Trainer Kit 1

4 Stepper Motor 1

5 Jumper Wires few

6 Patch Cords 1

THEORY

Stepper motors are electromechanical devices that rotate in discrete steps, making them
suitable for applications requiring precise positioning or motion control. They typically have multiple
coils that are energized in a specific sequence to generate rotational motion. The number of steps per
revolution and the sequence in which the coils are energized determine the motor's angular resolution
and direction of rotation.
To interface a stepper motor with an Arduino, need a stepper motor driver, which interprets
control signals from the Arduino and provides the necessary power and sequencing for the motor.
Stepper motor drivers can vary in complexity and features, but they generally accept input signals to
control step direction, step size, and step timing.
The Arduino generates control signals for the stepper motor driver using its digital output pins.
These signals include the step pulses, which determine the motor's movement incrementally, and the
direction signal, which determines the rotation direction. By sending a sequence of step pulses with
appropriate timing and direction changes, the Arduino can precisely control the stepper motor's
position and speed.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

1. Switch ON the Kit & Make the connections as per the procedure.
2. Write the program code in Arduino IDE 2.0
3. Now connect D13 of UNO to Stepper motor.
4. Now select sketch & upload the Program (After uploading the program message will appear---done
uploading at the bottom of the Arduino IDE software)
5. After successful uploading, the stepper motor starts to rotate at different angles.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM

#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through
Stepper my Stepper(steps Per Revolution, 8, 9, 10, 11);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
My Stepper.step(steps Per Revolution);
delay(500);
// step one revolution in the other direction:
Serial.println("counter clockwise");
My Stepper.step(-steps Per Revolution);
delay(500);
}

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. What is a stepper motor, and how does it differ from other types of motors?
A stepper motor is a type of electromechanical device that moves in discrete steps, unlike DC
motors that rotate continuously. Stepper motors have multiple coils that are energized in a specific
sequence to generate motion. This characteristic makes stepper motors suitable for applications
requiring precise positioning and control.

2. How does an Arduino control a stepper motor?


Arduino controls a stepper motor by sending digital signals to a stepper motor driver. These
signals determine the motor's step sequence, direction, and speed. The stepper motor driver interprets
these signals and applies the necessary voltage to the motor coils to generate motion.

3. What is the purpose of the Arduino Stepper Library?


The Arduino Stepper Library simplifies the process of controlling stepper motors by providing
pre-defined functions for generating step sequences, setting motor speed, and direction. It abstracts
low-level details, allowing developers to focus on high-level motor control logic.

4. How can determine the number of steps required to rotate a stepper motor by a specific angle?
The number of steps required for a given angle depends on the stepper motor's characteristics,
including its step angle and any gearing. The formula to calculate the steps per degree is:
Steps per degree=Steps per revolution/Angle per revolution

5. How can you improve the performance of a stepper motor control system?
Performance improvements can be achieved by implementing advanced control algorithms,
such as acceleration and deceleration profiles, closed-loop feedback control using encoders or sensors,
and optimizing the code for efficiency and speed.

RESULT

Thus interfaced and controlled the stepper motor with Arduino UNO using IoT Trainer Kit.
successfully

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
.Exp. No. 14
INTERFACING FLAME SENSOR WITH RASPBERRY PI
Date

AIM

To interface flame sensor to detect fire and make alarm using Buzzer With Raspberry Pi using
IoT Trainer Kit.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware & Software Requirements Quantity


1 Thonny IDE 1
2 Raspberry Pi IoT Trainer Kit 1

3 Flame sensor 1

4 Jumper Wires few

5 Patch Cords 1

6 Buzzer 1

THEORY
A flame sensor is a device that detects the presence of a flame. The most common type of
flame sensor is an infrared sensor, which detects the infrared radiation emitted by a flame. There are
also flame sensors that detect the ultraviolet radiation emitted by a flame. Flame sensors are used in a
variety of applications, including fire alarm systems, furnaces, and engines. In a fire alarm system. The
sensor has an operating voltage from 3V to 5.5V and has both digital and analog output. The
sensitivity of the digital output can be controlled by the onboard potentiometer. The detection angle of
the sensor is 60 degrees and the range is theoretically 100cm but practically you can get up to 20-
30cm.
The flame sensor is generally divided into far-infrared flame sensors and ultraviolet flame
sensors, and their working principle is to detect the heat radiation of a fire source of a specific
wavelength. The far-infrared flame sensor can detect infrared light with a wavelength in the range of
700 nanometers to 1000 nanometers.
When the infrared light wavelength is around 880 nanometers, its sensitivity reaches the
maximum. The far-infrared flame probe converts the change in the intensity of the external infrared
light into the change of the current, which is reflected as the change of the value in the range of
0~65535 through the A/D converter.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROCEDURE

1. Switch ON the Kit & Make the connections as per the diagram.
2. Connect DO of Flame Sensor to GP7 of Raspberry Pi using Patch cord.
3. Connect Buzzer Pin to GP8 of Raspberry Pi using Patch cord.
4. Now Click RUN on the Thonny IDE.
5. After successful uploading the program, appears the message at the bottom of the Thonny IDE.
6. A message appears No Flame No Fire Detected.
7. Now Make fire using Match Box or using Lighter and take it near the Flame Sensor.
8. Now the buzzer provides the sound and appears the message at the bottom of Thonny Ide which
shows Flame Present ----Fire Detected.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM

import RPi.GPIO as GPIO


import time
# Set GPIO mode and pin number
GPIO.setmode(GPIO.BCM)
FLAME_PIN = 17 # GPIO pin connected to the flame sensor's digital output
# Setup flame sensor pin as input
GPIO.setup(FLAME_PIN, GPIO.IN)
try:
while True:
# Read digital output from flame sensor
flame_detected = GPIO.input(FLAME_PIN)
# Check if flame is detected
if flame_detected:
print("Flame detected!")
else:
print("No flame detected")
# Delay before next reading
time.sleep(0.5)

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS

1. Define flame sensor and how does it work?


A flame sensor is an electronic device that detects the presence of fire or flames. It typically
consists of an IR receiver that detects infrared light emitted by flames. When exposed to flames, the
sensor's digital output changes state, indicating the presence of a flame.

2. What are the main components required to interface a flame sensor with a Raspberry Pi?
The main components include a flame sensor module, a Raspberry Pi board, and jumper wires
for connecting the sensor to the GPIO pins of the Raspberry Pi.

3. What is the role of the RPi.GPIO library in interfacing the flame sensor with the Raspberry Pi.
The RPi.GPIO library provides Python functions to control and monitor the GPIO pins of the
Raspberry Pi. It allows us to configure GPIO pins as inputs to read the digital output from the flame
sensor and react accordingly.

4. What actions can be triggered based on the detection of a flame using the Raspberry Pi?
Actions could include sounding alarms, sending notifications via email or SMS, activating fire
suppression systems, or initiating emergency shutdown procedures in critical applications.

5. What safety precautions should be taken when working with flame sensors and Raspberry Pi?
It's essential to handle flame sensors with care to prevent fire hazards or accidents. Ensure
proper wiring and power supply to the Raspberry Pi and avoid exposing the sensor to actual flames
during testing.

RESULT

Thus interfaced the flame sensor to detect fire and make alarm using Buzzer with Raspberry Pi
using IoT Trainer Kit.

R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy