ESIOT Lab Manual - 240503 - 132515
ESIOT Lab Manual - 240503 - 132515
[REGULATION-2021]
ANNAUNIVERSITY
CHENNAI-600025
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
LABORATORY MANUAL
REGULATION : 2021
YEAR/SEMESTER : III/VI
R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VISION AND MISSION OF THE INSTITUTION
VISION
MISSION
2. Make students employable through rigorous career guidance and training programs.
VISION
MISSION
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 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
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)
R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
COURSE OBJECTIVE
To build a small low-cost embedded and IoT system using Arduino/Raspberry Pi/ open
platform.
COURSE OUTCOME
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.
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.,).
5. Students must inspect their position for possible damage and report immediately to the faculty any
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.
10. Arrange your chairs properly before leaving from the lab.
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:
6. Explore different communication methods with IoT devices (Zigbee, GSM, Bluetooth)
11. Log Data using Raspberry PI and upload to the cloud platform
TOTAL: 30 PERIODS
R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
COURSE OUTCOMES:
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.
.
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:
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.
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:
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:
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.
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:
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:
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.
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.
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:
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.
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
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.
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
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.
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.
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.
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.
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.
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:
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.
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:
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.
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.
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.
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
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.
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.
.
THEORY
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
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.
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.
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.
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
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.
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
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
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.
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.
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.
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.
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.
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
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
THEORY
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
PROGRAM
from machine import Pin
import time
R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
CONNECTIONS
RGB:
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.
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.
1 Thonny IDE 1
2 Raspberry Pi IoT trainer Kit 1
3 Jumper Wires few
5 IR Sensor 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
PROGRAM
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()
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
PROGRAM
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.
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.
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.
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
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
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.
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
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.
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.
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.
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
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.
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
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).
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.
3 DHT 11 sensor 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
4. Enter the channel ID (Channel Created in Thingspeak) and Writekey for DHT11 Sensor ( to be
R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
PROGRAM
import sys
import Adafruit_DHT
import urllib.request
import time
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
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
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
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.")
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
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.
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.
4 Stepper Motor 1
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.
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.
3 Flame sensor 1
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
R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
OUTPUT
R2021 / CSE / CS3691 – EMBEDDED SYSTEM & IOT/ III YEAR / VI SEM
VIVA QUESTIONS
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