Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

JNANA SANGAMA, Belgaum - 590 014.

2021 - 2022

A
Report on Practical Exercises of the course

“Internet of Things(18CS81)”

Submitted in partial fulfillment of the requirements for the award of degree of


BACHELOR OF ENGINEERING
in
INFORMATION SCIENCE & ENGINEERING

Submitted by
LOHITHKUMAR G O
(1AT18IS045)

Under the guidance of


Mrs. Vijayalakshmi V
Assistant Professor
Dept. of ISE, ATRIA I. T.

ATRIA INSTITUTE OF TECHNOLOGY


Department of Information Science and Engineering,
Bengaluru - 560 024
ATRIA INSTITUTE OF TECHNOLOGY
(Affiliated to Visvesvaraya Technological University)
ASKB Campus, Anandnagar,
Bengaluru – 560024

Department of Information Science and Engineering

CERTIFICATE

Certified that the Practical exercises with demonstration was carried out by LOHITHKUMAR G
O, (1AT18IS045), a bonafide student of Department of Information Science and Engineering, Atria
I.T., in partial fulfilment for the award of Bachelor of Engineering in Information Science &
Engineering of the Visvesvaraya Technological University, Belagavi, during the year 2021-2022. It
is certified that all corrections/suggestions indicated for Internal Assessment have been
incorporated in the Report deposited in the departmental library. The report on Practical Exercises
has been approved as it satisfies the academic requirements prescribed for the said Degree.

Guide HOD

Mrs Vijayalakshmi V Dr. Shanthi Mahesh


(Asst. Prof., ISE) (Dept. of ISE)
DECLARATION

I, LOHITHKUMAR G O (1AT18IS045), Student of eighth semester, Bachelor of Engineering,


Atria Institute of Technology hereby declare that the Practical Exercises on Internet of
Things(18CS81) has been carried out by me at Atria Institute of Technology, Bengaluru, and
submitted in partial fulfillment of the course requirements for the award of the degree of Bachelor
of Engineering in Information Science & Engineering of Visvesvaraya Technological
University, Belagavi, during the academic year 2021-2022.

I also declare that, to the best of my knowledge and belief, the work reported here doesn’t
form part of any other dissertation on the basis of which a degree or award was conferred on an
earlier occasion on this by any other student.

Place: Bengaluru LOHITHKUMAR G O


Date: 13th June 2022 (1AT18IS045)

3
ACKNOWLEDGEMENT

I am grateful to my institution, Atria Institute of Technology, for having provided me with the
facilities to successfully complete these Practical Exercises on Internet of Things(18CS81).
I thank the management of Atria Institute of Technology for providing us this opportunity
and necessary infrastructure.
I thank Dr. T. N. Sreenivasa, Principal and Dr. Shanthi Mahesh, HOD, ISE for
providing us all the necessary facilities for successful completion of our Practical Exercises.
I take this opportunity to express our deep sense of gratitude to my coordinators Mrs
Vijayalakshmi V, Assistant Professor, Department of ISE for their valuable guidance and help
throughout the course. They have always been patient with me and helped immensely in
completing the task on hand.
Last but not least from the Department of Information Science and Engineering, teaching
and non-teaching staffs for their constant encouragement, support, patience and endurance shown
during the preparation of this report were remarkable.
LOHITHKUMAR G O
(1AT18IS045)
TABLE OF CONTENTS

EXPERIMENT NO. TITLE PAGE NO.

1. Expt 1 1
1.1 Introduction 1
1.2 Working 1
1.3 Implementation Code 2
2. Expt 2 5
2.1 Introduction 5
2.2 Working 6
2.3 Implementation Code 7
3. Expt 3 11
3.1 Introduction 11
3.2 Working 12
3.3 Implementation Code 13
4. Expt 4 17
4.1 Introduction 17
4.2 Working 18
5. Expt 5 20
5.1 Introduction 20
5.2 Working 21
5.3 Implementation Code 22

APPENDIX – A – Interface Description 24


1. Specific Requirements 24
A.1.1 Hardware requirements 24
A.1.2 Software requirements 24

APPENDIX – B – SCREEN SHOTS

1.1 Performing Transmit String using UART 2


1.2 Code screenshot for Transmit String using UART 4
2.1 Template on Blynk for P2P using RF 6
2.2 Code screenshot for Point-to-point communication of
two motes over the radio frequency 10
3.1 Performing Multi-point to Single point communication using RF 12
3.2 Code screenshot for Multi-point to Single point communication
using RF 16
4.1 I2C Protocol Architecture 17
4.2 I2C Communication 19
5.1 Performing the monitoring of Temperature and Humidity and
Blynk app template 21
5.2 Code screenshot for reading temperature and relative humidity
value from sensor 23
IoT Laboratory Report 2021-2022

EXPERIMENT 1
TRANSMIT A STRING USING UART

1.1 Introduction
Transmit string using UART ( Universal Asynchronous Receiver Transmitter) where the two
devices communicate directly with each other. UART is a hardware related to serial
communication. Asynchronous means there is no clock signal to synchronize the output bits
from the transmitting device going to the receiving end.

Baud Rate: Baud rate is the measure of the number of changes of the signal(p/sec) that
propagate through a medium. It is necessary to set both UART devices with the same baud rate
to have the proper transmission of data. Values for baud rate can be 9600, 1200, 2400, 480,
19200, 38400, 57600, and 115200 bps.

Components Required: Arduino UNO, Arduino USB Cable

1.2 Working

The goal of this experiment setup is to blink the in-built LED in Arduino board defined in pin
number 2 as the output. The input for the circuit is taken from serial monitor and is stored in a
variable "numBlinks".

The circuit prints on the serial monitor the state of the LED whenever it changes.

When the serial UART input is given to the circuit the LED blinks as many times parsed as
input to the circuit by using a loop.

Dept. of ISE, Atria IT Page 1


IoT Laboratory Report 2021-2022

Fig 1.1 Performing Transmit String using UART

1.3 Implementation Code

int ledPin = 2; // declare GPIO2 as ledpin

int numBlinks; // variable to store the number of blinks

String LedOnMessage = "LED is turned on"; // this is a string with information

String LedOffMessage = "LED is turned off"; // this is a string with information

void setup()

pinMode(ledPin, OUTPUT); // set pin10 as output pin

digitalWrite(ledPin, LOW); // set the pin value on low at the begin

Serial.begin(9600);

Dept. of ISE, Atria IT Page 2


IoT Laboratory Report 2021-2022
void loop()

//Prompt User for Input

Serial.println("How Many Times Do You Want the LEDs to blink?");

while (Serial.available() == 0) {

// Wait for User to Input Data

numBlinks = Serial.parseInt(); //Read the data the user has input

for (int counter = 1; counter <= numBlinks; counter++) {

Serial.println(LedOnMessage);

digitalWrite(ledPin, HIGH);

delay(1000);

Serial.println(LedOffMessage);

digitalWrite(ledPin, LOW);

delay(1000);

Dept. of ISE, Atria IT Page 3


IoT Laboratory Report 2021-2022

Fig 1.2 Code screenshot for Transmit String using UART

Dept. of ISE, Atria IT Page 4


IoT Laboratory Report 2021-2022

EXPERIMENT 2
POINT-TO-POINT COMMUNICATION OF TWO
MOTES OVER THE RADIO FREQUENCY

2.1 Introduction
A Point-to-Point connection (P2P) refers to a permanent direct communication link between
two parties. The two units communicate using either Frequency Division Multiplexing or time
division multiplexing to allow for bidirectional traffic flow. For fixed links, this can involve use
of high gain directional antennas which enables long distance and high capacity links.

Radio frequency is the measurement representing the oscillation rate of electromagnetic


radiation spectrum, or electromagnetic radio waves , from frequencies ranging from 300 GHz to
as low as 9 kHz

Components Required: Node MCU, ESP8266, USB B Type Cable

Dept. of ISE, Atria IT Page 5


IoT Laboratory Report 2021-2022

2.2 Working

The default LED on pin 15 is setup. Set the SSID and PASSWORD to the connected wi-fi.

The function BLYNK_WRITE() is called whenever state of V0 pin changes. When the Virtual
pin value is HIGH(1), the LED is also set to HIGH and thereby is turned ON else it is set to
LOW or is OFF.

The Blynk property listens on V3 pin,

• When state is 'offImageUrl', the image showing congratulations is displayed


• When state is 'onImageUrl', congratulations_pressed image is displayed and
• If the state is 'url', quick start is displayed. LED is defined as Output while the SSID and
PASSWORD are parsed to Blynk as parameters.

Fig 2.1 Template on Blynk for P2P using RF

Dept. of ISE, Atria IT Page 6


IoT Laboratory Report 2021-2022

2.3 Implementation Code

#define BLYNK_TEMPLATE_ID "TMPL8Vt1xmJi"

#define BLYNK_DEVICE_NAME "LED"

#define BLYNK_AUTH_TOKEN "zuJ1QbYFfWTkkKwgXNVBYi5auL_xl1_p"

#define LED 15

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "DHANUSH KILVIDHI VIJAY";

char pass[] = "password";

BlynkTimer timer;

// This function is called every time the Virtual Pin 0 state changes

BLYNK_WRITE(V1)

int value = param.asInt();

Blynk.virtualWrite(V1, value);

Dept. of ISE, Atria IT Page 7


IoT Laboratory Report 2021-2022

if(value == 1){

Serial.println("LED On");

digitalWrite(LED, HIGH);

else if(value == 0){

Serial.println("LED Off");

digitalWrite(LED, LOW);

// This function is called every time the device is connected to the Blynk.Cloud

BLYNK_CONNECTED()

// Change Web Link Button message to "Congratulations!"

Blynk.setProperty(V3, "offImageUrl",
"https://staticimage.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");

Blynk.setProperty(V3, "onImageUrl",
"https://staticimage.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.p
ng");

Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-


toblynk/how-quickstart-device-was-made");

Dept. of ISE, Atria IT Page 8


IoT Laboratory Report 2021-2022

void setup()

pinMode(LED,OUTPUT);

Serial.begin(115200);

Blynk.begin(auth, ssid, pass);

// You can also specify server:

//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);

//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

void loop()

Blynk.run();

timer.run();

Dept. of ISE, Atria IT Page 9


IoT Laboratory Report 2021-2022

Fig 2.2 Code screenshot for Point-to-point communication of two motes over the radio frequency

Dept. of ISE, Atria IT Page 10


IoT Laboratory Report 2021-2022

EXPERIMENT 3
MULTI-POINT TO SINGLE POINT COMMUNICATION
OF MOTES OVER THE RADIO FREQUENCY

3.1 Introduction
Point-to-multipoint communication, refers to communication that is accomplished through a
distinct and specific form of one to many connections, offering several paths from one location
to various location .

Radio frequency is the measurement representing the oscillation rate of electromagnetic


radiation spectrum, or electromagnetic radio waves , from frequencies ranging from 300 GHz to
as low as 9 kHz

Components Required: Node MCU, ESP8266, USB B Type Cable

Dept. of ISE, Atria IT Page 11


IoT Laboratory Report 2021-2022

3.2 Working

The DHT - Digital Temperature and Humidity sensor is set to pin 2 and Blynk app is listened
on Serial monitor connection. The V0 pin is monitored continuously and any change results in
calling dht() function.

The Blynk property listens on V3 pin,

• When state is 'offImageUrl', the image showing congratulations is displayed


• When state is 'onImageUrl', congratulations_pressed image is displayed and
• If the state is 'url', quick start is displayed. LED is defined as Output while the SSID and
PASSWORD are parsed to Blynk as parameters.

The DHT sensor monitors the floating point values of Temperature in °C and Humidity and
writes to the Blynk app through V2 pin. ESP module here uses one Master and multiple Slave
configuration.

This dht() function repeats in loop for continuous monitoring of the values of temperature and
humidity. The SSID and PASSWORD are parsed as the parameters to Blynk app.

Fig 3.1 Performing Multi-point to Single point communication using RF

Dept. of ISE, Atria IT Page 12


IoT Laboratory Report 2021-2022

3.3 Implementation Code

#define BLYNK_TEMPLATE_ID "TMPLJPcNPo5q"

#define BLYNK_DEVICE_NAME "DHT11"

#define BLYNK_AUTH_TOKEN "Js7lgXdue3Q9pvwASZuz19U8qJD2MLjr"

#define DHTPIN 2

#define DHTTYPE DHT11

#define BLYNK_PRINT Serial

#include <Adafruit_Sensor.h>

#include <DHT.h>

#include <DHT_U.h>

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "DHANUSH KILVIDHI VIJAY";

char pass[] = "password";

BlynkTimer timer;

DHT_Unified dht(DHTPIN, DHTTYPE);

// This function is called every time the Virtual Pin 0 state changes

Dept. of ISE, Atria IT Page 13


IoT Laboratory Report 2021-2022

// This function is called every time the device is connected to the Blynk.Cloud

BLYNK_CONNECTED()

// Change Web Link Button message to "Congratulations!"

Blynk.setProperty(V3, "offImageUrl",
"https://staticimage.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");

Blynk.setProperty(V3, "onImageUrl",
"https://staticimage.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.p
ng");

Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-


toblynk/how-quickstart-device-was-made");

// This function sends Arduino's uptime every second to Virtual Pin 2.

void myTimerEvent()

//Write Code Here:

sensors_event_t event;

dht.temperature().getEvent(&event);

Serial.print("Temperature: ");

float temp = float(event.temperature);

Serial.print(event.temperature);

Dept. of ISE, Atria IT Page 14


IoT Laboratory Report 2021-2022

Blynk.virtualWrite(V1, temp);

Serial.println("°C");

dht.humidity().getEvent(&event);

Serial.print("Relative Humidity: ");

float hum = float(event.relative_humidity);

Serial.print(hum);

Blynk.virtualWrite(V2, hum);

Serial.println("%");

Serial.println("\n-------------------------------");

void setup()

Serial.begin(115200);

dht.begin();

Blynk.begin(auth, ssid, pass);

//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);

//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

// Setup a function to be called every second

timer.setInterval(1000L, myTimerEvent);

}
Dept. of ISE, Atria IT Page 15
IoT Laboratory Report 2021-2022
void loop()

Blynk.run();

timer.run();

Fig 3.2 Code screenshot for Multi-point to Single point communication using RF

Dept. of ISE, Atria IT Page 16


IoT Laboratory Report 2021-2022

EXPERIMENT 4
I2C PROTOCOL STUDY

4.1 Introduction
I2C stands for inter integrated controller. This is a serial communication protocol that is used to
connect low-speed devices. It is a master-slave communication in which we can connect and
control multiple slaves from a single master. It uses only 2 bi-directional open-drain lines for
data communication called SDA and SCL. Both these lines are pulled high. With I2C, data is
transferred in messages. Messages are broken up into frames of data. Each message has an
address frame that contains the binary address of the slave, and one or more data frames that
contain the data being transmitted. The message also includes start and stop conditions,
read/write bits, and ACK/NACK bits between each data frame

Fig 4.1 I2C Protocol Architecture

Dept. of ISE, Atria IT Page 17


IoT Laboratory Report 2021-2022
Advantages:

Can be configured in multi-master mode

Complexity is reduced because it uses only 2 bi-directional lines

Cost-efficient

It uses ACK/NACK feature due to which it has improved error handling capabilities

Limitations:

Slower speed

Half-duplex communication is used in the I2C communication protocol

4.2 Working

I2C Communication Protocol uses only 2 bi-directional open-drain lines for data communication
called SDA and SCL.

• Serial Data (SDA) – Transfer of data takes place through this pin.
• Serial Clock (SCL) – It carries the clock signal.

I2C operates in 2 modes

• Master mode
• Slave mode

Each data bit transferred on SDA line is synchronized by a high to the low pulse of each clock
on the SCL line.

Dept. of ISE, Atria IT Page 18


IoT Laboratory Report 2021-2022

Fig 4.2 I2C Communication

Dept. of ISE, Atria IT Page 19


IoT Laboratory Report 2021-2022

EXPERIMENT 5
READING TEMPERATURE AND RELATIVE
HUMIDITY VALUE FROM THE SENSOR

5.1 Introduction
DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive
humidity sensor and a thermistor to measure the surrounding air and spits out a digital signal on
the data pin (no analog input pins needed). It's fairly simple to use but requires careful timing to
grab data. The only real downside of this sensor is you can only get new data from it once every
2 seconds, so when using our library, sensor readings can be up to 2 seconds old

DHT11 is a relative humidity sensor. To measure the surrounding air this sensor uses
a thermistor and a capacitive humidity sensor. DHT11 has a Capacitive Sensor for measuring
humidity & NTC Thermistor for temperature sensing. (We will cover them in detail below). It
calibrates the humidity using humidity coefficients, which are stored in the OTP program
memory of the built-in controller.

The temperature range of DHT11 is from 0 to 50 degree Celsius with a 2-degree accuracy.
Humidity range of this sensor is from 20 to 80% with 5% accuracy. The sampling rate of this
sensor is 1Hz .i.e. it gives one reading for every second. DHT11 is small in size with operating
voltage from 3 to 5 volts. The maximum current used while measuring is 2.5mA.
Components Required: Node MCU, DHT sensor, USB B Type Cable

Dept. of ISE, Atria IT Page 20


IoT Laboratory Report 2021-2022

5.2 Working

The DHT - Digital Temperature and Humidity sensor is set to pin 2 and Blynk app is listened
on Serial monitor connection. The V0 pin is monitored continuously and any change results in
calling dht() function.

The DHT sensor monitors the floating point values of Temperature in °C and Humidity and
writes to the Blynk app through V2 pin. This dht() function repeats in loop for continuous
monitoring of the values of temperature and humidity.

The Node MCU is connected with the DHT11 sensor. The libraries such as:

• Adafruit library
• DHT sensor library
• Firebase ESP8266 library
• Blynk Library

are necessary for the configuration. Add the libraries by navigating to Sketch >> Include Library
>> Add .zip library >> Select .zip file and load.

Thereby the values with respect to DHT can be obtained in real-time.

Fig 5.1 Performing the monitoring of Temperature and Humidity and Blynk app template

Dept. of ISE, Atria IT Page 21


IoT Laboratory Report 2021-2022

5.3 Implementation Code

#include <Adafruit_Sensor.h>

#include <DHT.h>

#include <DHT_U.h>

#define DHTPIN 2

#define DHTTYPE DHT11

DHT_Unified dht(DHTPIN, DHTTYPE);

void setup() {

Serial.begin(115200);

dht.begin();

void loop() {

sensors_event_t event;

dht.temperature().getEvent(&event);

Serial.print("Temperature: ");

Serial.print(event.temperature);

Serial.println("°C");

dht.humidity().getEvent(&event);

Serial.print("Relative Humidity: ");

Dept. of ISE, Atria IT Page 22


IoT Laboratory Report 2021-2022

Serial.print(event.relative_humidity);

Serial.println("%");

delay(1000);

Fig 5.2 Code screenshot for reading temperature and relative humidity value from sensor

Dept. of ISE, Atria IT Page 23


IoT Laboratory Report 2021-2022

INTERFACE DESCRIPTION

1. Specific Requirements

A.1.1 Hardware Requirements


• SST IoT Board:

Components GPIO PIN DESCRIPTION

ON Board LED 2, 16
LDR A0
LCD SCL - 5, SDA - 4
OLED 4, 5
DC Motor Motor 1- 16, 5 Motor 2- 4,2
Ultra Sonic Sensor Trigger-12, Echo-14
Bluetooth RX-14, TX-12
DHT 11 2
RELAY 13

A.1.2 Software Requirements


• Arduino IDE 1.8.16
• ESP8266
• Blynk Account
• Libraries Required:
o Adafruit_Sensor
o DHT-sensor-library
o Firebase-ESP8266
o blynk-library

Dept. of ISE, Atria IT Page 24

You might also like