This circuit is designed to monitor temperature using a DHT11 sensor and display the temperature on a 16x2 I2C LCD screen. Based on the temperature readings, it controls the speed of a fan motor using an L298N motor driver. The entire system is powered by a 10000mAh Lithium-ion battery, with voltage regulation provided by a 48V to 5V converter. The Arduino UNO microcontroller is the central unit that processes the sensor data and controls the motor and LCD.
Arduino UNO
L298N Motor Driver Controller Board Module Stepper Motor
DHT11
LCD screen 16x2 I2C
Lithium-ion Battery 10000mAh
48V to 5V Converter
2.1mm Barrel Jack with Terminal Block
Motor
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 6
#define DHTTYPE DHT11
#define MOTOR_PIN_ENA 9
#define MOTOR_PIN_IN1 10
#define MOTOR_PIN_IN2 11
#define TEMPERATURE_THRESHOLD 28
#define TEMPERATURE_THRESHOLD1 32
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(9600);
dht.begin();
Wire.begin();
lcd.init();
lcd.backlight();
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Temperature:");
}
void loop() {
delay(2000);
float temperature = dht.readTemperature();
if (isnan(temperature)) {
Serial.println("Failed to read temperature from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
lcd.setCursor(0, 1);
lcd.print(" ");
if (temperature > TEMPERATURE_THRESHOLD1) {
analogWrite(MOTOR_PIN_ENA, 255);
digitalWrite(MOTOR_PIN_IN1, HIGH);
digitalWrite(MOTOR_PIN_IN2, LOW);
lcd.setCursor(0, 1);
lcd.print("FAN Speed: Max");
}
else if (temperature > TEMPERATURE_THRESHOLD) {
analogWrite(MOTOR_PIN_ENA, 100);
digitalWrite(MOTOR_PIN_IN1, HIGH);
digitalWrite(MOTOR_PIN_IN2, LOW);
lcd.setCursor(0, 1);
lcd.print("FAN Speed: Med");
}
else {
analogWrite(MOTOR_PIN_ENA, 45);
digitalWrite(MOTOR_PIN_IN1, HIGH);
digitalWrite(MOTOR_PIN_IN2, LOW);
lcd.setCursor(0, 1);
lcd.print("FAN Speed: Low");
}
lcd.setCursor(12, 0);
lcd.print(temperature);
}
This code initializes the DHT11 sensor and the LCD screen, reads the temperature from the sensor, and adjusts the fan speed based on the temperature. The temperature is displayed on the LCD screen, and the fan speed is controlled using the L298N motor driver.