The circuit is designed to monitor air quality and humidity levels, displaying the data on an I2C LCD 16x2 screen. It consists of an MQ135 gas sensor for air quality detection, a DHT11 sensor for measuring temperature and humidity, and a NodeMCU V3 ESP8266 microcontroller for processing sensor data and controlling the LCD display. The circuit is powered through a common VCC line and grounded through a common GND line.
/*
* Air Quality and Humidity Monitoring System
* This Arduino sketch reads data from an MQ135 gas sensor and a DHT11
* humidity sensor, and displays the temperature, humidity, and air quality
* on an I2C LCD 16x2 screen. The system is designed to track air quality
* and humidity for healthier air and informed decisions.
*/
#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN D4 // Pin connected to the DHT11 sensor
#define DHTTYPE DHT11 // DHT 11
#define MQ135PIN A0 // Pin connected to the MQ135 sensor
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
dht.begin(); // Initialize the DHT sensor
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight of the LCD
}
void loop() {
// Read data from sensors
float temp = dht.readTemperature(); // Read temperature in Celsius
float hum = dht.readHumidity(); // Read humidity percentage
int airQuality = analogRead(MQ135PIN); // Read air quality from MQ135
// Display data on LCD
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temp);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Hum: ");
lcd.print(hum);
lcd.print("%");
lcd.setCursor(8, 1);
lcd.print("AQ: ");
lcd.print(airQuality);
lcd.print("ppm");
// Print data to Serial Monitor
Serial.print("Temperature: ");
Serial.print(temp);
Serial.print("C");
Serial.print(" Humidity: ");
Serial.print(hum);
Serial.print("%");
Serial.print(" Air Quality: ");
Serial.print(airQuality);
Serial.println("ppm");
delay(2000); // Wait for 2 seconds before next read
}
/*
* Real-time Air Quality Monitoring System
* This Arduino sketch reads data from a DHT11 sensor and displays the
* temperature and humidity on the Serial Monitor. The system is designed
* to track air quality for healthier air and informed decisions.
*/
#include <DHT.h>
#define DHTPIN D4 // Pin connected to the DHT11 sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
dht.begin(); // Initialize the DHT sensor
}
void loop() {
// Read data from the DHT11 sensor
float temp = dht.readTemperature(); // Read temperature in Celsius
float hum = dht.readHumidity(); // Read humidity percentage
if (isnan(temp) || isnan(hum)) {
Serial.println("Failed to read from DHT sensor!");
}
else {
// Print data to Serial Monitor
Serial.print("Temperature: ");
Serial.print(temp);
Serial.print("C");
Serial.print(" Humidity: ");
Serial.print(hum);
Serial.println("%");
delay(2000); // Wait for 2 seconds before next read
}
}
(Note: The code for the MQ135 sensor and the I2C LCD 16x2 Screen is integrated into the NodeMCU V3 ESP8266 code section above.)