You must. In what way are they not reliable? This is how real projects go... your teacher should know about this.
What will you be sensing/testing with the MQ135? It seems unnecessary unless you are instructed to detect gases. Humidity will be detected/sensed by the DHT.
It looks like you have the LCD plugged into DIO#4 and DIO#5 (+pwr, -gnd).
The LCD should be plugged into A4 and A5.
UNO R3 Peripheral module
========== =================
DIO PIN 2 - MQ135 digital output ** (your picture is missing this connection)
DIO PIN 3 - DHT output
DIO PIN 9 - Buzzer output
AIN PIN A0 - MQ135 analog output
AIN PIN A4 - LCD DATA
AIN PIN A5 - LCD CLOCK
POWER RAIL - Arduino 5v, MQ135, DHT, LCD
GROUND RAIL - Arduino GND, MQ135, DHT, LCD, BUZZER
Your power supply must be 5vdc in this case. You should wire everything together and use the following stand-alone module test sketches. When they all work, you should combine the sketches.
BUZZER
// test buzzer on dio pin 9
int buzzerPin = 9;
void setup() {
pinMode(buzzerPin, OUTPUT);
delay(2000);
for (int i = 0; i < 5; i++) {
digitalWrite(buzzerPin, HIGH);
delay(250);
digitalWrite(buzzerPin, LOW);
delay(250);
}
}
void loop() {
// nothing here
}
LCD
// LCD I2C test
#include <LiquidCrystal_I2C.h> // library https://github.com/lucasmaziero/LiquidCrystal_I2C
#define I2C_ADDR 0x27 // address of LCD
#define LCD_COLS 16 // columns of LCD
#define LCD_ROWS 2 // rows of LCD
LiquidCrystal_I2C myLCD(I2C_ADDR, LCD_COLS, LCD_ROWS); // create LCD_I2C instance/object
void setup() {
myLCD.init(); // initilize LCD object
myLCD.backlight(); // turn backlight ON
myLCD.setCursor(0, 0); // COL 0, ROW 0
myLCD.print("Hello, World!");
myLCD.setCursor(10, 1); // COL 10, ROW 1
myLCD.print("@biim");
}
void loop() {
// do nothing
}
LCD
// LCD I2C test
#include <LiquidCrystal_I2C.h> // library https://github.com/lucasmaziero/LiquidCrystal_I2C
#define I2C_ADDR 0x27 // address of LCD
#define LCD_COLS 16 // columns of LCD
#define LCD_ROWS 2 // rows of LCD
LiquidCrystal_I2C myLCD(I2C_ADDR, LCD_COLS, LCD_ROWS); // create LCD_I2C instance/object
void setup() {
myLCD.init(); // initilize LCD object
myLCD.backlight(); // turn backlight ON
myLCD.setCursor(0, 0); // COL 0, ROW 0
myLCD.print("Hello, World!");
myLCD.setCursor(11, 1); // COL 10, ROW 1
myLCD.print("@biim");
}
void loop() {
// do nothing
}
DHT
// DHT test on pin 3
#include <DHT.h> // https://github.com/adafruit/DHT-sensor-library
#define DHTPIN 3 // DHT data pin
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE); // configure DHT object/instance
void setup() {
Serial.begin(115200);
dht.begin(); // initialize DHT11
}
void loop() {
delay(2000); // wait before reading
float h = dht.readHumidity(); // read humidity
float t = dht.readTemperature(); // read temperature in centigrade
if (isnan(h) || isnan(t)) { // check for invalid readings
Serial.println(F("DHT reading failed."));
return; // quit
}
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.println();
}
MQ
// MQ135 test using pins AIN A0 and DIO 2 as input pins
int MQanalogPin = A0, MQdigitalPin = 2; // assign Arduino pins
int MQanalogValue, MQdigitalValue; // variables to store MQ output values
void setup() {
Serial.begin(115200); // serial port baud rate
pinMode(MQdigitalPin, INPUT); // configure DIO pin 2
pinMode(MQanalogPin, INPUT); // configure AIN A0 for clarity
Serial.println("Warm-up for 30 seconds.");
}
void loop() {
MQanalogValue = analogRead(MQanalogPin); // read MQ analog output on AIN A0
MQdigitalValue = digitalRead(MQdigitalPin); // read MQ digital output on DIO 2
Serial.print("Analog: ");
Serial.print(MQanalogValue); // print MQ Analog Output
Serial.print(" Digital: ");
Serial.print(MQdigitalValue);
Serial.println();
delay(1000); // wait one second
}