0% found this document useful (0 votes)
265 views20 pages

IoT Lab REPORT CSE

This document contains lab reports from an Internet of Things course. It includes summaries of 5 experiments: 1. Transmitting a string using UART protocol and blinking an LED based on the string length. 2. Point-to-point communication between two nodes (ESP8266 devices) to control an LED webpage. 3. Multi-point to single point communication between wireless sensor nodes using RF transmission. 4. A study of the I2C protocol using two Arduino boards as master and slave to command LED blinking. 5. Measuring temperature and humidity in real-time using a DHT11 sensor and NodeMCU ESP8266.

Uploaded by

Captains Play
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
265 views20 pages

IoT Lab REPORT CSE

This document contains lab reports from an Internet of Things course. It includes summaries of 5 experiments: 1. Transmitting a string using UART protocol and blinking an LED based on the string length. 2. Point-to-point communication between two nodes (ESP8266 devices) to control an LED webpage. 3. Multi-point to single point communication between wireless sensor nodes using RF transmission. 4. A study of the I2C protocol using two Arduino boards as master and slave to command LED blinking. 5. Measuring temperature and humidity in real-time using a DHT11 sensor and NodeMCU ESP8266.

Uploaded by

Captains Play
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

DAYANANDA SAGAR ACADEMY OF TECHNOLOGY AND MANAGEMENT

Udayapura, Kanakapura Road, Opp. Art of Living, Bangalore – 560082


(Affliated to VTU, Belagavi, Approved by AICTE, New Delhi)
Accredited by NBA and NAAC ( A+)

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

INTERNET OF THINGS LAB REPORT


COURSE CODE : 18CS81

USN: 1DT19CS033
NAME: CHIRAG SUTHAR
CLASS: 8 SEM CSE A SEC

FACULTY SIGNATURE:
\
Arduino Uno Pin Diagram

Dept. of CSE, DSATM, Bangalore-82 Page 2


Expt. No. 1: Transmit a String using UART

About Project

UART (Universal Serial Asynchronous Receiver Transmitter) is a serial communication


protocol used to transmit/receive data serially at a specific baud rate.
Several devices such as GPS, GSM, RFID, sensors, etc. need to communicate with the
microcontroller for transmitting or receiving information. To communicate with the microcontroller,
several communication protocols are used such as RS232, SPI, I2C, CAN etc. Basically, a protocol
is a set of rules agreed by both, the sender and the receiver, on -
 How the data is packed?
 How many bits constitute a character?
 When the data begins and ends?
With the help of USART, we can send / receive data to a computer or other devices. USART is also
used in interfacing microcontroller with various modules like Wi-Fi (ESP8266), Bluetooth, GPS,
GSM, etc.
Let us start with the USART based serial communication.
Asynchronous Communication: Asynchronous operation means that a process operates
independently of other processes. Asynchronous communication means each character (data byte) is
placed in between the start and stop bits. The start bit is always 0 (low) and the stop bit is always 1
(high).

Bit Rate & Baud Rate: The rate of data transfer in serial data communication is stated in bps (bits
per second). Another widely used terminology for bps is baud rate; means, number of changes in
signal per second. Here the signal is in bits, therefore bit rate = baud rate.

Project code
int led = 13;
String value = "";

IOT Page 3
void setup() {
Serial.begin(9600);
pinMode(led,OUTPUT);
}

void loop() {
if
(Serial.available()>0){
value =Serial.read();
delay(4);
for(int
i=0;i<value.length();i++){delay
(1000); digitalWrite(led,HIGH);
Serial.println("LED is ON");
delay(1000);
digitalWrite(led,LOW);
Serial.println("LED is OFF");
}
}

Results

Snapshot: Basic Program of Arduino IDE

IOT Page 4
Snapshot: Transmit String using UART protocol

Snapshot: LED Display going ON and OFF based on length of input string in ASCII.

IOT Page 5
Snapshot: LED Blinking when the Input string is provided.

IOT Page 6
Expt. No. 2 Point to Point Communication of Two Motes
About the Project:
A point-to-point connection in telecommunications denotes a communications link between
two communication endpoints or nodes. A phone call is an example where two phones are linked
together such that only one caller can hear what the other is saying. In contrast, a point-to-multipoint
or broadcast link allows several nodes to receive data sent by a single node. Leased lines and
microwave radio relay are two further types of point-to-point communication networks.
Point-to-Multipoint Communication (P2MP, PTMP, or PMP) is a sort of one-to-many link
used in wirelesscommunications that offers numerous pathways from a single place to several
locations. P2MP employs either frequency division multiplexing or temporal division multiplexing
to provide bidirectional traffic flow from a central antenna or antenna array to numerous receiving
antennas. In this project, we used the ESP8266(NodeMCU) as a webserver and a smartphone as a
client.
The sever side contains an LED and the client side contains the interface as a web page to
control theLED. The two motes connect through Wi-Fi and in the client side the web page can be
access by entering the IP address of the NodeMCU in the browser. The page contains two buttons
which can be used to turn ON or OFF the LED.

Project Code

#include <ESP8266WiFi.h>

const char* ssid = "Abhijit's OnePlus Nord";


const char* password = "1234567890";

WiFiServer server(80);

void setup()
{ pinMode(D1,
OUTPUT);
digitalWrite(D1, LOW);
Serial.begin(9600);
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED)


{delay(500);
Serial.print(".");
}

IOT Page 7
Serial.println("");
Serial.println("NodeMCU is connected to WiFi");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
delay(3000);
}

void loop()
{ WiFiClient client;
client = server.available();

if (client == 1) {
String request = client.readStringUntil('\n');
client.flush();
Serial.println(request);
if (request.indexOf("ledon") != -1)
{ digitalWrite(D1, HIGH);
Serial.println("LED is ON");
}

if (request.indexOf("ledoff") != -1)
{ digitalWrite(D1, LOW);
Serial.println("LED is OFF");
}

client.println("HTTP/1.1 200 OK");


client.println("Content-Type: text/html");
client.println("");

client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<head>");
client.println("<title> Controlling LED </title>");
client.println("</head>");
client.println("<body align= \"center\" >");
client.println("<h1> <font size = \"25\" face = \"Cooper\" > NodeMCU and Wifi Network </font>
</h1> ");
client.println("<p> <a href=\"/ledon\"> <button style=\"height:60px; background-color: yellow;
width:200px; cursor: pointer\"> ON </button> <a> </font></p> ");
client.println("<p> <a href=\"/ledoff\"> <button style=\"height:60px; background-color: yellow;
width:200px; cursor: pointer\" > OFF </button> <a> </font></p> ");
client.println("</body>");
client.println("</html>");
IOT Page 8
Serial.println("Client disonnected");
Serial.println("");
Serial.println(" ");

}
}

Results

1. Connect the NodeMCU with LED

2. User Interface

IOT Page 9
Expt. No. 3: Multi-point to single point communicationof Motes
over the radio frequency LAN
About the project:
Point-to-multipoint (PMP) communication refers to communication that is accomplished
through a distinct and specific form of one-to-many vice versa connections, offering several
paths from one single location to various locations. Single transmitter broad casts message
across the multiple receivers using wireless communication of motes through RF transmitter
and receiver 433 MHZ in a network.Wireless communication is achieved.
Code

IOT Page 10
Results

Figure: Receiver Output

Figure: Sender Output

IOT Page 11
Expt. No. 4: I2C Protocol Study

About the project:

I2C stands for Inter-Integrated Circuit. It is a bus interface connection protocol incorporated
into devices for serial communication. It was originally designed by Philips Semiconductor in 1982.
Recently, it is a widely used protocol for short-distancecommunication. It is also known as Two Wired
Interface (TWI).

In this expt, we will demonstrate how to communicate between two (or more) Arduino boards,
using I2C (Inter-Integrated Circuit) protocol. In this case, one Arduino Uno is acting as MASTER
and the other is acting as a SLAVE. I have programmed the MASTER Arduino to command the
SLAVE Arduino to blink its built-in LED once or twice depending on the received value. It is a bus
interface connection protocol incorporatedinto devices for serial communication. It was originally
designed by Philips Semiconductor in 1982. Recently, it is a widely used protocol for short-distance
communication. It is also known as Two Wired Interface (TWI).

Code

Master_writer.txt

IOT Page 12
Slave_receiver.txt

I have used 2 Arduino boards where one acts as a MASTER and the other acts as a SLAVE.
Both the boards are connected to each other via jumper wires. The MASTERArduino is programmed
to command the SLAVE Arduino to blink its built-in LED once or twice depending on the received
value.

IOT Page 13
Results

Snapshot : Output is depicted in serial monitor of slave

Snapshot\: Value of x being transferred from MASTER to


SLAVE

IOT Page 14
Expt. No. 5: Reading Temperature and Relative Humidity

About the Project:

Main Aim of this Project is to Measure Temperature and Humidity at real time using
Different Sensors in IOT. We have used DHT11 Sensor along with NodeMCU ESP8266 to
particularly measure the values arbitrarily.

The DHT11 is a primary, ultra-low-cost digital temperature, and humidity sensor. To


measure the surrounding air DHT11 uses a capacitive humidity sensor and a thermistor. And
then spits out a digital signal on the data pin (no analog input pins needed).

NodeMCU is a low-cost open source IoT platform. It initially included firmware


which runs onthe ESP8266 Wi-Fi SoC.DHT11 sensor is connected to NodeMCU using
Jumper wires and NodeMCU is connected to the Software. It’s quite simple to use but requires
precise timing to capture data. The entire real drawback of this sensor is you can only get new
data from it once every 2 seconds. So when using the DHT library, sensor readings are up to
2 seconds old. Software used here is Arduino IDE.

The Arduino IDE is an open-source software, which is used to write and upload code
to the Arduino boards. The IDE application is suitable for different operating systems
such as Windows, Mac OS X, and Linux. It supports the programming languages C and C++.

Arduino IDE is not only used to connect to NodeMCU but also to program and
configure NodeMCU ESP8266. We should ensure all the Libraries including starting from
DHT library and ESP8266 libraries are installed and ready to use.

After all the Connections, NodeMCU is connected to the Computer/Programming


devicewhich has Arduino as IDE using USB-Type B cable. Next Step is to Configure the
libraries and Choose the Port and Board required for the Same. Appropriate Port is Chosen
(ex: COM) and the Required Code is Compiled, Once the Compilation is Completed, it is
uploaded on the NodeMCU board.

After Successful Upload of the Program Code, Serial Monitor is opened in order to find
the measurement of Temperature and Humidity in Real Time.

IOT Page 15
Project code:
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 2
#define DHTTYPE DHT11 // DHT 11
DHT_Unified dht(DHTPIN, DHTTYPE); uint32_t
delayMS;
void setup()
{ Serial.begin(960
0);dht.begin();
Serial.println(F("DHTxx Unified Sensor Example"));sensor_t
sensor; dht.temperature().getSensor(&sensor);
Serial.println(F(" ----------------------------------------------"));
Serial.println(F("Temperature Sensor"));
Serial.print (F("Sensor Type: ")); Serial.println(sensor.name); Serial.print (F("Driver Ver:
")); Serial.println(sensor.version);Serial.print (F("Unique ID: "));
Serial.println(sensor.sensor_id);
Serial.print (F("Max Value: ")); Serial.print(sensor.max_value);
Serial.println(F("°C"));
Serial.print (F("Min Value: ")); Serial.print(sensor.min_value);
Serial.println(F("°C"));
Serial.print (F("Resolution: ")); Serial.print(sensor.resolution);
Serial.println(F("°C"));
Serial.println(F(" ----------------------------------------------"));
dht.humidity().getSensor(&sensor); Serial.println(F("Humidity Sensor"));
Serial.print (F("Sensor Type: ")); Serial.println(sensor.name); Serial.print (F("Driver Ver:
")); Serial.println(sensor.version);Serial.print (F ("Unique ID: "));
Serial.println(sensor.sensor_id);

Serial.print (F("Max Value: ")); Serial.print(sensor.max_value);


Serial.println(F("%"));
Serial.print (F("Min Value: ")); Serial.print(sensor.min_value);
Serial.println(F("%"));
Serial.print (F("Resolution: ")); Serial.print(sensor.resolution);Serial.println(F("%"));

IOT Page 16
Serial.println(F(" ----------------------------------------------"));
delayMS = sensor.min_delay / 1000;
}
void loop() { delay(delayMS);
sensors_event_t event;
dht.temperature().getEvent(&event);if
(isnan(event.temperature)) {
Serial.println(F("Error reading temperature!"));
}
else {
Serial.print(F("Temperature: "));
Serial.print(event.temperature);
Serial.println(F("°C"));
}
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) { Serial.println(F("Error reading
humidity!"));
}
else {
Serial.print(F("Humidity: "));
Serial.print(event.relative_humidity);
Serial.println(F("%"));
}
}

IOT Page 17
Results

Snapshot: Basic Program of Arduino IDE

Snapshot: Connection with NodeMCU and DHT11 sensor

IOT Page 18
Snapshot: Particular Program based on DHT11 Sensor-Unified

Snapshot: Final Output – Measurement of Temperature and Humidity

IOT Page 19
Snapshot: Successful Run through DHT11 sensor through NodeMCU
ESP8266

IOT Page 20

You might also like