Professional Documents
Culture Documents
1at18is045 Lohithkumar G o
1at18is045 Lohithkumar G o
2021 - 2022
A
Report on Practical Exercises of the course
“Internet of Things(18CS81)”
Submitted by
LOHITHKUMAR G O
(1AT18IS045)
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
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.
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
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
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.
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.
void setup()
Serial.begin(9600);
while (Serial.available() == 0) {
Serial.println(LedOnMessage);
digitalWrite(ledPin, HIGH);
delay(1000);
Serial.println(LedOffMessage);
digitalWrite(ledPin, LOW);
delay(1000);
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.
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.
#define LED 15
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V1)
Blynk.virtualWrite(V1, value);
if(value == 1){
Serial.println("LED On");
digitalWrite(LED, HIGH);
Serial.println("LED Off");
digitalWrite(LED, LOW);
// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
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");
void setup()
pinMode(LED,OUTPUT);
Serial.begin(115200);
void loop()
Blynk.run();
timer.run();
Fig 2.2 Code screenshot for Point-to-point communication of two motes over the radio frequency
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 .
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 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.
#define DHTPIN 2
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
// This function is called every time the Virtual Pin 0 state changes
// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
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");
void myTimerEvent()
sensors_event_t event;
dht.temperature().getEvent(&event);
Serial.print("Temperature: ");
Serial.print(event.temperature);
Blynk.virtualWrite(V1, temp);
Serial.println("°C");
dht.humidity().getEvent(&event);
Serial.print(hum);
Blynk.virtualWrite(V2, hum);
Serial.println("%");
Serial.println("\n-------------------------------");
void setup()
Serial.begin(115200);
dht.begin();
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
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
Cost-efficient
It uses ACK/NACK feature due to which it has improved error handling capabilities
Limitations:
Slower speed
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.
• 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.
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
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.
Fig 5.1 Performing the monitoring of Temperature and Humidity and Blynk app template
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 2
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(event.relative_humidity);
Serial.println("%");
delay(1000);
Fig 5.2 Code screenshot for reading temperature and relative humidity value from sensor
INTERFACE DESCRIPTION
1. Specific Requirements
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