0% found this document useful (0 votes)
10 views10 pages

Expt 3

Uploaded by

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

Expt 3

Uploaded by

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

School of Electronics Engineering (SENSE)

BECE352E – IOT DOMAIN ANALYTICS


LAB RECORD

Submitted By
21BEC1204-Swathi N S

Submitted To
Dr. Berlin Hency
Expt:3 Atmospheric monitoring using ESP8266-NODEMCU 12E
24.01.24 with MQ2 and DHT 11 and thinkspeak cloud computing
Aim:
To monitor atmosphere using ESP8266-NODEMCU12E with MQ2(gas sensor)
and DHT 11 (humidity and temperature sensor) and upload sensor information
to cloud using thinkspeak cloud computing .
Components used:
ESP8266-NODEMCU 12E
DHT2
MQ135
Software used:
Arduino IDE
Procedure:
 Open Arduino ID
 Save the file and Install packages of thingspeak, sensors and
ESP8266 from library manager.
 Now type the code and chose the board as nodemcu 12E
 Connect the Nodemcu board with sensors and connect with the
port.
 Open thingspeak and enter the output which has to be displayed.
 Now choose the port in Arduino ID and upload.
 Open serial monitor and thingspeak to check the output.
Code:
#include <ESP8266WiFi.h>
#include <DHT.h>
#include <ThingSpeak.h>
#include "MQ2.h"
int Analog_Input = A0;
int lpg, co, smoke, smoke1;
float h, t;
MQ2 mq2(Analog_Input);
const char *ssid = "Galaxy A22 5G7259";
const char *pass = "tflp4120";
DHT dht(D5, DHT11);
WiFiClient client;
long myChannelNumber = 1498653;
const char myWriteAPIKey[] = "R345CDR6NNVN0QCP";
// The load resistance on the board
//#define RLOAD 22.0
// Calibration resistance at atmospheric CO2 level
//#define RZERO 879.13
int val;
void setup() {
mq2.begin();
// put your setup code here, to run once:
Serial.begin(115200);
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() {
// put your main code here, to run repeatedly:
float h = dht.readHumidity();
float t = dht.readTemperature();
float* values= mq2.read(true); //set it false if you don't want to print the values
in the Serial
//lpg = values[0];
lpg = mq2.readLPG();
//co = values[1];
co = mq2.readCO();
//smoke = values[2];
smoke = mq2.readSmoke();
smoke1=(smoke*100)/1000000;
Serial.println("LPG:");
Serial.println(lpg);
Serial.println(" CO:");
Serial.println(co);
Serial.println("SMOKE:");
Serial.println(smoke1);
Serial.println(" %");
delay(1000);
ThingSpeak.writeField(myChannelNumber, 1, lpg, myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber, 2, co, myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber, 3, smoke1, myWriteAPIKey);
Serial.println("Temperature: " + (String) t);
Serial.println("Humidity: " + (String) h);
ThingSpeak.writeField(myChannelNumber, 4, t, myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber, 5, h, myWriteAPIKey);
delay(100);
}
Circuit diagram:
Serial monitor output:
Thingspeak output:
Output verification:
Result:
Hence atmosphere is monitored using ESP8266-NODEMCU12E with MQ2(gas
sensor) and DHT 11 (humidity and temperature sensor) and information of
sensor has been uploaded to cloud using thinkspeak cloud computing

You might also like