Embedded System and IOT Lab Manual Final
Embedded System and IOT Lab Manual Final
CSE(CYBER SECURITY)
Subject Code & Title: CS3691 EMBEDDED SYSTEM AND IOT LABORATORY
Certified that this is a bonafide record of work done by the above student in the laboratory
during the year 2024 - 2025.
❖ This Observation contains the basic diagrams of the circuits enlisted in the syllabus of the
CS3691 EMBEDDED SYSTEMS AND IOT course, along with the design of various
components of the circuit and controller.
❖ The aim of the experiment is also given at the beginning of each experiment. Once the
student can design the circuit as per the circuit diagram, he/she is supposed to go through
the instructions carefully and do the experiments step by step.
❖ They should note down the readings (observations) and tabulate them as specified.
❖ It is also expected that the students prepare the theory relevant to the experiment referring
to prescribed reference books/joumals in advance, and carry out the experiment after
understanding thoroughly the concept and procedure of the experiment.
❖ They should get their observations verified and signed by the staff within two days and
prepare & submit the record of the experiment when they come to the laboratory in the
subsequent week.
❖ The record should contain experiment No., Date, Aim, Apparatus required, Theory,
Procedure, and result on one side (i.e., Right-hand side, where rulings are provided) and
Circuit diagram, Design, Model Graphs, Tabulations, and Calculations on the other side
(Le., Left-hand side, where no rulings are provided)
❖ The students are directed to discuss & clarify their doubts with the staff members as and
when required. They are also directed to follow strictly the guidelines specified
CS3691 EMBEDDED SYSTEMS AND IOT
SYLLABUS
COURSE OBJECTIVES;
LIST OF EXPERIMENTS
OUTCOMES:
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
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 the 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. 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
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.
1
You can download this tool from https://sourceforge.net/projects/mcu8051ide/files/.
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 the OS.
Completely free and with user guide, examples, etc.
You can download this simulator from the https://www.edsim51.com/index.html.
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.
You can download this tool from https://www.acebus.com/win8051.htm
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.
You can download and get more information from https://www.keil.com/c51/.
To start writing a new program, you need to create a new project. Navigate to project
2
—> New µVision project. Then save the new project in a folder.
After saving the file, a new window will pop up asking you to select your microcontroller.
As discussed, we are using AT89C51/AT89C51ED2/AT89C52, so select this controller
under the Microchip section (as Atmel is now a part of Microchip).
Select ‘Yes’ in the next pop-up, as we do not need this file in our project.
Our project workspace is now ready! From here, we need to create a file where we can write
our C code. Navigate to File —> New. Once the file is created, save it with .c extension in
the same project folder.
3
Next, we have to add that .c or .asm file to our project workspace. Select Add Existing
Files and then select the created .c or .asm file to get it added.
4
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.
PROGRAM:
ORG 0000H
CLR C
MOV A, #20H
ADD A, #21H
MOV R0, A
END
OUTPUT:
RESULT:
5
EXP NO: 2 Test data transfer between registers and memory
DATE:
AIM: To write and execute an Assembly language program to transfer data between registers
and memory.
SOFTWARE REQUIRED:
S.No Software Requirements Quantity
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.
PROGRAM:
ORG 0000H
CLR C
MOV R0,
#55H MOV
R1, #6FH
MOV A, R0
MOV 30H, A
MOV A, R1
MOV 31H, A
END
6
OUTPUT:
RESULT:
7
EXP NO: 3 ALU operations
DATE:
AIM: To write and execute the ALU program using the Keil simulator.
SOFTWARE REQUIRED:
S.No Software Requirements Quantity
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.
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
8
//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
XRL A, B
MOV 48H, A
//NOT
MOV A, #45H
CPL A
MOV 49H, A
END
OUTPUT:
RESULT:
9
EXP NO: 4 WRITE BASIC PROGRAMS USING EMBEDDED C
DATE:
AIM: To write a basic embedded C program to control a port 0 pin 0 connected to an 8051
microcontroller using a Keil simulator.
SOFTWARE REQUIRED:
S.No Software Requirements Quantity
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 .c 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.
PROGRAM:
#include<REG51.h>
int i,j;
sbit LED = P2^0;
void main()
{
while(1)
{
LED = 0;
for(j=0;j<10000;j++);
LED = 1;
for(j=0;j<10000;j++);
}
}
10
OUTPUT:
RESULT:
11
EXP NO: 5 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
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 .c 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.
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);
}
12
OUTPUT:
RESULT:
13
EXP NO: 6 INTRODUCTION TO THE ARDUINO PLATFORM
DATE:
AIM: To study the basics of Arduino Uno board and Arduino IDE 2.0 software.
SOFTWARE REQUIRED:
S.No Software Requirements Quantity
Arduino is a open-source hardware, and software platform used to for creating electronic
projects. It designs and manufactures microcontroller kits and single-board interfaces for
building electronics 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. The most
standard and popular board used over time is Arduino UNO having an ATmega328
Microcontroller. The Arduino Boards are organized using the Arduino Integrated
Development Environment (IDE), which can run on various platforms.
2) Arduino Nano
The Arduino Nano is a small Arduino board based on ATmega328P. It is small in size compared
to the UNO board
3) Arduino Mega
The Arduino Mega is based on the 8 b i t ATmega2560 Microcontroller. 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
14
4) Arduino Micro
The Arduino Micro is based on the ATmega32U4 Microcontroller. It consists of 20 sets of pins.
5) Arduino Leonardo
specification of the Arduino Leonardo is the same as the Arduino Micro
6) Arduino Due
The Arduino Due is the first Arduino board based on the 32-bit ARM core. It consists of
54 Digital Input/Output pins and 12 Analog pins.
7) Arduino Lilypad
The Arduino LilyPad was initially created for wearable projects and e-textiles. It is based
on the ATmega168 Microcontroller.
8) Arduino Bluetooth
The Arduino Bluetooth board is based on ATmega168 Microcontroller. It is also named as
Arduino BT board. This can be programmed over the Bluetooth as a wireless connection.
9) Arduino Diecimila
The Arduino Diecimila is also based on the ATmeg628 Microcontroller. The Diecimila was
initially developed to mark the 10000 delivered boards of Arduino.
10) Arduino Zero
The Arduino Zero is generally called as the 32-bit extension of the Arduino UNO.
11) Arduino Esplora
The Arduino Esplora boards allow easy interfacing of sensors and actuators.
15
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 automatically draws power
from the external power supply or from USB. It also has an Arduino-integrated WIFI module. 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 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.
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.
16
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.
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. The
ICSP header consists of 6 pins.
The structure of the ICSP header is shown below:
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
17
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.
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. step by step, procedure to
download and install the software is given below
Download the editor
Downloading the Arduino IDE 2.0 is done through the Arduino Software page. Download
URL: https://www.arduino.cc/en/software
Requirements
Windows - Win 10 and newer, 64 bits
Linux - 64 bits
Mac OS X - Version 10.14: "Mojave" or newer, 64 bits
Installation Windows version: To install the Arduino IDE 2.0 on a Windows computer,
simply run the file downloaded from the software page. Follow the instructions in the
installation guide. The installation may take several minutes. You can now use the Arduino
IDE 2.0 on your 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
18
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.
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.
Installing a core
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
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".
19
You have now successfully downloaded and installed a core on your machine, and you
can start using your Arduino board!
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 upload a 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
1. Open the Arduino IDE 2.0.
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.
2. Click on the verify tool (checkmark). Since we are verifying an empty sketch, we can
be sure it is going to compile. After a few seconds, we can see the result of the action
in the console (black box in the bottom).
20
3. 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).
4. With the board selected, we are good to go! Click on the upload button, and it
will start uploading the sketch to the board.
5. 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
How to install and use a library with the Arduino IDE 2.0
21
4. When it is finished, we can take a look at the library in the library manager column,
where it should say "INSTALLED".
Including a library
To use a library, you first need to include the library at the top of the sketch. Almost all libraries
come with already made examples that you can use. These are accessible through File >
Examples > {Library} > {Example}. In this example, we are choosing the RTCZero
> SimpleRTC. The chosen example will now open up in a new window, and you can start
using it however you want to.
RESULT:
22
EXP NO: 7 INTRODUCTION TO ARDUINO PROGRAMMING
DATE:
AIM: To write and execute different Arduino programming for analog, digital signals
and serial communication.
.
HARDWARE AND SOFTWARE REQUIRED:
S.No Software Requirements Quantity
PROCEDURE:
Assemble the components on the breadboard as per the circuit design.
Ensure proper connections with the Arduino board (e.g., power, ground, and
input/output pins).
Write the Arduino code (sketch) for the experiment.
Connect the Arduino board to the computer via USB.
Open the Arduino IDE (or equivalent platform).
Verify the code for errors using the Verify/Compile button.
Upload the code to the Arduino board using the Upload button.
Power the Arduino and observe the circuit in action.
Monitor outputs (e.g., LEDs blinking, serial monitor readings) as specified in the
experiment.
Check connections, components, and code for errors if the circuit does not perform as
expected. Use tools like the serial monitor for debugging.
Document the experiment's outcome, including readings, observations, or behavior.
CONNECTION
Arduino UNO pin Arduino development board
2 LED
23
PROGRAM:
DIGITAL WRITE:
void setup() {
pinMode(2, OUTPUT);
}
void loop()
{
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
}
CONNECTION OUTPUT
Arduino UNO pin Arduino
development board
2 LED
5 SW1
DIGITAL READ:
void setup() {
pinMode(2, OUTPUT);
pinMode(5, INPUT_PULLUP);
}
void loop() {
int sw=digitalRead(5);
if(sw==1)
{
for(int i=0; i<5; i++)
{
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
}
}
else {
digitalWrite(2, LOW);
}
}
24
CONNECTION
Arduino UNO pin Arduino development board Joy stick module
2 LED
VCC or 5V +5V
GND GND
A0 VRx or VRy
OUTPUT
ANALOG READ:
void setup() {
pinMode(2, OUTPUT);
Serial.begin(9600);
}
void loop() {
int joystick=analogRead(A0);
Serial.println(joystick);
if(joystick>800)
digitalWrite(2, HIGH);
else
digitalWrite(2, LOW);
delay(500);
}
CONNECTION
Arduino UNO pin Arduino development board
3 LED
PWM Pins: 3, 5, 6, 9, 10, 11
ANALOG WRITE:
void setup() {
pinMode(3, OUTPUT);
}
void loop() {
for(int i=0; i<256;i++)
25
{
analogWrite(3,i);
delay(20);
}
for(int i=255; i>=0;i--)
{
analogWrite(3,i);
delay(20);
}
}
CONNECTION
Arduino UNO pin Arduino development board
4 LED
SERIAL COMMUNICATION:
void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT);
}
void loop() {
if(Serial.available()>0) {
char data=Serial.read();
Serial.println(data);
if(data=='1')
{
digitalWrite(4,HIGH);
}
else if(data=='2'){
digitalWrite(4,LOW);
}
}
}
OUTPUT
RESULT:
26
EXP NO: 8 Different communication methods with IoT
devices (Bluetooth)
DATE:
Bluetooth:
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.
27
PROCEDURE
Assemble the components on the breadboard as per the circuit design.
Ensure proper connections with the Arduino board (e.g., power, ground, and
input/output pins).
Write the Arduino code (sketch) for the experiment.
Connect the Arduino board to the computer via USB.
Open the Arduino IDE (or equivalent platform).
Verify the code for errors using the Verify/Compile button.
Upload the code to the Arduino board using the Upload button.
Power the Arduino and observe the circuit in action.
Monitor outputs (e.g., LEDs blinking, serial monitor readings) as specified in the
experiment.
Check connections, components, and code for errors if the circuit does not perform as
expected. Use tools like the serial monitor for debugging.
Document the experiment's outcome, including readings, observations, or behavior.
CONNECTIONS
PROGRAM:
#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)
28
{
char data=mySerial.read();
Serial.println(data);
if(data=='1'){
digitalWrite(4,HIGH);
Serial.println("LED ON");
}
else if(data=='2'){
digitalWrite(4,LOW);
Serial.println("LED OFF");
}
}
}
OUTPUT
OUTPUT OU
RESULT:
29
EXP NO: 9 Different communication methods with IoT
devices (Zigbee)
DATE:
Zigbee:
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 is commonly used in home automation, industrial control, and
smart energy applications.
PROCEDURE
Assemble the components on the breadboard as per the circuit design.
Ensure proper connections with the Arduino board (e.g., power, ground, and
input/output pins).
Write the Arduino code (sketch) for the experiment.
Connect the Arduino board to the computer via USB.
Open the Arduino IDE (or equivalent platform).
Verify the code for errors using the Verify/Compile button.
Upload the code to the Arduino board using the Upload button.
Power the Arduino and observe the circuit in action.
Monitor outputs (e.g., LEDs blinking, serial monitor readings) as specified in the
experiment.
Check connections, components, and code for errors if the circuit does not perform as
expected. Use tools like the serial monitor for debugging.
Document the experiment's outcome, including readings, observations, or behavior.
30
CONNECTIONS:
TRANSMITTER:
RECEIVER:
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);
}
RECEIVER SIDE:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx
void setup() {
mySerial.begin(9600);
Serial.begin(9600);
pinMode(4, OUTPUT);
}
31
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);
}
}
OUTPUT
RESULT:
32
EXP NO: 10 INTRODUCTION TO THE RASPBERRY PI
PLATFORM & INTRODUCTION TO PYTHON
DATE:
PROGRAMMING
1 Thonny IDE 1
2 Raspberry Pi Pico Development Board 1
3 Jumper Wires Few
4 LED 1
33
On-chip PLL allows variable core frequency
264kByte multi-bank high-performance SRAM
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.
You can realize the popularity of Thonny IDE from this that it comes pre-installed in
Raspian OS which is an operating system for a Raspberry Pi. It is available to install on r
Windows, Linux, and Mac OS.
34
4. Follow the installation wizard to complete the installation process. You just need to click
“Next”.
5. After completing the installation, open Thonny IDE. A window as shown in the following
figure should open.
CONNECTIONS:
35
PROGRAM
LED:
from machine import Pin
import time
LED = Pin(16, Pin.OUT)
while True:
LED.value(1)
time.sleep(1)
LED.value(0)
time.sleep(1)
OUTPUT
CONNECTIONS:
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)
36
sleep(1)
OUTPUT
CONNECTIONS:
OUTPUT
RESULT:
37
EXP NO: 11 INTERFACING SENSORS WITH RASPBERRY PI
DATE:
AIM: To interface the IR sensor and Ultrasonic sensor with Raspberry Pico.
1 Thonny IDE 1
2 Raspberry Pi Pico Development Board 1
3 Jumper Wires Few
4 IR Sensor 1
5 Ultrasonic sensor 1
PROCEDURE:
Flash the Raspberry Pi OS onto a microSD card using tools like Raspberry Pi Imager
Insert the microSD card into the Raspberry Pi.
Attach a monitor, keyboard, mouse, and n/w (Wi-Fi or Ethernet) to the Raspberry Pi.
Connect the power supply to the Raspberry Pi and boot it up.
Complete the initial setup wizard (set up locale, Wi-Fi, password, etc.).
Update the system software using: sudo apt update && sudo apt upgrade
Assemble external components (e.g., sensors, actuators) on a breadboard. Use GPIO
pins to connect the Raspberry Pi to the circuit as specified.
Write the code for the project using Python
Execute the program on the Raspberry Pi terminal or an IDE (e.g., Thonny).
Power the Raspberry Pi and observe the system in action
Monitor outputs (e.g., LEDs, sensors, or data on the screen) for expected behavior.
Verify all connections, components, and code logic if the project fails to work.
Analyze the results against the project’s objective.
CONNECTIONS
Raspberry Pi Pico pins Raspberry Pi PICO IR Sensor module
development board
GP16 BUZZER -
GP15 - OUT
- 5V VCC
- GND GND
38
PROGRAM:
IR Sensor:
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)
CONNECTIONS
ULTRASONIC SENSOR:
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)
39
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:
buzzer.value(0)
utime.sleep(0.01)
utime.sleep(0.5)
OUTPUT
RESULT:
40
EXP NO: 12 COMMUNICATE BETWEEN ARDUINO AND
RASPBERRY PI
DATE:
AIM: To write and execute the program to Communicate between Arduino and
Raspberry PI using any wireless medium (Bluetooth)
1 Thonny IDE 1
2 Raspberry Pi Pico Development Board 1
3 Jumper Wires Few
4 Arduino Uno Development Board 1
5 Micro USB Cable 1
6 Bluetooth module 2
PROCEDURE
CONNECTIONS
Arduino UNO pins Arduino development board Bluetooth module
2 - Tx
3 GND Rx
- 5V GND
- 5V
PROGRAM:
MASTER ARDUINO:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3); //rx,tx
void setup() {
mySerial.begin(9600);
}
void loop() {
mySerial.write('A');
delay(1000);
mySerial.write('B');
delay(1000);
}
41
Raspberry Pi Pico pins Raspberry Pi PICO Bluetooth module
development board
GP16 LED -
VCC - 5V
GND - GND
GP1 - Tx
GP0 - Rx
SLAVE
RASPBERRY PI PICO
from machine import Pin, UART
uart = UART(0, 9600)
led = Pin(16, Pin.OUT)
while True:
if uart.any() > 0:
data = uart.read()
print(data)
if "A" in data: led.value(1)
print('LED on \n')
uart.write('LED on \n')
elif "B" in data:
led.value(0)
print('LED off \n')
uart.write('LED off \n')
OUTPUT
RESULT
42
EXP NO: 13 CLOUD PLATFORM TO LOG THE DATA
DATE:
AIM: To set up a cloud platform to log the data from IoT devices.
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 and control them using a mobile app.
Step 1: Visit blynk.cloud and create a Blynk account on the Blynk website. Or you can simply
sign in using the registered Email ID.
Step 3: Give any name to the Template such as Raspberry Pi Pico W. Select ‘Hardware
Type’ as Other and ‘Connection Type’ as WiFi. So a template will be created now.
43
Step 4: Now we need to add a ‘New Device’ now. Select a New Device from ‘Template’.
Select the device from a template that you created earlier and also give any name to the
device. Click on Create.
44
Step 5: Now go to the dashboard and select ‘Web Dashboard’.
From the widget box drag a switch and place it on the dashboard screen.
Step 6:
On the switch board click on Settings and here you need to set up the Switch. Give any title
to it and Create Datastream as Virtual Pin.
45
Configure the switch settings as per the image below and click on create.
With this Blynk dashboard set up, you can now proceed to program the Raspberry Pi Pico W
board to control the LED.
To control the LED with a mobile App or Mobile Dashboard, you also need to setup the
Mobile Phone Dashboard. The process is similarly explained above
Install the Blynk app on your smartphone The Blynk app is available for iOS and Android.
Download
and install the app on your smartphone. then need to set up both the Mobile App and the
Mobile Dashboard in order to control the LED with a mobile device. The process is explained
above.
1. Open Google Play Store App on an android phone
2. Open Blynk.App
3. Log In to your account (using the same email and password)
RESULT:
46
EXP NO: 14 Log Data using Raspberry PI and upload it to the cloud
platform
DATE:
AIM: To write and execute the program Log Data using Raspberry PI and upload it to the
cloud platform
PROCEDURE
PROGRAM:
from machine import Pin, I2C, ADC
from utime import sleep_ms
from pico_i2c_lcd import I2cLcd
import time
import network
import BlynkLib
adc = machine.ADC(4)
i2c=I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
I2C_ADDR=i2c.scan()[0]
lcd=I2cLcd(i2c,I2C_ADDR,2,16)
wlan = network.WLAN()
wlan.active(True)
wlan.connect("Wifi_Username","Wifi_Password")
BLYNK_AUTH = 'Your_Token'
47
# connect the network
wait = 10
while wait > 0:
if wlan.status() < 0 or wlan.status() >= 3:
break
wait -= 1
print('waiting for connection...')
time.sleep(1)
lcd.clear()
while True:
ADC_voltage = adc.read_u16() * (3.3 / (65536))
temperature_celcius = 27 - (ADC_voltage - 0.706)/0.001721
temp_fahrenheit=32+(1.8*temperature_celcius)
print("Temperature in C: {}".format(temperature_celcius))
print("Temperature in F: {}".format(temp_fahrenheit))
lcd.move_to(0,0)
lcd.putstr("Temp:")
lcd.putstr(str(round(temperature_celcius,2)))
lcd.putstr("C ")
lcd.move_to(0,1)
lcd.putstr("Temp:")
lcd.putstr(str(round(temp_fahrenheit,2)))
lcd.putstr("F")
time.sleep(5)
blynk.virtual_write(3, temperature_celcius)
blynk.virtual_write(4, temp_fahrenheit)
blynk.log_event(temperature_celcius)
blynk.run()
time.sleep(5)
48
OUTPUT
RESULT:
49
EXP NO: 15 Design an IOT-based system
DATE:
PROCEDURE
Flash the Raspberry Pi OS onto a microSD card using tools like Raspberry Pi Imager
Insert the microSD card into the Raspberry Pi.
Attach a monitor, keyboard, mouse, and n/w (Wi-Fi or Ethernet) to the Raspberry Pi.
Connect the power supply to the Raspberry Pi and boot it up.
Complete the initial setup wizard (set up locale, Wi-Fi, password, etc.).
Update the system software using: sudo apt update && sudo apt upgrade
Assemble external components (e.g., sensors, actuators) on a breadboard. Use GPIO
pins to connect the Raspberry Pi to the circuit as specified.
Write the code for the project using Python
Execute the program on the Raspberry Pi terminal or an IDE (e.g., Thonny).
Power the Raspberry Pi and observe the system in action
Monitor outputs (e.g., LEDs, sensors, or data on the screen) for expected behavior.
Verify all connections, components, and code logic if the project fails to work.
Analyze the results against the project’s objective.
50
CONNECTIONS
PROGRAM:
import time
import network
import BlynkLib
from machine import Pin
led=Pin(16, Pin.OUT)
wlan = network.WLAN()
wlan.active(True)
wlan.connect("Wifi_Username","Wifi_Password")
BLYNK_AUTH = 'Your_Token'
# connect the network
wait = 10
while wait > 0:
if wlan.status() < 0 or wlan.status() >= 3:
break
wait -= 1
print('waiting for connection...')
time.sleep(1)
51
# Handle connection error
if wlan.status() != 3:
raise RuntimeError('network connection failed')
else:
print('connected')
ip=wlan.ifconfig()[0]
print('IP: ', ip)
#"Connection to Blynk"
#Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
# Register virtual pin handler
@blynk.on("V0") #virtual pin V0
def v0_write_handler(value): #read the value
if int(value[0]) == 1:
led.value(1) #turn the led on
else:
led.value(0) #turn the led off
while True:
blynk.run()
OUTPUT
RESULT:
52
ADDITIONAL EXPERIMENTS
LCD DISPLAY:
CONNECTIONS
DHT 11 Sensor:
53
CONNECTIONS
SERVO MOTOR:
pwm = PWM(Pin(1))
pwm.freq(50)
while True:
for position in range(1000,9000,50):
pwm.duty_u16(position)
sleep(0.01)
for position in range(9000,1000,-50):
pwm.duty_u16(position)
sleep(0.01)
CONNECTIONS
STEPPER MOTOR:
from machine import Pin
from time import sleep
IN1 = Pin(12,Pin.OUT)
IN2 = Pin(13,Pin.OUT)
IN3 = Pin(14,Pin.OUT)
IN4 = Pin(15,Pin.OUT)
54
for step in sequence:
for i in range(len(pins)):
pins[i].value(step[i])
sleep(0.001)
CONNECTIONS
55