IoT Lab REPORT CSE
IoT Lab REPORT CSE
USN: 1DT19CS033
NAME: CHIRAG SUTHAR
CLASS: 8 SEM CSE A SEC
FACULTY SIGNATURE:
\
Arduino Uno Pin Diagram
About Project
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
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>
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);
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("<!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
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
IOT Page 11
Expt. No. 4: I2C Protocol Study
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
IOT Page 14
Expt. No. 5: Reading Temperature and Relative Humidity
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 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 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);
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
IOT Page 18
Snapshot: Particular Program based on DHT11 Sensor-Unified
IOT Page 19
Snapshot: Successful Run through DHT11 sensor through NodeMCU
ESP8266
IOT Page 20