Iot Lab Manual
Iot Lab Manual
LAB MANUAL
Programme : B. Tech
Semester : VIII
Prepared By:
Yash lodha
(0173cs201062) Approved By:
LIST OF EXPERIMENTS TO BE CONDUCTED
S. NO EXPERIMENT PAGE NO
Hardware Procedure:
Software Procedure:
2. Click on file
3. Click on New
5. Click on Save
6. Click on Verify
7. Click on Upload the code into Arduino Uno by using USB cable.
Program:
const int led = 2;
Precautions:
Conclusion:
Viva questions:
Experiment: 02
Apparatus:
Hardware Procedure:
LED pin is Connected to Arduino Uno pin of 11 & 12.
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on Upload the code into Arduino Uno by using USB cable.
Program:
#define LED_PIN 11
#define POTENTIOMETER_PIN A1
void setup() {
// put your setup code here, to run once:
pinMode(4,INPUT);
pinMode(12,OUTPUT);//LED
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:potentiometer loop int
potentiometerValue = analogRead(POTENTIOMETER_PIN); int brightness =
potentiometerValue / 4;
analogWrite(LED_PIN, brightness);
else { digitalWrite(12,LOW);
}
}Precautions:
RESULT: Both Analog and Digital Sensors data are successfully measured by Arduino.
Experiment: 03
Apparatus:
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3.Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6.Click on Verify
7. Click on Upload the code into Arduino Uno by using USB cable.
8. Install Serial Bluetooth Terminal app on mobile phone.
9. Pair your phone with Bluetooth Module and open Bluetooth app then give commands
As per the Code.
Program:
char data; //Variable for storing received data void
setup()
{
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data and store it into variable
data
}else{
digitalWrite(13, LOW); //if any other value both LED turns off
digitalWrite(12,LOW);
}
}Precautions:
● Wifi module pins RX & TX are connected to 8 and 9 pin of Arduino ( RX = 8, TX = 9).
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3.Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6.Click on Verify
7.Click on Upload the code into Arduino Uno by using USB cable.
THINGS SPEAK ACCOUNT CREATION PROCEDURE:
1. First, open ThingsSpeak.com website, and then create an account.
2. And then click on verify on gmail.
3. Login to things speak website and create channel and save it.
4. Go to the API key and then copy “write API key”.
5. And paste that API key in Arduino code
6. After successful code uploading and circuit connections.
7. Open Things Speak account private view, Sensor data will be shown in graph.
Program:
#include <dht.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
dht DHT;
void setup()
{ lcd.begin(16, 2);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, 0);
project_Name(); Serial.begin(9600);
Serial.println("AT"); delay(1000);
Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CNMI=2,2,0,0,0");
delay(1000);
lcd.setCursor(0,0); lcd.print("WiFi
module "); lcd.setCursor(0,1);
lcd.print("Initilizing ");
wifi.begin(115200);
wifi.println("AT+RST"); delay(4000);
wifi.println("AT+CWMODE=3");
delay(4000); wifi.print("AT+CWJAP=");
wifi.write('"'); wifi.print("STTMANI");
wifi.write('"');
wifi.write(',');
wifi.write('"');
wifi.print("hailucky123,./");
wifi.write('"'); wifi.println();
delay(1000); lcd.setCursor(0,0);
lcd.print("WiFi module ");
lcd.setCursor(0,1);
lcd.print("Initilized ");
delay(1000);
lcd.clear();
}
void loop()
{
int chk = DHT.read11(DHT11_PIN);
//SendWiFi_Data();
//delay(1000); lcd.setCursor(0,0);
lcd.print("Temperature: ");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.setCursor(12,0);
lcd.print(DHT.temperature);
lcd.setCursor(9,1);
lcd.print(DHT.humidity); delay(500);
/* Tempurature Data Process*/
if(DHT.temperature > 45)
{
buzzer_sound();
}
/* Humidity Data Process*/
if(DHT.humidity < 30)
{
buzzer_sound();
}
lcd.setCursor(15,1);
lcd.write(0x20);
SendWiFi_Data();
delay(1000);
}
void SendWiFi_Data(){
String cmd = "AT+CIPSTART=\"TCP\",\""; cmd +=
"184.106.153.149"; // api.thingspeak.com cmd += "\",80";
wifi.println(cmd);
delay(1500);
+= "\r\n\r\n";
void buzzer_sound()
{
digitalWrite(buzzer, HIGH);
delay(600); digitalWrite(buzzer,
LOW); delay(400);
digitalWrite(buzzer, HIGH);
delay(600); digitalWrite(buzzer,
LOW); delay(400);
}
void project_Name()
{ lcd.setCursor(0,0); lcd.print("
ESP8266 ");
lcd.setCursor(0,1); lcd.print("
Interfacing "); delay(3000);
lcd.clear();
Precautions:
RESULT: Things Speak account will be successfully created. DHT11 Sensor data will be uploaded to
cloud.
Experiment: 05
Hardware Procedure:
● Wifi module pins RX & TX are connected to 8 and 9 pin of Arduino ( RX = 8, TX = 9).
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Login to ThingsSpeak account and then go to apps and create talkback.
7. Copy those Talkback id and Read API key and paste it on the Arduino Code
8. Give commands from cloud which was given in the code.
10. Click on save & Click on Verify.
11. Click on Upload code into Arduino Uno by using USB cable.
12. Relays are turned on and turned off while giving the commands.
Program:
#include <SoftwareSerial.h> #include
<stdlib.h>
int ch,ch1,mode=1;
void setup()
{ wifi.begin(115200);
Serial.begin(115200);
pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
delay(100);
Serial.println("WiFi Module initilizing ");
wifi.println("AT+RST");
delay(4000);
wifi.println("AT+CWMODE=3");//AT+CWJAP="SSID","PASWD"
delay(4000);
wifi.print("AT+CWJAP=");
wifi.write('"');
wifi.print("STTMANI2");
wifi.write('"');
wifi.write(',');
wifi.write('"');
wifi.print("hailucky123,./");
wifi.write('"'); wifi.println();
delay(2000);
void loop(){
String cmd = "AT+CIPSTART=\"TCP\",\""; cmd +=
"184.106.153.149"; // api.thingspeak.com cmd += "\",80";
wifi.println(cmd);
delay(1000);
String
getStr ="GET
/talkbacks/47047/commands/execute?api_key=5G9L2SELAH60VR3F\r\n\r\n";
wifi.end(); delay(1000);
wifi.begin(115200);
delay(1500);
wifi.println(getStr);
for(i=0;i<=1000;i++)
{
if(wifi.available())
{
ch=wifi.read();
Serial.write(ch);
}
}
delay(1200);
for(i=0;i<=1000;i++)
{
if(wifi.available())
{
ch=wifi.read();
if(ch==':')
gotoxx; ch1=ch;
Serial.write(ch);
}
}
xx: ch1=wifi.read();
if(mode==1)
{
if(ch1=='1')
{
digitalWrite(relay1,HIGH);
Serial.println("relay1 ON");
}
if(ch1=='2')
{
digitalWrite(relay1,LOW);
Serial.println("relay1 OFF");
}
if(ch1=='3')
{
digitalWrite(relay2,HIGH);
Serial.println("relay2 ON");
}
if(ch1=='4')
{
digitalWrite(relay2,LOW);
Serial.println("relay2 OFF");
}
}
}Precautions:
Hardware Procedure:
● Wifi module pins RX & TX are connected to 8 and 9 pin of Arduino ( RX = 8, TX = 9).
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Create an Account in Things Speak, then create a channel.
7. Go to API keys in that Channel and then copy “Write API key”.
8. Go to Arduino code and paste Write API key.
9. Give your mobile hotspot name and password in Arduino code.
10. Click on save & Click on Verify.
11. Click on Upload the code into Arduino Uno by using USB cable.
12. After that open things Speak account and click on private view
13. DHT11 Sensor data will be uploaded and it will be shown as graph in Private view on Things
Speak account.
Program:
#include <dht.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
LiquidCrystallcd(2,3, 4, 5, 6, 7);
SoftwareSerialwifi(8, 9); // TX, RX
dhtDHT;
void setup()
{ lcd.begin(16, 2);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, 0);
project_Name(); Serial.begin(9600);
Serial.println("AT"); delay(1000);
Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CNMI=2,2,0,0,0");
delay(1000);
lcd.setCursor(0,0); lcd.print("WiFi
module "); lcd.setCursor(0,1);
lcd.print("Initilizing ");
wifi.begin(115200);
wifi.println("AT+RST");
delay(4000);
wifi.println("AT+CWMODE=3");
delay(4000); wifi.print("AT+CWJAP=");
wifi.write('"'); wifi.print("STTMANI");
wifi.write('"');
wifi.write(',');
wifi.write('"');
wifi.print("hailucky123,./");
wifi.write('"'); wifi.println();
delay(1000); lcd.setCursor(0,0);
lcd.print("WiFi module ");
lcd.setCursor(0,1);
lcd.print("Initilized ");
delay(1000);
lcd.clear();
}
void loop()
{
int chk = DHT.read11(DHT11_PIN);
//SendWiFi_Data();
//delay(1000); lcd.setCursor(0,0);
lcd.print("Temperature: ");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.setCursor(12,0);
lcd.print(DHT.temperature);
lcd.setCursor(9,1);
lcd.print(DHT.humidity);
delay(500);
/* Tempurature Data Process*/
if(DHT.temperature> 45)
{
buzzer_sound();
}
/* Humidity Data Process*/
if(DHT.humidity< 30)
{
buzzer_sound();
}
lcd.setCursor(15,1);
lcd.write(0x20);
SendWiFi_Data();
delay(1000);
}
void SendWiFi_Data(){
String cmd = "AT+CIPSTART=\"TCP\",\""; cmd +=
"184.106.153.149"; // api.thingspeak.com cmd +=
"\",80";
wifi.println(cmd);
delay(1500);
+= "\r\n\r\n";
void buzzer_sound()
{
digitalWrite(buzzer, HIGH);
delay(600); digitalWrite(buzzer,
LOW); delay(400);
digitalWrite(buzzer, HIGH);
delay(600); digitalWrite(buzzer,
LOW); delay(400);
}
void project_Name()
{ lcd.setCursor(0,0); lcd.print("
ESP8266 ");
lcd.setCursor(0,1); lcd.print("
Interfacing "); delay(3000);
lcd.clear();
}
Precautions:
Aim: To Interface MQ-7and MQ-135 Sensor Using ArduinoUno boardto measure Carbon
monoxide and Ammonia gas.
Apparatus:
Hardware Procedure:
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3.Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6.Click on Verify
7.Click on Upload the code into Arduino Uno by using USB cable.
Program:
#include<LiquidCrystal.h>
LiquidCrystallcd(2, 3, 4, 5, 6, 7);
void setup()
{
lcd.begin(16, 2);
project_Name();
}
void loop()
{
int mq7_gas_sensor_data = analogRead(A0); int
mq135_gas_sensor_data = analogRead(A1);
lcd.setCursor(0,0);
lcd.print("MQ7 Data: ");
lcd.setCursor(9,0);
lcd.print(mq7_gas_sensor_data);
lcd.setCursor(0,1); lcd.print("MQ135
Data: ");
lcd.setCursor(12,1);
lcd.print(mq135_gas_sensor_data);
delay(1000);
}
void project_Name()
{ lcd.setCursor(0,0);
lcd.print(" AIR POLLUTION ");
lcd.setCursor(0,1); lcd.print("CONTROL
SYSTEM");
delay(3000);
lcd.clear();
}
Precautions:
RESULT:MQ – 7 gas sensor detects the Carbon Monoxide gas. And MQ – 135 gas sensor detects Ammonia
gas. Whenever the gas value exceeds the threshold value, buzzer starts sounding. And MQ-7 and MQ-135 sensors
data also uploaded to cloud successfully.
Experiment: 08
Apparatus:
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on Upload the code into Arduino Uno by using USB cable.
Program: #include<LiquidCrystal.h>
int relay = 8;
const int TDS_sensor = 9;
void setup()
{
lcd.begin(16, 2); pinMode(relay,
OUTPUT); digitalWrite(relay, LOW);
project_Name();
}
void loop()
{
int TDS_sensor_data = analogRead(A0);
lcd.setCursor(0,0);
lcd.print("TDS Data: ");
lcd.setCursor(0,1); lcd.print(" ");
lcd.setCursor(9,0);
lcd.print(TDS_sensor_data);
if(TDS_sensor_data >150)
digitalWrite(relay, HIGH); else
digitalWrite(relay, LOW); delay(500);
Apparatus:
Hardware Procedure:
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3.Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6.Click on Verify
7.Click on Upload the code into Arduino Uno by using USB cable.
Program:
const int Actuator = 9; void
setup()
{ Serial.begin(9600);
pinMode(Actuator, OUTPUT);
}
if (Serial.available()) { brightness =
Serial.read();
Serial.println(brightness);
}
if(brightness == 'a')
digitalWrite(Actuator, HIGH); else
if(brightness == 'b')
digitalWrite(Actuator
, LOW);
}
Precautions: