You are on page 1of 8

Name: Ankur Vatsa

Registration No.: - 21BAI1199


Slot: L9+L10

Experiment-5
IoT Domain Analyst

Submitted to:
Prof . Prasanna Bharathi
Temperature and Humidity Monitoring
Aim : Atmospheric monitoring using ESP8266 – NODEMCU 12Ewith MQ135 and
DHT11and Thingspeak Cloud Computing.

Thoery :
1. Introduction:

Atmospheric monitoring is crucial for understanding air quality and environmental


conditions. In this experiment, we utilize an ESP8266 (NODEMCU 12E) microcontroller
to interface with sensors, namely the MQ135 gas sensor for detecting air quality and the
DHT11 sensor for measuring humidity and temperature.

2. Components:

- ESP8266 (NODEMCU 12E): This microcontroller provides Wi-Fi connectivity,


enabling data transmission to cloud platforms.

- MQ135 Gas Sensor:Specifically designed for air quality monitoring, it measures


various gases including carbon dioxide, methane, and ammonia.

- DHT11 Sensor:Measures humidity and temperature, providing additional


environmental data.

3. Working Principle:

- The ESP8266 collects data from the MQ135 and DHT11 sensors through analog and
digital interfaces, respectively.

- The MQ135 detects gases in the air based on their resistance changes. These changes
are converted to gas concentration levels.

- The DHT11 measures humidity and temperature and provides digital signals for the
microcontroller to interpret.

4. Calibration:

- Calibration of the sensors is essential for accurate readings. This involves exposing
the sensors to known concentrations of gases and humidity and adjusting the readings
accordingly.

5. Data Transmission:

- The ESP8266 is programmed to establish a Wi-Fi connection and transmit sensor


data to the Thingspeak cloud platform.
- Thingspeak allows for real-time data visualization, storage, and analysis. It provides
an easy-to-use interface for monitoring and sharing the collected data

6. Cloud Computing Integration:

- Thingspeak enables cloud computing by storing and processing data remotely. Users
can access the data through web interfaces or APIs.

- Cloud computing facilitates the aggregation of data from multiple devices, allowing
for comprehensive analysis and decision-making.

7. Applications:

- The atmospheric monitoring system finds applications in environmental research,


smart cities, and industries where air quality and environmental conditions are critical.

Procedure :
 Connect the MQ135 gas sensor to the analog pin of the ESP8266 (NODEMCU
12E).
 Connect the DHT11 sensor to the digital pin of the ESP8266 (NODEMCU 12E).
 Power the sensors and ESP8266 appropriately.
 Install the Arduino IDE and necessary libraries for ESP8266, MQ135, and DHT11.
 Write a program to read data from MQ135 and DHT11 sensors.
 Implement calibration for accurate sensor readings.
 Configure the ESP8266 to connect to Wi-Fi.
 Create a Thingspeak account and set up a new channel.
 Note down the API key provided by Thingspeak for data transmission.
 Modify the Arduino code to include Thingspeak API key and update frequency.
 Expose the sensors to a known concentration of gases for MQ135.
 Adjust sensor readings based on calibration results.
 Upload the Arduino code to the ESP8266.
 Monitor the serial output to ensure the sensors are providing accurate data.
 Check if the ESP8266 successfully connects to Wi-Fi and transmits data to
Thingspeak. a. Visit the Thingspeak channel to visualize the real-time data.
 Explore different visualization options and configure the channel settings.
 If issues arise, check wiring connections and sensor calibration.
 Verify the Wi-Fi connectivity of the ESP8266.
 Monitor serial output for debugging information. a. Once testing is successful,
deploy the atmospheric monitoring system in the desired location.
 b. Ensure continuous power supply for long-term monitoring.
 Utilize Thingspeak's analytics tools for in-depth analysis of collected data.
 Explore trends and patterns in air quality and environmental conditions.
 Document the entire setup, including hardware connections, software code, and
calibration results.
 Provide instructions for future maintenance and updates.

Circuit :

Properties :
Code:
#include <DHT.h> // Including library for dht

#include <ESP8266WiFi.h>

String apiKey = ""; // Enter your Write API key from ThingSpeak

const char *ssid = ""; // replace with your wifi ssid and wpa2 key

const char *pass = "";

const char *server = "api.thingspeak.com";

#define DHTPIN 0 // pin where the dht11 is connected

DHT dht(DHTPIN, DHT11);

WiFiClient client;

void setup()

Serial.begin(115200);

delay(10);

dht.begin();

Serial.println("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, pass);

while (WiFi.status() != WL_CONNECTED)

delay(500);

Serial.print(".");
}

Serial.println("");

Serial.println("WiFi connected");
}

void loop()

float h = dht.readHumidity();

float t = dht.readTemperature();

if (isnan(h) || isnan(t))

Serial.println("Failed to read from DHT sensor!");

return;
}

if (client.connect(server, 80)) // "184.106.153.149" or api.thingspeak.com

String postStr = apiKey;

postStr += "&field1=";

postStr += String(t);

postStr += "&field2=";

postStr += String(h);

postStr += "\r\n\r\n";

client.print("POST /update HTTP/1.1\n");

client.print("Host: api.thingspeak.com\n");

client.print("Connection: close\n");

client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");

client.print("Content-Type: application/x-www-form-urlencoded\n");

client.print("Content-Length: ");

client.print(postStr.length());
client.print("\n\n");

client.print(postStr);

Serial.print("Temperature: ");

Serial.print(t);

Serial.print(" degrees Celcius, Humidity: ");

Serial.print(h);

Serial.println("%. Send to Thingspeak.");


}

client.stop();

Serial.println("Waiting...");

// thingspeak needs minimum 15 sec delay between updates

delay(1000);
}

Output :
Inference:
The implemented atmospheric monitoring system utilizing ESP8266, MQ135, and DHT11 sensors,
integrated with Thingspeak cloud computing, offers a cost-effective and efficient solution for real-
time data collection, enabling informed decision-making in environmental monitoring.
Result:
Hence, Atmospheric monitoring has been done using ESP8266 – NODEMCU 12Ewith MQ135
and DHT11and Thingspeak Cloud Computing

You might also like