Iot Manual
Iot Manual
ENGINEERING
MUTHAYAMMAL
EDUCATIONAL
INSTITUTIONS
LAB MANUAL
VI SEMESTER
(Academic Year – 2024-2025)
Prepared by Approved by
Mrs.S.Suganya M.E., Prof.Dr.C.Nagarajan M.Tech.,Phd.,
AP/EEE HOD/EEE
OCS352 IOT CONCEPTS AND APPLICATIONS L T P C
2 0 2 3
OBJECTIVES:
The main learning objective of this course is to prepare the students able to:
To apprise students with basic knowledge of IoT that paves a platform to understand physical
and logical design of IoT.
To teach a student how to analyse requirements of various communication models and
protocols for cost-
Effective design of IoT applications on different IoT platforms.
To introduce the technologies behind Internet of Thing (IoT).
To explain the students how to code for an IoT application using Arduino/Raspberry Pi open
platform.
To apply the concept of Internet of Things in real world scenario.
CO2 – Understand the communication models and various protocols for IoT
CO4 – Apply data analytics and use cloud offerings related to IoT.
CO/
PO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 PSO3
3 3 2 2 2 1 - - - - - 2 3 2 1
CO1
3 3 2 2 1 3 - - - - - 2 3 3 3
CO2
3 3 2 2 2 1 - - - - - 3 2 2 2
CO3
CO4 2 3 3 1 1 3 - - - - - 1 3 1 2
CO5 2 3 1 1 2 2 - - - - - 1 3 1 1
EX. NO: 1 INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING
Aim:
Apparatus Required:
1. 1 X LED
2. 1 X Resistor, 330 Ohm
3. Breadboard
4. Arduino UNO R4 or earlier versions.
5. Jumper wires
THEORY:
Introduction:
Select the serial device of the Arduino board from the Tools | Serial Port menu. This is likely
to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serialports). To find out,
you can disconnect your Arduino 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. (Note: If you have an ArduinoMini, NG, or other board, you'll
need to physically press the reset button on the board immediately before clicking the upload button on
the Arduino Software).
A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board
start to blink (in orange). If it does, congratulations! You've gotten Arduino up-and- running.
If you have problems, please see the troubleshooting suggestions.
Coding:
Program 1:
Program 2:
void setup()
{
pinMode(1 3,OUTPU T);
}
void loop()
{
digitalWrite(13,HIGH);
delay(100 0);
digitalWrite(13,LOW );
delay(100 0);
}
RESULT:
Aim:
To write the Arduino program for communication between two trainers and control
the ledby switch.
Apparatus Required:
1. Arduino UNO
2. AtMega328 microcontroller
3. Zigbee Transmitter (ZTx)
4. Zigbee Receiver (ZRx)
5. USB cables
6. LEDs
Theory:
XBee(2,3);
void setup()
{
Serial.begin(9600 );
pinMode(SW1,INPUT);
XBee.begin(9600 );
}
void loop()
{
if (digitalRead(SW1) == HIGH)
{
Serial.println("Turn on
LED");
XBee.write('1');
delay(1000);
}
else if (digitalRead(SW1) == LOW)
{
Serial.println("Turn off
LED");
XBee.write('0');
delay(1000);
}
}
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);
}
//if the data is 1, turn on the
LED
else if (received == '1')
{
Serial.println("Turning on LED");
digitalWrite(led, HIGH);
} } }
RESULT:
Thus, the Arduino is interfaced to the Zigbee module and the output is verified.
EX.NO:03 INTERFACING ARDUINO TO GSM MODULE
Aim:
To write the Arduino program for detect the flame and send a sms.
Apparatus Required:
Theory:
#include <SoftwareSerial.h>
RESULT:
Thus, the Arduino is interfaced to the GSM module and the output is verified.
EX.NO:04 INTERFACING ARDUINO TO BLUETOOTH MODULE
Aim:
To write the Arduino program for Electronics Notice Board.
Apparatus Required:
1. Arduino UNO
2. AtMega328 Microcontroller
3. HC-05 Bluetooth Module.
4. LED.
5. Breadboard.
6. Resistors - 1K & 2K Ohm.
7. Connecting Wires.
Note: DIP Switch S1 in 16X2 LCD Display Block should be all ON position.
Theory:
The HC-05 is a class 2 Bluetooth module designed for transparent wireless serial
communication. It is pre-configured as a slave Bluetooth device. Once it is paired to a master
Bluetooth device such as PC, smart phones and tablet, its operation becomes transparent to the
user.
Program:
RESULT:
Thus, the Arduino is interfaced to the Bluetooth module and the output is verified.
EX.NO:05 INTRODUCTION TO RASPBERRY PI PLATFORM AND
PYTHON
PROGRAMMING
Aim:
To write the python program for Turn on & off a LED.
Apparatus Required:
1. Raspberry Pi
2. PiCo W
3. LED
4. Connecting Wires
Theory:
Python is the official programming language of the Raspberry Pi. It is known for its two unique
characteristics: cross-platform compatibility and easy-to-understand syntax. Unlike lower-level
languages like C and C++, Python uses a Python interpreter that translates the Python program into
machine-specific instructions. So as long as you have a Python interpreter on your computer, you can
run any Python program written on whatever machine. Moreover, compared to other languages, the
syntax is simple. Syntax is the arrangement of symbols, words, and phrases needed to make a Python
program work. The friendly Python syntax makes programming fun, which is perfect for a credit card
computer that is made to acquaint people in the field of computer science.
Program:
Import machine
Import time
While (True):
Led. On ()
led.off ()
time. Sleep(1)
RESULT:
Thus, the LED was turned on and off and the output was verified.
EX.NO:06 INTERFACING SENSORS TO RASPBERRY PI
Aim:
To write the python program for measure the obstacle distance in cm using Ultrasonic Sensor.
Apparatus Required:
1. Raspberry Pi
2. PiCo W
3. Ultrasonic Sensor (HC-SR04)
4. Connecting Wires
Theory:
Program:
RESULT:
Thus, the sensors were interfaced to Raspberry Pi and the output was verified.
EX.NO:07 COMMUNICATE BETWEEN ARDUINO AND RASPBERRY PI USING ANY
WIRELESS MEDIUM
1. Raspberry Pi
2. PiCo W
3. Arduino UNO
4. AtMega328 Microcontroller
5. Zigbee Transmitter (ZTx)
6. Zigbee Receiver (ZRx)
7. Connecting Wires
RESULT:
Thus, the communication between Arduino and Raspberry Pi using ZigBee wireless medium
is done and the output was verified.
EX.NO:08 SETUP A CLOUD PLATFORM TO LOG THE DATA
Aim:
Apparatus Required:
1. Arduino UNO
2. Arduino IDE 1.8.2 or higher
3. Thingspeak Account
4. Thinhspeak Library
5. Arduino Wifi Shield 101
6. Photocell
7. Temperature Sensor (This example uses a TMP36)
8. 10K Ohm Resistor
Procedure:
Step-1: The first step is to create an account. The good part is that ThingSpeak does not require a
Credit card (like AWS/Azure) for signing up. You may sign up here.
Step-2: After signing up on ThingSpeak, login here.
Step-3: Create a new ThingSpeak channel by clicking on the "New Channel".
Step-4: In the new channel creation screen, fill out the details of the device from which data will be
received.
Step-5: In the new channel creation screen, scroll down further and make this channel public. So that
you can post data to it.
Step-6: After saving the channel, the channel details screen will get displayed (as shown below). Notice
that there will be 5 tabs: Private View, Public View, Channel Settings, API Keys and Data
Import/Export. You are all set! Browse through them to get a feeling of the contents. Make note of the
Channel ID, as you will need it for posting and reading data to ThingSpeak.
Step-7: Now we will see how to log data and read data to and from this channel. Browse to the API
Keys tab for your channel. Note down the read and write api_keys (as shown below), as you will need
it for posting and reading data to ThingSpeak. I have obscured the api keys for my channel intentionally.
Never share your channel api keys with unintented recipients as they might spam the channel
inadvertently.
Step-8: Use the following URL format to log data to ThingSpeak.
https://api.thingspeak.com/update.json?api_key=<your-write-api-key>&field1=58
Upon hitting the above URL, the data '58' will get logged in the ThingSpeak IoT cloud.
Correspondingly, you can also see the logged data in the ThingSpeak channel's Private/Public.
Step-9: Use the following URL format to read the logged data from ThingSpeak.
http://api.thingspeak.com/channels/<your-channel-id>/feeds.json?key=<your-read-api-
key>&results=1
On hitting the above URL in the browser, you will receive the last posted data row from ThingSpeak.
Code:
RESULT:
Thus, the IoT cloud platform ThinkSpeak was set up to log the data and the output was
verified.
EX.NO:09 LOG DATA USING RASPBERRY PI AND UPLOAD TO THE CLOUD
PLATFORM
Aim:
To write the python program for Log Temperature Data using Raspberry Pi and upload to
the Cloud Platform.
Apparatus Required:
1. Raspberry Pi
2. PiCo W
3. LM35 Temperature Sensor
Theory:
LM35 sensor uses the basic principle of a diode, whereas the temperature increases, the
voltage across a diode increases at a known rate. By precisely amplifying the voltage change, it is
easy to generate an analog signal that is directly proportional to temperature.
Program:
Import network
import urequests
from time import sleep
import machine
sensor_temp = machine.ADC(26)
#Network Initialization
ssid = "IElec Systems"
password = "9840838264"
def ConnectWiFi():
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while wlan.isconnected() == False:
print('Waiting for connection...')
sleep(1)
ip = wlan.ifconfig()[0]
print(f'Connected on {ip}')
return ip
#Connect to Network
ip = ConnectWiFi()
#ThingSpeak Initialization
server = "http://api.thingspeak.com/"
apikey = "74085BCYRZG0G9YJ"
field = 1
#Main Program
while True:
temperature = sensor_temp.read_u16()
temperature = ((temperature/65535)*3300)/10
print(temperature)
url = f"{server}/update?api_key={apikey}&field{field}={temperature}"
request = urequests.post(url)
request.close()
sleep(20)
RESULT:
Thus, the data was logged using Raspberry Pi and uploaded to the Cloud Platform.
EX.NO:10 DESIGN AN IOT BASED SYSTEM
Aim:
To write a program to design a Home Automation system using Ardunio and Bluetooth control.
Apparatus Required
1. PIR Motion Sensor (generic)
2. HC-05 Bluetooth Module
3. LDR (Light Dependent Resistor)
4. LED (generic)
5. Arduino UNO
6. Temperature Sensor
7. Relay (generic)
8. Jumper wires (generic)
9. Apps and platforms
10. Arduino IDE
11. Windows 10
Theory:
An Arduino UNO will control devices and reads sensor data. The figure "Room
Architecture" depicts how the Arduino UNO will connects with the devices and sensors. Room
have multiple controllable devices (i.e. Light(s), Fan, Wall Socket(s), etc.), one PassiveIR (to
detect human presence in the room), one temperature sensor (LM35 to collect room temperature)
and LDR (to detect light intensity near room window).
PIR:
PIR sensor consists of three pins, ground, signal, and power at the side or bottom.
Generally, the PIR sensor power is up to 5V, but, the large size PIR modules operate a relay instead
of direct output.
Program:
if(digitalRead(8)==HIGH) //pir
{
digitalWrite(9,HIGH);
}
Else
{ digitalWrite(9,LOW);}
digitalWrite(trigPin, HIGH); //ULTRA
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance >= 10 || distance <= 0)
{
// Serial.println("no object detected");
digitalWrite(ledPin,LOW);
}
else
{
Serial.println("object detected \
");
Serial.print("distance= ");
Serial.print(distance);
digitalWrite(ledPin,HIGH);
} //ULTRA
if(digitalRead(2)==HIGH) //gate first
{
my.write(0); //servo
}
Else
{
my.write(90); //servo
}
analogRead(5); //ldr
float a = analogRead(5);
Serial.println(a);
if (a <=200) {
digitalWrite(4,1);
Serial.println("LDR is DARK, LED is ON");
}
else {
digitalWrite(4,0);
Serial.println(" ----- ");
} //ldr
if (Serial.available()) //bluetooth
{
val = Serial.read();
Serial.println(val);
if(val == 'TV')
digitalWrite(3,HIGH);
else if(val == 'tv')
digitalWrite(3,LOW);
} //Bluetooth
}
RESULT:
Thus, the program was written to design a Home Automation system using Ardunio
and Bluetooth control and the output was verified.