Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

IOT Lab Manual

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 37

LIST OF EXPERIMENT

S.No List of Experiment CO PO PS


O
01. To write a program to sense the available 1, 2 1,2,5 1
networks using Arduino.
02. To write a program to measure the distance 2 1,2 1
using ultrasonic sensor and make LED blink
using Arduino.

03. To write a program to detects the vibration 2 1,2,3,4, 1


of an object with sensor using Arduino.
5
04. To write a program to connect with the 4 1,2 1
available Wi-Fi using
Arduino

05. To write a program to sense a finger when 2, 3 1,2,3,5 1


it is placed on the board Arduino.

06. To write a program to get 2, 3 1,2,3,5 1


temperature notification using
Arduino.
07. To write a program for LDR to vary the 2, 3 1,5 1
light intensity of LED using Arduino.
08. To write a program to install 2, 3 1,2,3,5 1
MySQL database in Raspberry pi.

09. To write a program to work with basic 3, 5 1,2,5 1, 2


MySQL queries by fetching data from
database in Raspberry pi.

10. To write a program to switch light on when 5 1,2,3 1, 2


the input is 1 and switch the light off when
the input is 0 using Raspberry pi.

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:

1. Detect the vibration of an object using Arduino.


COMPONENTS REQUIRED:
1. Vibration sensor
2. Jumper wires
3. USB cable

ALGORITHM:
STEP 1: Start the process. STEP 2:
StartArduino.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 toolsSelect boardArduino Nano gndSelect 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: StartArduino 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 toolsSelect boardNode MCU 0.9C ESP-12 module and then
SelectPort.
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:

1. Sense a finger when it is placed on board using Arduino.


COMPONENTS REQUIRED:
1. Touch Sensor
2. Jumper wire
3. USB cable
ALGORITHM:
STEP 1: Start the process. STEP 2:
Start Arduino 1.8.8
STEP 3: Then enter the coding in arduino software. STEP 4:
Compile the coding in the arduino software.
STEP 5: In arduino board, connect VCC to power supply 5v and connect SIG to
Electrical signal DT and connect to ground and wing jumper wires.
STEP 6: Connect the arduino board with USB cable to the system. STEP 7:
Select tools Select processor board and port.
STEP 8: Upload the coding to arduino board. Then the output will be
displayed in the serial monitor.
STEP 9: Stop the process.

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:

1. MySQL database installation in raspberry pi.


COMPONENTS REQUIRED:
1. Raspberrypi
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 to mouse and keyboard.
STEP5: then enter the coding in terminal for installing MySQL to Raspberry
pi. STEP6: stop the process.
CODING:
sudo apt-get install mysql-server sudo
apt update
sudo apt upgrade
sudo apt install mariadb-server
sudomysql_secure_installation
sudomysql -u root –p

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:

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: Enter the coding in the terminal for installing python and GPTO.
STEP6: Open notepa →enter coding →save as →file extension python or
py.
STEP7: Copy file location → open terminal → paste file location in terminal → press
enter.
STEP8: In the terminal window to get output enter 0 or 1, to switch light ON when the
input is 1 and switch light OFF when the input is 0 in breadboard using Raspberry pi.
STEP9: Stop the process.

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

AIM: Design of digital DC voltmeter and ammeter.

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:

S. No Name of the equipment Quantity


1 Arduino Uno 1

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

6 Center tapped transformer (230/6-0-6V) 1


7 jumper cables As
required

ELECTRICAL CIRCUIT DIAGRAM:

A) DC VOLTMETER:

Figure: Electrical Circuit for DC Volt meter

B) DC AMMETER:

Figure: Circuit Diagram for Digital DC ammeter


49
ARDUINO CODE:

A) Code for DC

Voltmeter: void setup()


{
Serial.begin(9600);
}
void loop() {
int volt = analogRead(A0);// read the input
double voltage = map(volt,0,1023, 0, 2500) + offset;// map 0-1023 to 0-2500 and add
correction offset
voltage /=100;// divide by 100 to get the decimal values Serial.print("Voltage:
"); Serial.print(voltage);//print the voltge Serial.println("V");
delay(500);
}

B) Code for DC Voltmeter:

void setup() { Serial.begin(9600);


}
void loop() { float average = 0;
for(int i = 0; i< 1000; i++) {
average = average + (.0264 * analogRead(A0) -13.51) / 1000;
//5A mode, if 20A or 30A mode, need to modify this formula to
//(.19 * analogRead(A0) -25) for 20A mode and
//(.044 * analogRead(A0) -3.78) for 30A mode delay(1);
}

50
Serial.println(average);
}

PROCEDURE:

Procedure for DC Voltmeter:

1. Make the connection as per the electrical circuit diagram


2. Open the Arduino IDE in computer and write the program.
3. Compile the program for any errors and upload it to the Arduino.
4. Observe the voltage on LCD display.
5. If a potentiometer is used between the battery and sensor to change the voltage value.
6. Observe the changed voltage is updated on LCD display.

Procedure for DC Ammeter:

1. Make the connection as per the electrical circuit diagram


2. Open the Arduino IDE in computer and write the program.
3. Compile the program for any errors and upload it to the Arduino.
4. Observe the current on LCD display.
5. If the load is increased by adding a series resistor to LED then current increases and
is updated in LCD display.

EXPERIMENT NO. 12

AIM: Design of digital frequency meter.

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

ELECTRICAL CIRCUIT DIAGRAM:

Figure: Circuit Diagram for Digital frequency meter.

ARDUINO CODE:

#include <LiquidCrystal.h> int input=13;


int high_time; int low_time;
float time_period; float freq;
float frequency; LiquidCrystallcd(0, 1, 3, 4, 5, 6); void setup()
{
pinMode(input,INPUT); lcd.begin(16, 2);
}
void loop()

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:

Make the connection as per the electrical circuit diagram


Open the Arduino IDE in computer and write the program.
Compile the program for any errors and upload it to the Arduino.
Observe the frequency on LCD display.

53

You might also like