Iiot Lab Manual
Iiot Lab Manual
Experiment-1
Aim: To send and receive messages from long distances using the
LoRa module.
Apparatus Required:
● LoRa module.
● Nodemcu.
● Jumpers.
Circuit Diagram:
Transmitter section:
PIN configuration:
1. GND-GND.
2. NSS-D8.
3. MOSI-D7.
4. MOS0-D6.
5. SCK-D5.
6. GND-GND.
7. 3.3v-3.3v.
8. GND-GND.
9. RESET-D0.
10. DIO0-D2.
Receiver Section:
PIN configuration:
1. GND-GND.
2. NSS-D8.
3. MOSI-D7.
4. MOS0-D6.
5. SCK-D5.
6. GND-GND.
7. 3.3v-3.3v.
8. GND-GND.
9. RESET-D0.
10. DIO0-D2.
#include <LoRa.h>
#define SS 15
#define RST 16
#define DIO0 04
#define led 02
void setup()
{
Serial.begin(115200);
pinMode(led,OUTPUT);
digitalWrite(led,1);
while (!Serial);
Serial.println("Device Activated");
LoRa.setPins(SS, RST, DIO0);
if (!LoRa.begin(433E6))
{
Serial.println("LoRa Error");
delay(100);
while (1);
}
data.reserve(200); // Max Number of character Sented through a
Single message
}
void loop()
{
serialEvent();
stringComplete = false;
int packetSize = LoRa.parsePacket();
if (packetSize)
{
while (LoRa.available())
{
Serial.print("Message Received : ");
Serial.println(LoRa.readString());
}
}
}
void serialEvent() {
while (Serial.available()) {
char inChar = (char)Serial.read();
data += inChar;
if (inChar == '\n')
{
stringComplete = true;
Serial.print("Sending Message: ");
Serial.println(data);
LoRa.beginPacket();
LoRa.print(data);
LoRa.endPacket();
data="";
digitalWrite(led,0);
delay(2000);
digitalWrite(led,1);
}
}
}
Procedure:
➢ Rig up the ckt as shown in the ckt diagram.
➢ Connect all the ground pins of NODEMCU ,either the pins used or
not.
➢ Because the grounding is important to the LoRa module .
➢ Download the LoRa library in the managed library.
➢ Upload the code to the NODEMCU.
➢ Now send the message from one LoRa to another.
Result :
Communication using the LoRa module is successfully implemented.
Experiment-2
APPARATUS REQUIRED:
⦁GSM module
⦁Arduino UNO
⦁SIM
⦁Jumper wires(female to male type)
CIRCUIT DIAGRAM:
PROGRAM CODE:
#include<SoftwareSerial.h>
SoftwareSerial gsm(2,3);
void setup()
{
delay(1000);
Serial.begin(9600);
gsm.begin(9600);
gsm.println("AT+CMGF=1");
delay(1000);
gsm.println("AT+CMGS=\"+919880466676\"\r"); //replace x by your
number
delay(1000);
gsm.println("Good afternoon sir");
delay(100);
gsm.println((char)26);
delay(1000);
}
void loop(){ }
PROCEDURE:
● Make the connections as per the circuit diagram.
● *Connect arduino uno gnd to GSM gnd.
● *Connect GSM TX to arduino pin2.
● *Connect GSM RX to arduino pin3.
● *Insert the SIM in GSM SIM socket.
● *Give the power supply to GSM,and connect the Arduino to the
laptop via data cable.
● *Go to Arduino ide software, copy the sketch and paste in a new
file.
● *Replace your phone number and SMS in the sketch.(where you
want to have the SMS)
● *Compile and upload the sketch to Arduino uno.
Experiment-3
Design a simple MQTT protocol-based system. The Cloud
application should blink the LED using the MQTT protocol.
APPARATUS REQUIRED:
⦁NodeMCU wifi module (esp8266)
⦁Data cable
⦁System installed with Arduino IDE Software
⦁Mobile with internet access
CIRCUIT DIAGRAM:
PROCEDURE:
● Open Arduino IDE software.
● Erase previous program and open New
file>Examples>PubSubClient(installed library from manage
library)>esp8266.
In Void loop
● Save
● Select nodemcu board and comport.
● Compile>upload.
● Open chrome,search for mqtt lens.
● Click on Launch and then click on add connections.
● Place the hostname,type IP address and save it.
● Make changes in out topic and in topic as per below fig.
OUTPUT:
NOTE: You can observe here. The nodemcu led is when the message is
0.
Experiment-4
Apparatus Required:
● NodeMCU
● Relay
● Jumper wires
● Arduino IOT cloud
● Alexa Mobile App
Circuit Diagram:
1. OPEN CHROME
VARIABLES
23 CLICK ON DONE
3. OPEN APP
4. GO TO DEVICE CLICK ON SYMBOL
7. SEARCH ARDUINO
8.CLICK ON THIS OPTION
Experiment-5
Components Required:
Circuit Diagram:
Code:
BlynkTimer timer;
bool Relay = 0;
void setup() {
Serial.begin(9600);
pinMode(waterPump, OUTPUT);
digitalWrite(waterPump, HIGH);
timer.setInterval(100L, soilMoistureSensor);
BLYNK_WRITE(V1) {
Relay = param.asInt();
if (Relay == 1) {
digitalWrite(waterPump, LOW);
} else {
digitalWrite(waterPump, HIGH);
Serial.println("Motor is ON ");
void soilMoistureSensor() {
Blynk.virtualWrite(V0, value);
void loop() {
Procedure:
Step 1
Step 2
Second, place the Nodemcu board on the breadboard and connect the
VIN and GND pins to the breadboard.
Step 3
Thirdly, place the soil moisture sensor on the breadboard and connect it
to the Nodemcu board. For that, use the circuit diagram below.
Step 4
Now, let’s create the Blynk web dashboard for this project. For that,
follow the steps below.
● First, go to the Blynk website and create a new account using your
Gmail address. And then, sign in to your account and click the new
Template button. Next, enter your project name as you like and
click the done button.
Now, click the “Datastreams” tab and create two data streams for that.
Use the information below.
Next, click the “Web dashboard” tab and include the one button and one
Gauge widget to the dashboard. And then, arrange these widgets as you
like.
Step 6
Now, connect this project to the computer, and let’s upload the program
for this project.
Experiment-6
Apparatus Required:
● NodeMCU
● DHT11 sensor
● USB Cable
● Bread Board
● Jumper Wires
● Arduino IDE Software
Circuit Diagram:
Program Code:
#include <ESP8266WiFi.h>
#include <DHT.h>
#include <ThingSpeak.h>
WiFiClient client;
void setup()
Serial.begin(9600);
WiFi.begin(ssid, pass);
while(WiFi.status() != WL_CONNECTED)
delay(200);
Serial.print("..");
Serial.println();
Serial.println("NodeMCU is connected!");
Serial.println(WiFi.localIP());
dht.begin();
ThingSpeak.begin(client);
void loop()
float h = dht.readHumidity();
float t = dht.readTemperature();
ThingSpeak.writeField(channelID, 1, t, writeAPIkey);
ThingSpeak.writeField(channelID, 2, h, writeAPIkey);
delay(2000);
Once you Sign in after your account verification, Create a new channel by
clicking the “New Channel” button.
After clicking on “New Channel”, enter the Name and Description of the data
you want to upload on this channel. For example, I am sending my DHT11 sensor
data, so I named it DHT1interfacing.
Enter the name of your data ‘Temperature’ in Field1 and ‘Humidity’ in Field2.
If you want to use more Fields, you can check the box next to Field option and
enter the name and description of your data.
After this, click on the save channel button to save your details.
Now copy your “Write API Key”. We will use this API key in our code.
After this navigate to your Thingspeak page and open your channel at
Thingspeak and output will be shown as below:
Procedure:
Experiment-7
Apparatus required:
● NodeMCU ESP8266
● TCS3200 Colour Sensor
● Jumper Wires
● USB cable for power
Circuit diagram:
Vcc 3.3V
GND GND
S0 D4
S1 D5
S2 D6
S3 D7
OUT D8
OE GND
Procedure:
Step 1: Sign up
To send data to Thingspeak, a Thingspeak account is required. To do
so, navigate to the Thingspeak website
Click on the ‘Sign up’ option in the top right corner and fill out the
required details.
After clicking on “New Channel” enter the Name and Description of the
data you want to upload on this channel.
Enter the name of data in Field1, Field2, Field3, and Field4. If you want to
use more field than two, then you can check the box next to the Field
option and enter the name and description of the channel.
After that, click on the ‘Save Channel’ button to complete the channel
creation process.
the ‘Add Widgets’ option and choose the widget you want to use. In this
project, I am using the ‘Numeric Display’ widget.
Click on the “API Keys” option to get a unique API key for uploading
sensor data. Now copy “Write API Key.”
Sketch:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>;
#include <ThingSpeak.h>;
WiFiClient client
int red = 0;
int green = 0;
int blue = 0;
int color=0;
int redcolor = 0;
int greencolor = 0;
int orangecolor = 0;
int yellowcolor = 0;
void setup()
Serial.begin(9600);
pinMode(s0, OUTPUT);
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);
pinMode(out, INPUT);
digitalWrite(s0, HIGH);
digitalWrite(s1, HIGH);
ThingSpeak.begin(client);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
delay(550);
Serial.print(".");
Serial.println("");
Serial.println("WiFi connected");
void loop()
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
digitalWrite(s3, HIGH);
digitalWrite(s2, HIGH);
Serial.print("R Intensity:");
Serial.print(red, DEC);
Serial.print(green, DEC);
Serial.print(blue, DEC);
if(red<39 & red>29 & green<93 & green>83 &blue<78 & blue>69){
redcolor++;
Serial.print("Red");
ThingSpeak.writeField(myChannelNumber, 1,redcolor,
myWriteAPIKey);
orangecolor++;
Serial.print("Orange");
ThingSpeak.writeField(myChannelNumber, 2,orangecolor,
myWriteAPIKey);
greencolor++;
Serial.print("Green");
ThingSpeak.writeField(myChannelNumber, 3,greencolor,
myWriteAPIKey);
if(red<34 & red>25 & green<37 & green>28 & blue<53 & blue>43){
yellowcolor++;
Serial.print("Yellow");
ThingSpeak.writeField(myChannelNumber, 4,yellowcolor,
myWriteAPIKey);
Serial.println();
Output:
Experiment-8
Aim : Implement the car parking system using Arduino uno and IR
sensor.
Apparatus Required:
● IR Sensor
● Servo motor
● LCD Display 16x12 screen
● Arduino boar (UNO)
● Jumper wires
Circuit Diagram:
Procedure:
1. Connections to be made as per the circuit diagram
3. Paste the lcd display program on Arduino ide software we get the
address in serial monitor
1. Open serial monitor and copy the I2C address of lcd display
2. Open the main program of car parking system paste the address to the
LiquidCrystal_I2C lcd(0x27,16, 2);
3. Go to the tools select the manage library in that install the library
LiquidCrystal_I2C ,wire.h ,servo
4. After go to the board and select Arduino UNO select the serial comport
6. Connection
Gnd ,Gnd
Vcc , 5V
SDA, A4
SCD ,A5
VCC ,5V
GND ,GND
DATA, 2
VCC ,5V
GND ,GND
DATA, 4
SERVO MOTOR
VCC, 5V
GND ,GND
DATA, 3
VCC ,5V
GND ,GND
DATA, 5
VCC 5V
GND GND
DATA 6
void setup()
Wire.begin();
Serial.begin(9600);
Serial.println("\nI2C Scanner");
void loop()
int Devices;
Serial.println("Scanning...");
Devices = 0;
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
Devices++;
else if (error==4)
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
if (Devices == 0)
else
Serial.println("done\n");
delay(5000);
Servo myservo;
#define ir_enter 2
#define ir_back 4
#define ir_car1 5
#define ir_car2 6
#define ir_car3 7
#define ir_car4 8
int S1 = 0, S2 = 0, S3 = 0, S4 = 0;
int slot = 4;
void setup() {
Serial.begin(9600);
pinMode(ir_car1, INPUT);
pinMode(ir_car2, INPUT);
pinMode(ir_car3, INPUT);
pinMode(ir_car4, INPUT);
pinMode(ir_enter, INPUT);
pinMode(ir_back, INPUT);
myservo.attach(3);
myservo.write(90);
lcd.init();
lcd.backlight();
lcd.print(" JustDoElectronics");
delay (5000);
lcd.clear();
delay (5000);
lcd.clear();
Read_Sensor();
void loop() {
Read_Sensor();
lcd.print(slot);
lcd.print(" ");
if (S1 == 1) {
lcd.print("S1:Full ");
else {
lcd.print("S1:Empty");
if (S2 == 1) {
lcd.print("S2:Full ");
else {
lcd.print("S2:Empty");
if (S3 == 1) {
lcd.print("S3:Full ");
else {
lcd.print("S3:Empty");
if (S4 == 1) {
lcd.print("S4:Full ");
else {
lcd.print("S4:Empty");
if (slot > 0) {
flag1 = 1;
if (flag2 == 0) {
myservo.write(180);
slot = slot - 1;
} else {
delay(1500);
flag2 = 1;
if (flag1 == 0) {
myservo.write(180);
slot = slot + 1;
delay (1000);
myservo.write(90);
flag1 = 0, flag2 = 0;
delay(1);
void Read_Sensor() {
S1 = 0, S2 = 0, S3 = 0, S4 = 0;
if (digitalRead(ir_car1) == 0) {
S1 = 1;
if (digitalRead(ir_car2) == 0) {
S2 = 1;
if (digitalRead(ir_car3) == 0) {
S3 = 1;
if (digitalRead(ir_car4) == 0) {
S4 = 1;
Experiment-9
APPARATUS REQUIRED :
● CISCO PACKET TRACER SOFTWARE.
Circuit Diagram:
PROCEDURE:
● Open cisco packet tracer software .
● Create a new file .
● Rig up the circuit as shown in circuit diagram.
● Select end devices and select or pick two PCs.
● Select connection( shock symbol) pick cooper cross over it will
automatically connect with two PCs.
● Click on PC0 select configure click fastethernet.
Experiment-10
APPARATUS REQUIRED :
● CISCO PACKET TRACER SOFTWARE.
Circuit Diagram:
PROCEDURE:
● Open cisco packet tracer software .
● Create a new file .
● Rig up the circuit as shown in circuit diagram.
● Select the pt-hub
● Select the different pc’s
● Select the fast ethernet 0 to pc0 fast ethernet 0
● Select the fast ethernet 1 to pc1 fast ethernet 1
● Select the fast ethernet 2 to pc2 fast ethernet 2
● Select the fast ethernet 3 to pc3 fast ethernet 3
● Select the fast ethernet 4 to pc4 fast ethernet 4
● Go to desktop select ip configuration edit ip address
● pc0=10.10.10.0
● pc1=10.10.10.1
● pc2=10.10.10.2
● pc3=10.10.10.3
● pc4=10.10.10.4
● Run the simulation.
Experiment-11
APPARATUS REQUIRED :
● CISCO PACKET TRACER SOFTWARE.
Circuit Diagram:
PROCEDURE:
●Open cisco packet tracer software .
●Create a new file .
●Rig up the circuit as shown in circuit diagram.
●Select the home gateway
●Select the different equipments
●And select the smartphone
●On next click on different equipments select the “HOME
GATEWAY”
● On next click on smart phone and next configure and click on
wireless0 change the SSID to HOME GATEWAY
● Go to the desktop and click on the iot monitor ..login. Analyse the
output
RESULT: SIMULATING HOME AUTOMATION SUCCESSFULLY
DONE.
Experiment-12
APPARATUS REQUIRED :
● CISCO PACKET TRACER SOFTWARE.
Circuit Diagram:
PROCEDURE:
● Open cisco packet tracer software .
● Create a new file .
● Rig up the circuit as shown in circuit diagram.
● Select the 4 different PC’S
● PT- Router And PT-Switch
● And adjust the above figure
● Give default IP-Address for
● PC’S =192.168.1.0
● PC’S =192.168.2.0
● PT-Router =10.12.1.0
● Go to desktop select the IP Configuration Edit the IP Address for
IPv4 in PC’s
● PC 0=192.168.1.2
● PC 1=192.168.1.3
● PC 2=192.168.2.2
● PC 3=192.168.2.3
● Now click on subnet mask after each IP Address assigned in a PC
and even edit the Default gate address of four different pcs
● pc0=192.168.1.1
● pc1=192.168.1.1
● pc2=192.168.2.1
● pc3=192.168.2.1
● On next click on PT-Router and edit the
fastethernet0/0=192.168.1.1
● On next click on PT-Router and edit the
fastethernet0/0=192.168.2.1
● On next click on PT-Router and edit the Serial 2/0=10.12.1.1
● On next click on PT-Router and edit the Serial 2/0=10.12.1.2
● On next click on PT-Router and edit the RIP=192.168.1.0
● =10.12.1.0
● On next click on PT-Router and edit the RIP=192.168.2.0
● =10.12.2.0
● Run the simulation.
Experiment-13
Design an IoT based Water Level Indicator Model Using
Ultrasonic Sensor, NodeMCU and display the water level
on the web server.
Apparatus Required:
● NodeMCU.
● Ultrasonic Sensor.
● Jumpers.
Circuit Diagram:
Procedure:
● Open arduino Ide libraries > Pub sub client->Install
● Go to examples → Pubsub client -> MQTT ESP8266 -> Now our
codes will visible
● add Hotspot name & Password
● Which you have connect through wifi
● Assign value for trigPin as 4
● And assign value for echoPin as 5
● Go to Search → Command prompt -> Type Cmd
Code:
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
long duration;
int distance;
WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE (50)
char msg[MSG_BUFFER_SIZE];
int value = 0;
void setup_wifi()
{ //connect wifi to nodemcu
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
randomSeed(micros());
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
}
Serial.println();
void reconnect()
{
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Create a random client ID
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.c_str()))
{
Serial.println("connected");
// Once connected, publish an announcement...
client.publish("ultra", "mqtt connection is successfull");
// ... and resubscribe
client.subscribe("ledman");
}
else
{
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void setup()
{
pinMode(echoPin,INPUT);
pinMode(trigPin,OUTPUT);
// timer.setInterval(2000L,myTimer);
pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin
as an output
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
}
void loop()
{
if (!client.connected())
{
reconnect();
}
client.loop();
digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin,LOW);
duration=pulseIn(echoPin,HIGH);
distance=duration*0.034/2; //0.034 velocity of sound, /2 to get one way
distance
Experiment-14
Design home automation using Blynk IoT platform.
Apparatus Required:
● Nodemcu board
● Relay module
● Bulb holder
● Bulb
● Plug
● Wires
● Breadboard
● Jumper wires
Circuit Diagram:
Procedure:
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define relay1 D0
#define relay2 D1
BLYNK_WRITE(V0) {
if (value1 == 1) {
digitalWrite(relay1, LOW);
} else {
digitalWrite(relay1, HIGH);
BLYNK_WRITE(V1) {
if (value2 == 1) {
digitalWrite(relay2, LOW);
} else {
digitalWrite(relay2, HIGH);
}}
void setup() {
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
void loop() {
Blynk.run();
● Now, copy and paste the Blynk auth token. To do this, check the
“Device Info” tab of your Blynk web application.
● Next, enter your correct WIFI name and password.
● Now, select the board and port. Then, upload this program to the
Nodemcu board.
● OK, now let’s set up the Blynk mobile dashboard. For that, follow
the instructions below.
● First, download and install the Blynk app on your phone. Then, run
this application. Now, you can see the template we created earlier.
Next, click this template and set up your dashboard.
● Now, click the upper right corner button and include the two
buttons to the dashboard. Then, arrange these widgets as you like.
● Next, click the buttons one by one and select the detastreams V0
and V1 respectively. Also, select the mode as a switch.
Output: