IOT Lab Manual
IOT Lab Manual
IOT Lab Manual
1
EXPERIMENT NO. 01
AIM:
To write a program to sense the available networks using Arduino.
Practical Objectives:
1. Sense the available networks using Arduino.
COMPONENTS REQUIRED:
1. WiFi Module or ESP 8266 Module.
2. Connecting cable or USB cable.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Start ->Arduino IDE -1.8.8
STEP 3: Then enter the coding in Arduino Software. STEP 4:
Compile the coding in Arduino Software.
STEP 5: Connect the USB cable to WiFi module.
STEP 6: Select tools -> select board -> Module node Mch.0.9CE ESP
1.2 modules -> select port.
STEP 7: Upload the coding in ESP Module node Mch.0.9CE and open serial
monitor to view the available networks.
STEP 8: Stop the process.
BLOCK MODULE:
2
CODING:
#include <ESP8266WiFi.h>
void setup()
{ Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.disconnect(); delay(100);
Serial.println("Setup done");
}
void loop() { Serial.println("scan
start"); int n =
WiFi.scanNetworks();
Serial.println("scan done"); if
(n == 0) {
Serial.println("no networks found");
} else {
Serial.print(n);
Serial.println(" networks found"); for
(int i = 0; i < n; ++i) { Serial.print(i +
1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " :
"*"); delay(10);
3
}
4
}
Serial.println(""); delay(5000);
}
OUTPUT:
RESULT:
Thus the output for sensing the available networks using Arduino has successfully
executed.
5
EXPERIMENT NO. 02
AIM:
To write a program to measure the distance using ultrasonic sensor and
make LED blink using Arduino.
Practical Objectives:
1. Measure the distance using ultrasonic sensor and make LED blink using Arduino.
COMPONENTS REQUIRED:
1. Ultra sonic sensor.
2. Jumper wires.
3. Connecting cable or USB cable.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Start ->Arduino IDE -1.8.8
STEP 3: Then enter the coding in Arduino Software. STEP 4:
Compile the coding in Arduino Software.
STEP 5: In Arduino board, connect VCC to power supply 5V and connect to
ground as in
PIN gnd and connect trig to trigpio =9, connect echo to echopin=10 using jumper
wires.
STEP 6: Connect the Arduino board with USB cable to the system. STEP 7: Select
tools -> select board ->Arduino Nano -> select processor -> AT Mega 328 p and the
select port.
STEP 8: Upload the coding in Arduino board and now for the LED to blink.
STEP 9: Then, the output will be displayed in the serial monitor. STEP 10: Stop
the process.
6
BLOCK MODULE:
CODING:
const int trigPin = 9; const int
techoPin = 10; long duration;
int distance; void
setup()
{
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin,
INPUT); // Sets the echoPin as an Input Serial.begin(9600); // Starts the serial
communication
}
void loop()
{
digitalWrite(trigPin, LOW);// Clears the trigPin delayMicroseconds(2);
digitalWrite(trigPin, HIGH);// Sets the trigPin on HIGH state for 10 micro
seconds delayMicroseconds(10);
digitalWrite(trigPin, LOW); duration =
pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2; // distance= (Time x Speed of Sound in Air (340
m/s))/2
7
Serial.println(distance);
delay(1000);
}
OUTPUT:
RESULT:
Thus the output for measuring the distance using ultrasonic sensor and LED
blink using Arduino has successfully executed.
8
EXPERIMENT NO. 03
AIM:
To write a program to detects the vibration of an object with sensor
using Arduino.
Practical Objectives:
ALGORITHM:
STEP 1: Start the process. STEP 2:
StartArduino.1.8.8.
STEP 3: Then enter the coding in Arduino software.
STEP 4: In Arduino board, connect vcc to power supply 5V and connect do to
analog pin A0 and connect gnd to ground gnd using jumper wires.
STEP 5: Connect the arduino board with the USB cable to the system.
STEP 6: Select toolsSelect boardArduino Nano gndSelect processor AT
mega 823p and then select the port.
STEP 7: Upload the coding to the Arduino board.
STEP 8: Then the output will be displayed in the serial monitor. STEP 9: Stop
the process.
9
BLOCK DIAGRAM:
CODING:
Int ledPin = 13; Int
vib=A0; void
setup()
{
pinMode(ledPin, OUTPUT);
pinMode(vib, INPUT); //set EP input for measurement Serial.begin(9600); //init serial
9600
}
void loop()
{
long measurement=pulseIn (vib, HIGH);
delayMicroseconds(50);
Serial.print("VIB:v001:hertz: " );
Serial.println(measurement);
}
10
OUTPUT:
RESULT:
Thus the output for detecting the vibrations of an object with vibration sensor
using Arduino has been successfully executed.
11
EXPERIMENT NO. 04
AIM:
To write a program to connect with the available Wi-Fi using
Arduino
Practical Objectives:
1. CONNECT WITH THE AVAILABLE WI-FI USING ARDUINO
COMPONENTS REQUIRED:
1. ESP 8266 module or Wi-Fi module
2. Connecting cables or USB cables
ALGORITHM:
STEP1: Start the process.
STEP2: StartArduino IDE 1.8.8.
STEP3: Include the file directory ESP 8266 in Arduino.
STEP4: Then enter the coding to Wi-Fi module or ESP 8266 module. STEP5:
Then enter the coding in Arduino software.
STEP6: Connect the USB cable to the Wi-Fi module and the Arduino connected
system with available network.
STEP7: Select toolsSelect boardNode MCU 0.9C ESP-12 module and then
SelectPort.
STEP8: Upload the coding to ESP 8266 module and open serial monitor to
View the available network connects IP address.
STEP9: Stop the process.
BLOCK DIAGRAM:
12
13
CODING:
#include <ESP8266WiFi.h> // Include the Wi-Fi library
const char* ssid = "Error"; // The SSID (name) of the Wi-Fi network you want to
connect to
const char* password = "networkerror"; // The password of the Wi-
Fi network void
setup() {
Serial.begin(115200); // Start the Serial communication to send messages to
the computer
delay(10); Serial.println('\n');
WiFi.begin(ssid, password); // Connect to the
network Serial.print("Connecting to ");
Serial.print(ssid);
Serial.print(“...") int i
= 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to
connect delay(1000);
Serial.print(++i); Serial.print(' ');
}
void loop() {
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to
the computer
}
}
OUTPUT:
30
RESULT:
Thus the output for connecting with the available Wi-Fi using Arduino has been
successfully executed.
31
EXPERIMENT NO. 05
AIM:
To write a program to sense a finger when it is placed on the board Arduino.
Practical Objectives:
32
BLOCK DIAGRAM:
CODING:
int Led = 13 ; // define LED Interface
int buttonpin = 7; // define Metal Touch Sensor Interface int val ;
// define numeric variables val
void setup ()
{
Serial.begin(9600);
pinMode (Led, OUTPUT) ; // define LED as output interface pinMode
(buttonpin, INPUT) ; // define metal touch sensor output interface
}
void loop ()
{
val = digitalRead (buttonpin) ;
//Serial.println(val);
if (val == 1) // When the metal touch sensor detects a signal, LED flashes
33
{
digitalWrite (Led, HIGH);
Serial.println(val); delay(1000);
}
else
{
digitalWrite(Led,LOW);
Serial.println(val); delay(1000);
}
}
OUTPUT:
RESULT:
Thus the output for sensing a finger when it is placed in board Arduino has been
successfully executed.
34
EXPERIMENT NO. 06
AIM:
To write a program to get temperature notification using Arduino.
Practical Objectives:
1. Temperature notification using Arduino.
COMPONENTS REQUIRED:
1. Temperature and humidity sensor.
2. Jumper wires
3. Connectivity cable or USB cable.
ALGORITHM:
STEP 1: Start the process. STEP 2:
Start Arduino 1.8.8
STEP 3: Include the DHT library to the Arduino software. STEP 4: Then
enter the coding in Arduino software.
STEP 5: Complete the coding in Arduino.
STEP 6: In Arduino board connect VCC to the power supply 5V and connect SIG
to digital signal DT and connect SND to ground GND using jumper wires.
STEP 7: Connect the arduino board with USB cable to the system. STEP 8:
Select tools Selected.
STEP 9: Upload the coding to arduino board. Then the output will be
displayed in the serial monitor.
STEP 10: Stop the process.
35
BLOCK DIAGRAM:
CODING:
#include <dht.h>
#define dht_apin A0 // Analog Pin sensor is connected to dht DHT;
void setup()
{
pinMode(A0,INPUT);
Serial.begin(9600);
delay(500);
Serial.println("DHT11 Humidity & temperature Sensor\n\n"); delay(1000);
}
void loop()
{
DHT.read11(dht_apin);
Serial.print("THS:th01:None:");
Serial.print(DHT.humidity);
Serial.print("%,");
36
//Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("degC");
delay(2000);//Wait 5 seconds before accessing sensor again.
}
OUTPUT:
RESULT:
Thus the output to get temperature notification using Arduino has successfully
executed.
37
EXPERIMENT NO. 07
AIM:
To write a program for LDR to vary the light intensity of LED using Arduino.
Practical Objectives:
1. LDR to vary the light intensity of LED using Arduino.
ALGORITHM:
STEP1: Start the program.
STEP2: Start →Arduino 1.88[IDE].
STEP3: Enter the coding in Arduino software. STEP4:
Compile the coding in the Arduino software.
STEP5: From LDR light sensor module, connect VCC to power supply 5V and
connect to digital pin D3 and connect GND to ground gnd using jumper wires to
arduino board.
STEP6: For LED, connect D to digital pin D2 and connect GND to ground GND
using jumper wires to arduino board.
STEP7: Show the variance of lights intensity in LED we use LDR light sensor
module.
STEP8: Stop the process.
BLOCK DIAGRAM
38
CODING:
const int ldr_pin = 3; const int
led_pin = 2; void setup() {
pinMode(ldr_pin, INPUT);
pinMode(led_pin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if ( digitalRead( ldr_pin ) == 1) {
digitalWrite(led_pin, HIGH);
}
else {
digitalWrite(led_pin , LOW);
}
Serial.println(digitalRead( ldr_pin ));
delay(100);
}
OUTPUT:
39
LED OUTPUT: LED OFF
LED ON
RESULT:
Thus the output for LDR to vary the light intensity of LED using Arduino has
successfully executed.
40
EXPERIMENT NO. 08
AIM:
To write a program to install MySQL database in Raspberry pi.
Practical Objectives:
41
OUTPUT:
42
RESULT:
Thus the output to install MySQL database in Raspberry pi has
successfully executed.
43
EXPERIMENT NO. 09
AIM:
To write a program to work with basic MySQL queries by fetching data from
database in Raspberry pi.
Practical Objectives:
Sql queries by featching data from database in Respberry pi.
COMPONENTS REQUIRED:
1. Raspberry pi
2. HDMI
3. Micro USB power input
ALGORITHM:
STEP1: Start the process.
STEP2: Connect micro USB power input to Raspberry pi.
STEP3: Connect HDMI to the system to act as monitor for Raspberry pi.
STEP4: Connect USB port 2.0 to mouse and keyboard.
STEP5: When enter the coding in the terminal to update and upgrade package using
commands.
STEP6: Create database in MySQL and basic SQL queries by fetching data from
database by using insert, update and delete queries.
STEP7: Stop the process.
CODING:
sudomysql -u root –p
CREATE DATABASE exampledb;
CREATE USER 'exampleuser'@'localhost' IDENTIFIED BY 'pimylifeup';
CREATE TABLE Books(Id INTEGER PRIMARY KEY, Title
VARCHAR(100),Author VARCHAR(60));
INSERT INTO Books(Title, Author) VALUES (1,‘War and Peace’,‘Leo Tolstoy’);
SELECT * FROM Books;
UPDATE Books SET Author='Lev Nikolayevich Tolstoy' WHERE Id=1;
44
DELETE FROM Books2 WHERE Id=1;
OUTPUT:
| Id | Title | Author |
+ + + +
+ + + +
+ + + +
| Id | Title | Author |
+ + + +
| 1 | War and Peace | Leo Tolstoy |
+ + + +
+ + + +
| Id | Title | Author |
+ + + +
| 1 | War and Peace | Lev Nikolayevich Tolstoy |
+ + + +
| Id | Title | Author |
+ + + +
+ + + +
RESULT:
The output to fetch data from database using SQL queries in Raspberry pi
has successfully executed.
45
EXPERIMENT NO. 10
AIM:
To write a program to switch light on when the input is 1 and switch the light off
when the input is 0 using Raspberry pi.
Practical Objectives:
1. Switch light on AND off based on the input of user using Respberry pi.
COMPONENTS REQUIRED:
1. Raspberry pi
2. Breadboard
3. Jumperwires
4. Resistor
5. LED
ALGORITHM:
46
CODING:
sudo apt-get install python-pip sudo apt-get install python-dev sudo pip install
RPi.GPIO
sudo –i #python
importRPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False) GPIO.setup(18,GPIO.OUT)
ip=int(input("enter the value: ")) ifip==1:
print "LED on" GPIO.output(18,GPIO.HIGH)
time.sleep(1) elifip==0:
print "LED off"
GPIO.output(18,GPIO.LOW) time.sleep(1)
OUTPUT:
47
RESULT:
Thus the output to switch light ON/OFF using Raspberry pi has been successfully
executed.
EXPERIMENT NO. 11
Practical Objectives:
1. To design a Digital frequency meter to measure the frequency in any AC
electrical circuit using Arduino and display the values in LCD display.
COMPONENTS REQUIRED:
2 16 x 2 LCD display 1
3 ACS712 Voltage sensor 1
48
4 9/12V Battery 1
5 Computer with Arduino IDE software 1
A) DC VOLTMETER:
B) DC AMMETER:
A) Code for DC
50
Serial.println(average);
}
PROCEDURE:
EXPERIMENT NO. 12
Practical Objectives:
1. To design a system to control the direction of three phase induction
motor through IOT.
COMPONENTS REQUIRED:
51
S. No Name of the equipment Quantity
1 Arduino Uno 1
2 16 x 2 LCD display 1
3 Diode (IN4007) 1
4 Resistor (47K/1W) 1
5 Opto-coupler 1
6 Computer with Arduino IDE software 1
7 jumper cables As
required
ARDUINO CODE:
52
{
lcd.clear(); lcd.setCursor(0,0); lcd.print("Frequency Meter");
high_time=pulseIn(input,HIGH); low_time=pulseIn(input,LOW);
time_period=high_time+low_time; time_period=time_period/1000;
frequency=1000/time_period; lcd.setCursor(0,1); lcd.print(frequency);
lcd.print(" Hz"); delay(500);
}
PROCEDURE:
53