Modified Embedded IoT Manual
Modified Embedded IoT Manual
LABORATORY MANUAL
Regulation–2021
(As per Anna University, Chennai Syllabus)
IIIYEAR VI SEMESTER
Prepared by Approved By
Mr.G.Sivakumar -AP/ECE Dr.C.ArunachalaPerumal
Mr.R.Ramasamy-AP/ECE Professor & Head
Department of ECE
1
RAMCO INSTITUTE OF TECHNOLOGY
Department of Electronics and Communication engineering
Department Vision, Mission, PEOs, POs & PSO
VISION
Develop futuristic technologist in Electronics and Communication Engineering to meetthe
global challenges and the societal needs of our nation.
MISSION
Educate students to become enlightened engineers with the latest know-how to take on the
challenges concerned with the society.
Equip the students with the current trends and latest technologies in the field of Electronics
and Communication Engineering to make them technically strong and ethically sound.
Constantly motivate the students and faculty members to achieve excellence in Electronics
and Communication Engineering and Research & Development activities
2
PO3: Design/Development of Solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified needswith
appropriate consideration for public health and safety, and cultural, societal, and environmental considerations.
PO4: Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data and
synthesis of the information to provide valid conclusions.
PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
PO 6: The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal, and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
PO7: Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and the need for sustainable development.
PO8: Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
PO 9: Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.
PO 10: Communication: Communicate effectively on complex engineering activities with
the engineering community and with the society at large, such as being able to comprehend
and write effective reports and design documentation, make effective presentations, and give
and receive clear instructions.
PO 11: Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
PO12: Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change.
3
RAMCO INSTITUTE OF TECHNOLOGY
Course Code & Title: CS3691 Embedded Systems and IoT Laboratory
COURSE OBJECTIVES:
COURSE OUTCOMES:
After completion of the course, it is expected that:
The students will be able to:
1. Apply the various cellular concepts like frequency reuse, channel assignments, handoff
strategies etc., in mobile communication.
2. Elaborate the characteristics of a wireless channel and evolve the system design
specifications.
3. Analyze the performance of various digital signalling schemes, equalization and diversity for
Fading channels.
4. Examine the performance of various multiple access schemes.
5. Explore the knowledge of various wireless networks in telecommunication field.
Assessment Methods followed:
4
CO-PO-PSO Matrices of the Course
Competency PO 6
PO 1 PO 3 PO 5 The PO 11
and Engineeri PO 2 Design/development PO 4 Conduct engineer PO 7 PO 8 PO 9 PO 10 PO 12 PSO1 PSO2 PSO3 PSO4
of solutions investigations and Environment Individual Life-
COs ng
knowled
Problem
analysis
of complex Modern
tool society and
Ethics
and team
Communication
Project
management
long
problems sustainability work learning
ge usage and finance
5
LIST OF EXPERIMENTS
Expt.
Title of the Experiment
No.
1. Write 8051 Assembly Language experiments using simulator
11. Log Data using Raspberry PI and upload to the cloud platform
6
Expt.No.:
Write 8051 Assembly Language experiments using simulator.
Date:
AIM:
To write a program to perform arithmetic and logical operations between two 8-bit numbers
using a microcontroller.
OBJECTIVE:
To make the student to perform basic arithmetic and logic operation using 8051
microcontroller.
Hardware/Software Required:
MCU8051 IDLE
PROCEDURE:
Ensure that you have the MCU8051 Idle Simulator software installed on your system.
Set up the simulation environment. Prepare the input data or program that you want to
simulate on the 8051 microcontroller.
Open new project -> Type program and save as .asm extension
Click Start simulation icon -> click Run Icon
START
PERFORM ADDITION/
SUBTRACTION/MULTIPLICATION/
DIVISION
STOP
7
I. ADDITION PROGRAM :
OBSERVATION:
INPUT OUTPUT
A=
A=
B=
OBSERVATION:
INPUT OUTPUT
A=
A=
B=
8
OBSERVATION:
INPUT OUTPUT
A=
4500 = 4501=
B=
OBSERVATION:
INPUT OUTPUT
A=
4500= 4501=
B=
OBSERVATION:
INPUT OUTPUT
A=
4500 =
B=
9
OBSERVATION:
INPUT OUTPUT
A=
4500 =
B=
10
III.NOT OPERATION PROGRAM:
LABEL PROGRAM COMMENTS
MOV A,#06 Initialize the A value
CPL A Complement of A
MOV DPTR,#4500 Initialize the DPTR value
MOVX @DPTR,A Move the accumulator value to DPTR
Loop SJMP Loop End of the program
OBSERVATION:
INPUT OUTPUT
A= 4500 =
11
RESULT:
Thus the assembly language program for arithmetic and logical operation was executed
successfully.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
12
PROGRAM:
MOV R0,#34H
MOVR1,#12H
CLR C
MOV A, R0
ADDC A, R1
MOV 21H, A
MOV 22H, C
END
OUTPUT:
R0 = 21 H =
R1= 22 H =
OBSERVATION:
INPUT OUTPUT
External
memory Register Data
Data
Location
4500 R0
13
Expt.No.: 02
TEST DATA TRANSFER BETWEEN REGISTERS AND MEMORY.
Date:
AIM:
To write a program to test data transfer between registers and memory using microcontroller.
APPARATUS REQUIRED
1. MCU8051 IDLE - 1
2. 8051 Microcontroller Kit - 1
3. Power Cable - 1
4. Keyboard - 1
PROCEDURE:
Ensure that the MCU8051 Idle Simulator software installed on your system.
Set up the simulation environment. Prepare the input data or program that you want to
simulate on the 8051 microcontroller.
Open new project -> Type program and save as .asm extension
Click Start simulation icon -> click Run Icon
14
TRANSFER DATA FROM INTERNAL RAM TO EXTERNAL MEMORY:
MOV R1,#25
MOV A,R1
MOV DPTR, #4600
MOVX @DPTR, A
SJMP
OBSERVATION:
INPUT OUTPUT
External
Register Data memory
Data
Location
R1 4600
15
RESULT:
Thus the data transfer between registers and memory are executed successfully.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
16
3. What is the purpose of data transfer between registers and memory in the 8051
microcontroller?
4. Explain the addressing modes supported by the MOV instruction in the 8051 Assembly
Language. How do they affect the data transfer process?
STOP
I. ADDITION PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 MOV A,#50 Initialize the A value
MOV B,#10 Initialize the B value
ADD A, B Add A & B
MOV DPTR, #4500 Initialize the DPTR value
MOVX @DPTR, A Move the accumulator value to DPTR
Loop SJMP Loop End of the program
OBSERVATION:
INPUT OUTPUT
A=
4500 =
B=
17
Expt.No.:3
BASIC ARITHMETIC AND LOGICAL OPERATION
Date:
AIM:
To write a program to perform arithmetic and logical operation between two 8-bit numbers
using 8051 microcontroller.
OBJECTIVE:
To make the student to perform basic arithmetic and logic operation using 8051
microcontroller.
APPARATUS REQUIRED
Sl.No. COMPONENTS RANGE QUANTITY
2. Power Cable - 1
3. Keyboard - 1
ALGORITHM:
a. Arithmetic Operation
Step1: Initialize memory pointer to data location.
Step2: Get the first number from memory in accumulator.
Step3: Get the second number and add/sub/mul/div it to the accumulator.
Step4: Store the answer at another memory location.
b. Logical Operation
Step1: Get the two numbers in mentioned registers using MOV instruction
Step2: AND/OR/NOT these two numbers using AND/OR/NOT instruction store the coming
output from these AND/OR/NOT operation using MOV instructions
Step3: AND/OR/NOT operation is used for masking particular bits in a byte
18
II. SUBTRACTION PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 MOV A,#50 Initialize the A value
MOV B,#10 Initialize the B value
SUBB A,B Subtract A & B
MOV DPTR,#4500 Initialize the DPTR value
MOVX @DPTR,A Move the accumulator value to DPTR
Loop SJMP Loop End of the program
OBSERVATION:
INPUT OUTPUT
A=
4500 =
B=
OBSERVATION:
INPUT OUTPUT
A=
4500 =
B=
19
20
IV. DIVISION PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 MOV A,#50 Initialize the A value
MOV B,#10 Initialize the B value
DIV AB Division A by B
MOV DPTR,#4500 Initialize the DPTR value
MOVX @DPTR,A Move the accumulator value to DPTR
INC DPTR Increment DPTR
MOV A, B Move B register value to accumulator
MOVX @DPTR,A Move accumulator to DPTR
Loop SJMP Loop End of the program
OBSERVATION:
INPUT OUTPUT
A=
4500 = 4501=
B=
OBSERVATION:
INPUT OUTPUT
A=
4500 =
B=
21
22
II.OR OPERATION PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 MOV A,#02 Initialize the A value
MOV B, #06 Initialize the B value
ORL A,B OR operation between A & B
MOV DPTR,#4500 Initialize the DPTR value
MOVX @DPTR,A Move the accumulator value to DPTR
Loop SJMP Loop End of the program
OBSERVATION:
INPUT OUTPUT
A=
4500 =
B=
OBSERVATION:
INPUT OUTPUT
A= 4500 =
23
RESULT:
Thus the assembly language program for arithmetic and logical operation was executed
successfully.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
24
PROGRAM:
ADDITION:
#include<reg51.h>
void main(void)
{
unsigned a,b,c;
a=0x08;
b=0x02;
P0=0X00;
c=a+b;
P0=c;
}
OUTPUT :
SUBTRACTION:
#include<reg51.h>
void main(void)
{
unsigned a,b,c;
a=0x0a;
b=0x02;
P0=0X00;
c=a-b;
P0=c;
}
OUTPUT:
25
Expt.No.:04 WRITE BASIC AND ARITHMETIC PROGRAMS USING
Date: EMBEDDED C
AIM:
To write 8051 Assembly Language Program for an 8-bit addition using Keil simulator and execute
it.
SOFTWARE REQUIRED:
Keilμvision5 IDE
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.
26
MULTIPLICATION:
#include<reg51.h>
void main(void)
{
unsigned a,b,c;
a=0x05;
b=0x02;
P0=0X00;
c=a*b;
P0=c;
}
OUTPUT:
DIVISION:
#include<reg51.h>
void main(void)
{
unsigned a,b,c;
a=0x08;
b=0x02;
P0=0X00;
c=a/b;
P0=c;
}
OUTPUT:
27
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
Result:
Thus embedded C program for the arithmetic operation was executed successfully.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
28
The Arduino board is shown below:
The components of Arduino UNO board are shown below:Let's discuss each component in detail.
29
Expt.No.: 5(A)
INTRODUCTION TO THE ARDUINO PLATFORM
Date:
AIM:
To study 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 vital role in creating different projects. It makes electronics accessible to
non-engineers, hobbyists, etc. 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 ATmega328Microcontroller 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. Let's discuss some common and best 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.
30
31
3) Arduino Mega:
The Arduino Mega is based on the ATmega2560 Microcontroller. The ATmega2560 is an 8-
bitmicrocontroller. We need a simple USB cable to connect to the computer and the AC to DC
adapteror battery to get started with it. It has the advantage of working with more memory space.
TheArduino Mega includes 54 I/O digital pins and 16 Analog Input/Output (I/O), ICSP header, a
resetbutton, 4 UART (Universal Asynchronous Reciever/Transmitter) ports, USB connection, and a
power jack.
4) Arduino Micro :
The Arduino Micro is based on the ATmega32U4 Microcontroller. It consists of 20 sets of pins.
The7 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,
anda 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 basedon
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.
Arduino UNO :
The Arduino UNO is a standard board of Arduino. Here UNO means 'one' in Italian. It was
named as UNO to label the first release of Arduino Software. It was also the first USB board released
by Arduino. It is considered as the powerful board used in various projects. Arduino.cc developed the
Arduino UNO board.Arduino UNO is based on an ATmega328P microcontroller. It is easy to use
compared to other boards, such as the Arduino Mega board, etc. The board consists of digital and
analog Input/Output pins (I/O), shields, and other circuits.
The Arduino UNO includes 6 analog pin inputs, 14 digital pins, a USB connector, a power jack, and
an ICSP (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.
32
33
Digital I/O pins- The digital pins have the value HIGH or LOW. The pins numbered from D0
to D13 are digital pins.
TX and RX LED's- The successful flow of data is represented by the lighting of these LED's.
AREF- The Analog Reference (AREF) pin is used to feed a reference voltage to the Arduino
UNO board from the external power supply.
Reset button- It is used to add a Reset button to the connection.
USB- It allows the board to connect to the computer. It is essential for the programming of the
Arduino UNO board.
Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz, which makes the Arduino
UNO a powerful board.
Voltage Regulator- The voltage regulator converts the input voltage to 5V.
GND- Ground pins. The ground pin acts as a pin with zero voltage.
Vin- It is the input voltage.
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) pins.
Open the LED blink example sketch: File > Examples >01.Basics > Blink.
Select your board type and port
Need to select the entry in the Tools > Board menu that corresponds to your Arduino board.
Select the serial device of the board from the Tools | Serial Port menu. This is likely to be
COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find
out, you can disconnect your board and re-open the menu; the entry that disappears should be
the Arduino board. Reconnect the board and select that serial port.
Now, simply click the "Upload" button in the environment. Wait a few seconds - you should
see the RX and TX leds on the board flashing. If the upload is successful, the message "Done
uploading." will appear in the status bar.
RESULT:
Studied the components, pin configuration, and fundamental hardware architecture aspects of
the Arduino platform.
34
PROGRAM:
BUZZER:
LED BLINKING:
void setup() {
void loop() {
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
35
Expt.No. 5(B)
INTRODUCTION TO ARDIUNO PROGRAMING
Date:
AIM:
To write and execute different Arduino programming for analog, digital signals and serial
Communication.
APPARATUSREQUIRED:
THEORY:
The DHT11 sensor is a low-cost digital temperature and humidity sensor that provides reliable and
accurate readings of temperature and humidity with a relatively simple interface. The DHT11 sensor
utilizes a capacitive humidity sensor and a thermistor to measure humidity and temperature, respectively.
The capacitive humidity sensor consists of a moisture-sensitive capacitor whose capacitance changes
with variations in humidity. When the relative humidity increases, moisture is absorbed by the sensor,
causing the dielectric constant of the sensing material to change, thereby altering the capacitance of the
capacitor. By measuring this change in capacitance, the humidity level can be determined. The DHT11
sensor also incorporates a thermistor, which is a type of resistor whose resistance varies with
temperature.
The thermistor's resistance decreases as the temperature increases and vice versa. By measuring the
resistance of the thermistor, the temperature can be calculated using a known relationship between
resistance and temperature. The DHT11 sensor has a temperature measurement range of 0°C to 50°C
with an accuracy of ±2°C and a humidity measurement range of 20% to 90% RH with an accuracy of
±5%. The DHT11 sensor operates on a wide range of voltages (typically 3.3V to 5V) and consumes very
low power, making it suitable for battery-powered applications.
CIRCUIT DIAGRAM:
36
CODE:
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11 // Other possibilities DHT21, DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
dht.begin();
}
void loop()
{
float temp = dht.readTemperature();
float humidity = dht.readHumidity();
if (isnan(temp) || isnan(humidity))
{
Serial.println("Failed to read from DHT11");
}
else
{
Serial.print("Temperature: ");
Serial.print(temp);
Serial.print(" °C, ");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}
delay(5000);
}
37
PROCEDURE:
1. Connect the Arduino Uno to your computer using the USB cable.
2. Launch the Arduino IDE software on your computer.
3. Place the DHT11 or DHT22 sensor on the breadboard.
4. Connect the power and ground pins of the sensor to the 5V and GND pins on the Arduino Uno,
respectively.
5. Connect the out pin of the sensor to analog pin A0 on the Arduino Uno.
6. Write the code in the Arduino IDE to read temperature and humidity values from the sensor.
7. Upload the code to the Arduino Uno.
8. Open the serial monitor in the Arduino IDE to observe the temperature and humidity readings.
RESULT
Thus the interfacing of a LED, Buzzer, temperature and humidity sensor with an
Arduino board successfully completed and measured real time temperature and humidity values
using DHT 11 Sensor.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
38
ROGRAM:
#define ledPin 12
int data = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(9600);
}
void loop()
{
if(Serial.available() > 0)
{
data = Serial.read();
if (data == '0')
{
digitalWrite(ledPin, LOW);
Serial.println("LED: OFF");
}
else if (data == '1')
{
digitalWrite(ledPin, HIGH);
Serial.println("LED: ON");
}
}
}
39
Expt.No. 6(A)
BLUETOOTH COMMUNICATION WITH IOT DEVICES
Date:
AIM:
To control an LED wirelessly using a Bluetooth module HC-05 and an Arduino board.
THEORY:
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.
40
41
PROCEDURE
Arduino DHT11
Pin 12 Data
Arduino HC-05
Tx Rx
Rx Tx
2. Upload the Arduino code to your Arduino board (Note: Before uploading the code, remove Tx, Rx
pins from the Arduino board and after uploading the code, connect the pins at Tx and Rx.
3. Use Bluetooth Receiver Controller application (Android) to receive the transmitted data wirelessly.
4. Pair HC-05 Bluetooth module with the smartphone application and open the terminal window.
5. Send the character '1' to turn on the LED and '0' to turn it off.
RESULT:
The experiment successfully demonstrated the interfacing of a LED and bluetooth module
with an Arduino board, enabling turning on/off the LED from the smartphone application terminal
window.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
42
PROGRAM:
ZIGBEE – TRANSMIT:
#include "SoftwareSerial.h"
SoftwareSerialXBee(2,3);
int BUTTON = 5;
boolean toggle = false; //this variable keeps track of alternative click of the button
void setup()
{
Serial.begin(9600);
pinMode(BUTTON, INPUT_PULLUP);
XBee.begin(9600);
}
void loop()
{
//When button is pressed (GPIO pulled low) send 1
if (digitalRead(BUTTON) == LOW && toggle)
{
Serial.println("Turn on LED");
toggle = false;
XBee.write('1');
delay(1000);
}
//When button is pressed second time (GPIO pulled low) send 0
else if (digitalRead(BUTTON) == LOW && !toggle)
{
Serial.println("Turn off LED");
toggle = true;
XBee.write('0');
delay(1000);
}
}
43
Expt.No. 6(B)
ZIGBEE COMMUNICATION WITH IOT DEVICES
Date:
AIM:
The aim of this experiment is to demonstrate the interfacing of an Arduino microcontroller with a
Zigbee module to establish wireless communication between devices.
5 Zigbee Module 2
THEORY:
44
ZIGBEE –RECEIVER:
#include<SoftwareSerial.h>
int led = 6;
int received = 0;
inti;
//For communicating with zigbee
SoftwareSerialzigbee(2,3);
void setup()
{
Serial.begin(9600);
zigbee.begin(9600);
pinMode(led, OUTPUT);
}
void loop()
{
//check if the data is received
if (zigbee.available() > 0)
{
received = zigbee.read();
//if the data is 0, turn off the LED
if (received == '0')
{
Serial.println("Turning off LED");
digitalWrite(led, LOW);
}
else if (received == '1') //if the data is 1, turn on the LED
{
Serial.println("Turning on LED");
digitalWrite(led, HIGH);
}
}
}
45
PROCEDURE:
1. Connect Zigbee module's TX pin to Arduino's digital pin 2 (RX) and RX pin to digital pin 3 (TX).
RESULT:
Thus the experiment, interfacing of a Zigbee module with an Arduino board has been
successfully completed, facilitating communication between two Zigbee devices connected via
Arduino.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
VIVA VOCE QUESTIONS:
1. What are the primary considerations when selecting a communication method for IoT
applications?
2. List the key features and characteristics of Zigbee communication.
3. What is Bluetooth, and how is it used for short-range wireless communication in IoT devices?
4. What are the advantages and limitations of using Zigbee for IoT applications?
46
Program:
}
}
if (mySerial.available() > 0)
{
Serial.write(mySerial.read());
}
}
void SendMessage()
{
mySerial.println("AT+CMGF=1"); // Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milliseconds or 1 second
mySerial.println("AT+CMGS=\"+xxxxxxxxxxx\"\r"); //Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module"); // The SMS text you want to send delay(100);
mySerial.println((char)26); // ASCII code of CTRL+Z delay(1000);
}
void DialCall()
{
mySerial.println("ATD+xxxxxxxxxxxx;"); // ATDxxxxxxxxxx; -- watch out here for semicolon at the end!!
delay(100);
47
}
Expt.No. 6(C)
GSM COMMUNICATION WITH IOT DEVICES
Date:
AIM:
APPARATUS REQUIRED:
THEORY:
GSM SIM module is an ultra-compact and reliable wireless module. It provides a complete
Dual-band GSM/GPRS solution in a Surface Mount Technology (SMT) module, which can be easily
integrated into customer applications. This module offers an industry- standard interface and delivers
excellent performance for voice, SMS, Data, and Fax over GSM/GPRS 900/1800 MHz frequencies.
The SIM module is a GSM/GPRS modem that allows devices to communicate over cellular networks.
It works by integrating the necessary hardware and software to establish a connection to the GSM
network and facilitate data transmission.
PROCEDURE:
In this section we have listed the steps to successfully boot our SIM GSM Module:
• Insert the SIM card into the GSM module and lock it.
• Now wait for some time (say 1 minute) and see the blinking rate of the status LED’ or ‘network
LED’ (the GSM module will take some time to establish a connection with the mobile network).
48
OUTPUT:
49
• Once the connection is established successfully, the status/network LED will blink continuously
every 3 seconds. You may try making a call to the mobile number of the SIM card inside the GSM
module. If you hear a ring back, the GSM module has successfully established a network connection.
GND GND
RESULT :
The experiment successfully demonstrated the interfacing of a GSM module with an Arduino
board, enabling sending and receiving messages between devices.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
VIVA VOCE QUESTIONS:
1. What are some common applications of GSM modules in real-world scenarios?
2. What factors should be considered when selecting a GSM module for a project?
3. What are the main components of a typical GSM module?
4. What are the advantages and limitations of using GSM modules for wireless communication
compared to other technologies?
50
PIN DIAGRAM:
51
Expt.No. 7
INTRODUCTION TO RASPBERRY PI PLATFORM AND
Date: PYTHON PROGRAMMING
AIM :
The objective of this experiment is to introduce the Raspberry Pi platform and Python
programming.
APPARATUS REQUIRED:
5. Personal Computer - 1
THEORY:
Introduction to Raspberry Pi 3 B+:
The Raspberry Pi 3 Model B+ is a versatile single-board computer renowned for its compact
size and powerful performance. Released in 2018 as an upgrade to its predecessor, it boasts a 64-bit
quad-core processor running at 1.4 GHz, offering enhanced processing capabilities for various
computing tasks. Notable improvements include dual-band wireless LAN supporting 2.4GHz and
5GHz frequencies, along with Bluetooth 4.2/BLE, ensuring faster and more reliable networking.
Gigabit Ethernet over USB 2.0 further enhances connectivity options, complementing its array of
USB ports, HDMI, and GPIO pins. With 1GB LPDDR2 SDRAM and support for microSD storage,
the Raspberry Pi 3 Model B+ accommodates a wide range of projects, from home automation to IoT
applications. The official operating system for the Raspberry Pi is called Raspberry Pi OS (formerly
known as Raspbian). Raspberry Pi OS is a Debian-based Linux distribution optimized for the
Raspberry Pi hardware.
Features:
Quad Core 1.2GHz Broadcom BCM2837 64bit CPU.
1GB RAM.
BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board.
100 Mbps Base Ethernet.
40-pin extended GPIO.
52
PROGRAM:
GPIO.setmode(GPIO.BCM)
LED_PIN = 17
GPIO.setup(LED_PIN, GPIO.OUT)
try:
while True:
GPIO.output(LED_PIN, GPIO.HIGH)
GPIO.output(LED_PIN, GPIO.LOW)
except KeyboardInterrupt:
53
4 USB 2.0 ports.
4 Pole stereo output and composite video port.
Full size HDMI.
CSI camera port for connecting a Raspberry Pi 3 B+ camera.
DSI display port for connecting a Raspberry Pi 3 B+ touchscreen display.
Micro SD port for loading your operating system and storing data.
Upgraded switched Micro USB power source up to 2.5A.
Raspberry Pi mainly consists of the following blocks:
Processor: Raspberry Pi uses Broadcom BCM2835 system on chip which is an ARM processor and
Video core Graphics Processing Unit (GPU). It is the heart of the Raspberry Pi which controls the
operations of all the connected devices and handles all the required computations.
HDMI: High Definition Multimedia Interface is used for transmitting video or digital audio data to a
computer monitor or to digital TV. This HDMI port helps Raspberry Pi to connect its signals to any
digital device such as a monitor digital TV or display through an HDMI cable.
GPIO ports: General Purpose Input Output ports are available on Raspberry Pi which allows the user
to interface various I/P devices.
Audio output: An audio connector is available for connecting audio output devices such as
headphones and speakers.
USB ports: This is a common port available for various peripherals such as a mouse, keyboard, or
any other I/P device. With the help of a USB port, the system can be expanded by connecting more
peripherals.
SD card: The SD card slot is available on Raspberry Pi. An SD card with an operating system
installed is required for booting the device.
Ethernet: The ethernet connector allows access to the wired network, it is available only on the
model B of Raspberry Pi.
Power supply: A micro USB power connector is available onto which a 5V power supply can be
connected.
Camera module: Camera Serial Interface (CSI) connects the Broadcom processor to the Pi camera.
Display: Display Serial Interface (DSI) is used for connecting LCD to Raspberry Pi using 15 15-pin
ribbon cables. DSI provides a high-resolution display interface that is specifically used for sending
video data.
54
55
A powerful feature of the Raspberry Pi is the row of GPIO (general-purpose input/output) pins along
the top edge of the board. A 40-pin GPIO header is found on all current Raspberry Pi boards
Voltages:
Two 5V pins and two 3.3V pins are present on the board, as well as a number of ground pins (GND),
which can not be reconfigured. The remaining pins are all general-purpose 3.3V pins, meaning
outputs are set to 3.3V and inputs are 3.3V-tolerant.
Outputs:
A GPIO pin designated as an output pin can be set to high (3.3V) or low (0V).
Inputs :
A GPIO pin designated as an input pin can be read as high (3.3V) or low (0V). This is made easier
with the use of internal pull-up or pull-down resistors. Pins GPIO2 and GPIO3 have fixed pull-up
resistors, but for other pins this can be configured in software.
Other functions :
As well as simple input and output devices, the GPIO pins can be used with a variety of alternative
functions, some are available on all pins, others on specific pins.
Pulse width modulation (PWM) is a modulation technique that generates variable-width pulses to
represent the amplitude of an analog input signal.
SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0 (GPIO8), CE1 (GPIO7)
SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0 (GPIO18); CE1 (GPIO17);
CE2 (GPIO16)
56
57
I2C :
I2C stands for Inter-Integrated Circuit. It is a bus interface connection protocol incorporated into
devices for serial communication. I2C stands for Inter-Integrated Circuit. It is a bus interface
connection protocol incorporated into devices for serial communication.
Serial:
TX (GPIO14); RX (GPIO15)
GPIO pinout :
A GPIO reference can be accessed on your Raspberry Pi by opening a terminal window and running
the command pinout. This tool is provided by the GPIO Zero Python library, which is installed by
default in Raspberry Pi OS.
Serial interface:
The serial interface on Raspberry Pi has received (Rx) and transmit (Tx) pins for
communication with serial peripherals.
Raspberry Pi has multiple serial ports. The first two are called primary and secondary. By default,
primary appears on GPIO 14 (transmit) and 15 (receive) of the J8. Secondary is used by bluetooth, on
Raspberry Pi that support bluetooth. Each port is driven by a UART. On every Raspberry Pi there are
at least two of them: UART0 and UART1. The assignment of which UART drives which port
depends on the model and its configuration.
Thonny IDE :
Thonny is an open-source IDE which is used to write and upload programs to different
development boards such as Raspberry Pi Pico, Raspberry Pi 1 , Raspberry Pi 2, Raspberry Pi 3,
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.
58
59
PROCEDURE:
2. Open the Thonny IDE and create new file. Type the program, save and run.
RESULT :
Studied the components, pin configuration, and fundamental hardware architecture aspects of
the Raspberry Pi platform.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
60
PROGRAM FOR DHT Sensor:
import time
import board
import adafruit_dht
dhtDevice = adafruit_dht.DHT11(board.D4, use_pulseio=False) ## Raspberry pi 4 - gpio4
while True:
try:
# Print the values to the serial port
temperature_c = dhtDevice.temperature
temperature_f = temperature_c * (9 / 5) + 32humidity = dhtDevice.humidity
print("Temp: {:.1f} F / {:.1f} C Humidity: {}% ".format(temperature_f, temperature_c, humidity))
except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
print(error.args[0])
time.sleep(2.0)
continue
except Exception as error:
dhtDevice.exit()
raise error
time.sleep(2.0)
OUTPUT:
61
Expt.No. 8
INTERFACING SENSORS WITH RASPBERRY PI
Date:
AIM:
1 Thonny IDE 1
5 IR sensor 1
6 Temperature sensor 1
Theory:
An infrared (IR) sensor is a device that detects infrared radiation emitted or reflected by
objects in its field of view. It typically consists of an IR emitter and an IR detector. The emitter emits
infrared radiation, while the detector detects the radiation reflected or emitted by objects. IR sensors
are commonly used for various applications such as motion detection, proximity sensing, and
temperature measurement. They work based on the principle that different materials emit and reflect
different amounts of infrared radiation at different temperatures. By measuring the intensity of
infrared radiation, IR sensors can determine the presence or absence of objects, as well as their
temperature.
The DHT11 sensor is a digital temperature and humidity sensor that utilizes a capacitive
humidity sensor and a thermistor to measure environmental conditions. It can detect temperature in
the range of 0°C to 50°C with an accuracy of ±2°C, and humidity in the range of 20% to 80% with an
accuracy of ±5%. The sensor outputs data in a digital format, making it easy to interface with
microcontrollers like Arduino. The DHT11 sensor is widely used in applications requiring precise
monitoring of temperature and humidity levels, such as weather stations, HVAC systems, and
environmental monitoring devices.
62
PROGRAM FOR IR SENSOR:
gpio.setmode(gpio.BOARD)
while True:
sensor=gpio.input(36)
if sensor==1:
sleep(0.1)
elif sensor==0:
print(" detect")
OUTPUT :
63
PROCEDURE:
1. Once Raspberry Pi 3 B+ is booted up to GUI, Connect the keyboard and Mouse to USB slots.
2. Now you can write your programs at Thonny Python IDE. Menu → Programming → Thonny
Python IDE. File → New. You can write your Program here and save.
IR Sensor
GPIO Pin Components
GPIO16 IR sensor
DHT11 Sensor
GPIO4 DHT11 Sensor
4. Execute the program at terminal only by following command
5. Check the temperature and humidity values and the presence of objects in the screen.
RESULT
Thus the experiment, interfacing of IR and DHT11 sensors with Raspberry PI board using
python programming was implement successfully. Real-time temperature and humidity readings were
obtained as a result.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
VIVA VOCE QUESTIONS:
1. What are the different types of sensors commonly used with Raspberry Pi?
2. How do you physically connect sensors to a Raspberry Pi?
3. How do you read sensor data using GPIO programming in Python on a Raspberry Pi?
4. Explain the challenges and techniques involved in interfacing analog sensors with Raspberry
Pi.
5. Provide examples of sensors used for measuring environmental parameters.
64
Program:
Arduino :
int led=13;
void setup()
{
pinMode(led, OUTPUT);
Serial.begin(9600); //default baud rate for bt 38400
}
void loop()
{
if(Serial.available())
{
int a=Serial.parseInt();
Serial.println(a);
if (a==1)
{
digitalWrite(led, HIGH);
}
if (a == 0)
{
digitalWrite(led, LOW);
}
}
}
Raspberry Pi Bluetooth:
import serial
import time
bluetooth=serial.Serial("/dev/rfcomm7",9600)
while True:
a=input("enter:-")
string='X{0}'.format(a)
bluetooth.write(string.encode("utf-8"))
65
Expt.No. 9
COMMUNICATE BETWEEN ARDUINO AND RASPBERRY PI
Date: USING ANY WIRELESS MEDIUM
AIM:
5. Personal Computer - 2
Theory:
Procedure
2. Open Thonny IDE in another PC and write slave code and save.
66
67
Arduino
UNO Pin Bluetooth Module
D2 Tx
D3 Rx
D13 LED
4. Arduino:
Write the arduino program and upload it
As per connection bluetooth to arduino TX-RX , RX-TX
5. Raspberry :
CTRL + Z
sudo rfcomm help ## rfcomm command will display
sudo rfcomm bind 7 mac address ## enter command paste your mac ad
Connect the Bluetooth on raspberry pi ,right corner click Bluetooth icon and pair
RESULT:
The experiment successfully executed the communication between Arduino and Raspberry PI
using Bluetooth wireless medium to blink a LED with Raspberry PI board using python
programming.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
VIVA VOCE QUESTIONS:
What is wireless communication, and why is it useful in connecting Arduino and Raspberry
Pi?
What is Bluetooth, and how does it enable wireless communication between devices?
Describe the different Bluetooth profiles and their use cases in IoT applications.
Can you list some common wireless communication technologies used for IoT projects?
68
69
Expt.No. 10
SETUP A CLOUD PLATFORM TO LOG THE DATA
Date:
AIM:
Theory:
Procedure
Step1: Navigate to the Thing Speak website using your web browser
(Link: https://thingspeak.com/login?skipSSOCheck=true).
Step 2: Login using the credentials if an existing account is present or else create a new account.
Step 3: Once Logged in, create new channel. Give a channel name and required field names and save
channel.
Step 4: Go to the Sharing tab and select ‘Share channel view with everyone’.
Step 5: Under API Keys tab, note the ‘Write API Key’ for enabling communication from any device.
70
71
72
73
RESULT
The experiment successfully set up a cloud platform in Things Speak to log the data from IoT
devices.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
74
Figure 1: Signup for ThingSpeak
75
Expt.No. 11
LOG DATA USING RASPBERRY PI AND UPLOAD TO THE
Date: CLOUD PLATFORM
AIM:
To write the program Log Data using Raspberry PI and upload it to the cloud platform
1 Thonny IDE 1
Theory:
To log data using a Raspberry Pi and upload it to a cloud platform utilizing the Raspberry Pi
CPU temperature, begin by setting up your Raspberry Pi and writing a Python script to read the CPU
temperature from the appropriate system file. Modify the script to upload the CPU temperature data
to the chosen cloud platform using their respective APIs, ensuring proper authentication and data
formatting for security.
Procedure:
Step 1: Signup for ThingSpeak
For creating your channel on ThingSpeak you first need to sign up on ThingSpeak. In case if you
already have account on ThingSpeak just sign in using your id and password.For creating your
account go to www.thinspeak.com. Click on signup if you don’t have account and if you already
have account click on sign in. After clicking on signup fill your details. Shown in Fig. 1. After this
verifies your E-mail id and click on continue.
Step 2: Create a Channel for Data
Once you Sign in after your account verification, Create a new channel by clicking “New Channel”
button. Shown in Fig. 2. After clicking on “New Channel”, enter the Name and Description of the
data you want to upload on this channel. Now enter the name of your data (like Temperature or
pressure) in Field1. If you want to use more than one Field you can check the box next to Field option
and enter the name and description of your data. After this click on save channel button to save your
details.
76
Figure 3: Create a Channel for Data
Program:
import httplib
import urllib
import time
key = "XXXXXXXXXXXXXXXX" # 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()
77
Step 3: Getting API Key in ThingSpeak
To send data to ThingSpeak, we need an unique API key, which we will use later in our python code
to upload our CPU data to Thing Speak Website. Click on “API Keys” button to get your unique API
key for uploading your CPU data.Shown in Fig. 3. Now copy your “Write API Key”. We will use this
API key in our code.
78
Output :
79
RESULT:
The experiment successfully set up a cloud platform in Things Speak to log the CPU
temperature data from Raspberry PI board to the cloud.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
80
Connection Diagram:
81
Expt.No. 12
DESIGN AN IOT BASED SYSTEM
Date:
Aim:
To design and implement a simple home automation system using electronic components and
microcontrollers.
APPARATUS REQUIRED:
1. NodeMCU ESP8266 - 1
2. Computer system - 1
3. Power Cable - 1
4. Keyboard - 1
5. VBMB – 15 Kit - 1
Relay Module
Jumper wires
Theory:
Home automation refers to the use of technology to automate and control household appliances and
systems remotely or automatically. It involves the integration of various electronic devices, sensors,
actuators, and communication technologies to enhance convenience, comfort, energy efficiency, and
security within a home.
Procedure:
Place the relay module on the breadboard and connect it to the controller according to the
datasheet or manufacturer's instructions.
Connect sensors and actuators to the appropriate pins on the Arduino. For example, connect
the motion sensor to a digital input pin, and connect LED bulbs to relay outputs for
controlling lights.
82
PROGRAM:
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BLYNK_WRITE(V0)
{
int value = param.asInt();
Serial.println(value);
if(value == 1)
{
digitalWrite(D5, LOW);
Serial.println("LED ON");
}
if(value == 0)
{
digitalWrite(D5, HIGH);
Serial.println("LED OFF");
}
}
BLYNK_WRITE(V1)
{
int value = param.asInt();
Serial.println(value);
if(value == 1)
{
digitalWrite(D6, LOW);
Serial.println("LED ON");
83
}
if(value == 0)
{
digitalWrite(D6, HIGH);
Serial.println("LED OFF");
}
}
BLYNK_WRITE(V2)
{
int value = param.asInt();
Serial.println(value);
if(value == 1)
{
digitalWrite(D7, LOW);
Serial.println("LED ON");
}
if(value == 0)
{
digitalWrite(D7, HIGH);
Serial.println("LED OFF");
}
}
BLYNK_WRITE(V3)
{
int value = param.asInt();
Serial.println(value);
if(value == 1)
{
digitalWrite(D8, LOW);
Serial.println("LED ON");
}
if(value == 0)
{
digitalWrite(D8, HIGH);
Serial.println("LED OFF");
}
}
void setup()
84
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(D5,OUTPUT);
pinMode(D6,OUTPUT);
pinMode(D7,OUTPUT);
pinMode(D8,OUTPUT);
}
void loop()
{
Blynk.run();
}
RESULT:
Thus, the home automation system was design using electronic components and
microcontrollers.
Marks Marks
Description
Allotted Obtained
Performance 25
Record 15
Viva-Voce 10
Total 50
85