0% found this document useful (0 votes)
14 views5 pages

Mine Iot 3

The document outlines an experiment to monitor air quality using the MQ135 gas sensor and display the data on ThingSpeak. It details the aim, objectives, hardware used, procedures, implementation code, and analysis of the experiment's outcomes. The experiment successfully demonstrated real-time air quality monitoring and data visualization through an IoT-based system.
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)
14 views5 pages

Mine Iot 3

The document outlines an experiment to monitor air quality using the MQ135 gas sensor and display the data on ThingSpeak. It details the aim, objectives, hardware used, procedures, implementation code, and analysis of the experiment's outcomes. The experiment successfully demonstrated real-time air quality monitoring and data visualization through an IoT-based system.
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/ 5

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment-3

Student Name: Mohd Talib Siddiqi UID:22BCS13509


Branch: BE-CSE Section/Group:22BCS_ 620/A.
Semester:6th Date of Performance:05/02/2025.
Subject Name: Foundation of Cloud IOT Edge ML Subject Code: 22CSP-367

1. Aim: Monitor air quality using a gas sensor (MQ135) and display the data on
ThingSpeak.

2. Objective: Monitor air quality using the MQ135 gas sensor and send the data to
ThingSpeak for visualization and analysis.

3. Hardware Used: MQ135 gas sensor, ESP8266/NodeMCU, Breadboard, Jumper


Wires, Power Supply and ThingSpeak Account.

4. Procedure:

 Connect the MQ135 sensor to the NodeMCU by wiring VCC to 3V3 or 5V


(depending on module support), GND to GND, and A0 to A0.

 Create a ThingSpeak account, set up a new channel, add a field (e.g., "Air Quality"),
and note down the Write API Key from the API Keys tab.

 Open Arduino IDE, go to Tools > Manage Libraries, search for ESP8266, and
install the required library.

 Install additional libraries such as ThingSpeak and ESP8266WiFi by searching for


them in the Library Manager.

 Create a new sketch in Arduino IDE for reading air quality data from the MQ135
sensor.

 Initialize the ESP8266 Wi-Fi module and connect it to a Wi-Fi network using the
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

 WiFi.begin(SSID, PASSWORD) function.

 Read the analog value from the MQ135 sensor using analogRead(A0) and process
the data for air quality measurement.

 Format the sensor data into an HTTP request and send it to ThingSpeak using
the HTTPClient library.

 Use the ThingSpeak.writeField() function to upload the air quality data to the
ThingSpeak channel at regular intervals.

 Add a delay(15000) (15 seconds) between consecutive uploads to comply with


ThingSpeak’s update rate limits.

 Verify and upload the code to the NodeMCU and monitor the Serial Monitor for
debugging messages.

 Check the ThingSpeak dashboard to visualize real-time air quality variations and
analyze the collected data.

5. Implementation Script/Code:

#include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h>


const char* ssid = "Your_SSID"; const char* password = "Your_PASSWORD";
const char* server = "http://api.thingspeak.com"; String apiKey =
"YOUR_API_KEY"; mq135Pin = A0;

void setup() { Serial.begin(115200);


WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) {
delay(1000); Serial.println("Connecting to WiFi...");

}
Serial.println("Connected to WiFi");
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

void loop() {
airQuality = analogRead(mq135Pin);

Serial.println("Air Quality Value: " + String(airQuality));


if (WiFi.status() == WL_CONNECTED) { HTTPClient http;
String url = server + "/update?api_key=" + apiKey + "&field1=" + String(airQuality);
http.begin(url);

int httpCode = http.GET(); if (httpCode > 0) {


Serial.println("Data sent to ThingSpeak successfully.");
} else {
Serial.println("Error sending data.");
}
http.end();
}
delay(15000);
}

6. Output:
a)

Simulated Output
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

b)

Hardware Configuration

c)

ThingSpeak Output

7. Conclusion:

In this experiment, we successfully monitored air quality using the MQ135 gas sensor
and displayed the data on ThingSpeak for real-time visualization and analysis. The
ESP8266/NodeMCU was used to read the analog values from the sensor and transmit the
data to the ThingSpeak cloud platform via an HTTP request.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

The implementation demonstrated how to interface a gas sensor with an IoT-based


system for remote monitoring. The data was uploaded at regular intervals, allowing
continuous tracking of air quality variations. The ThingSpeak dashboard provided a
graphical representation of the recorded values, making it easier to analyze trends and
detect fluctuations.

8. Analysis:

 Sensor Data Accuracy – The MQ135 sensor provides analog readings based on the
concentration of gases in the environment. However, calibration may be needed for
precise air quality measurements.

 Wi-Fi Connectivity – The ESP8266 successfully connected to the Wi-Fi network and
transmitted data to ThingSpeak. Any network instability could affect data transmission.

 Data Transmission – The data was uploaded to ThingSpeak at 15-second intervals,


ensuring continuous real-time monitoring while adhering to ThingSpeak’s update
limits.

 Visualization on ThingSpeak – The recorded air quality values were displayed


graphically, enabling easy trend analysis and pattern recognition over time.

 Code Functionality – The script correctly initialized the Wi-Fi module, read sensor
data, formatted an HTTP request, and sent it to ThingSpeak without errors.

 Power Consumption – The ESP8266 and MQ135 sensor required a stable power
supply for consistent performance. Using a 5V source ensured reliable operation.

You might also like