Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Temperature-Controlled Fan System with OLED Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Temperature-Controlled Fan System with OLED Display

Circuit Documentation

Summary of the Circuit

This circuit is designed to control a DC motor (fan) based on temperature readings from a DHT11 sensor and user input from a potentiometer. The system uses an Arduino UNO as the central microcontroller to process sensor data, control the motor speed, and display information on a 0.96" OLED screen. The temperature threshold for activating the fan is set at 25°C, above which the fan's speed is adjusted proportionally to the temperature and potentiometer setting.

Component List

0.96" OLED

KY-015 DHT11

Arduino UNO

Potentiometer

Resistor

9V Battery

DC Motor

Wiring Details

0.96" OLED

KY-015 DHT11

Arduino UNO

Potentiometer

Resistor

9V Battery

DC Motor

Documented Code

#include <DHT.h>          // Include the DHT library
#include <Wire.h>         // Include Wire library for I2C
#include <Adafruit_GFX.h> // Include the graphics library
#include <Adafruit_SSD1306.h> // Include the OLED library

#define DHTPIN 2         // Pin where the sensor is connected
#define FAN_PIN 9        // PWM pin to control the fan
#define POT_PIN A0       // Potentiometer pin
#define DHTTYPE DHT11    // DHT 11

DHT dht(DHTPIN, DHTTYPE);
Adafruit_SSD1306 display(128, 64, &Wire, -1); // Create display object

void setup() {
    pinMode(FAN_PIN, OUTPUT);
    dht.begin();
    display.begin(SSD1306_I2C_ADDRESS, 0x3C); // Initialize OLED
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0, 0);
    display.print("Fan Control System");
    display.display();
    delay(2000);
}

void loop() {
    float temperature = dht.readTemperature(); // Read temperature
    int potValue = analogRead(POT_PIN); // Read potentiometer value
    int fanSpeed = map(potValue, 0, 1023, 0, 255); // Map pot value to fan speed

    // Update fan speed based on temperature
    if (temperature > 25) {
        fanSpeed = map(temperature, 25, 35, 0, 255);
        fanSpeed = constrain(fanSpeed, 0, 255); // Ensure speed is between 0 and 255
    } else {
        fanSpeed = 0; // Turn off fan if temperature is 25°C or below
    }

    // Set fan speed (you may need to modify this based on the fan type)
    analogWrite(FAN_PIN, fanSpeed);

    // Display temperature and fan speed on OLED
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print("Temp: ");
    display.print(temperature);
    display.print(" C");
    display.setCursor(0, 10);
    display.print("Fan Speed: ");
    display.print(fanSpeed);
    display.display();

    delay(1000); // Update every second
}

This code is responsible for reading the temperature from the DHT11 sensor and adjusting the fan speed accordingly. It also reads the potentiometer to allow manual control over the fan speed. The OLED display shows the current temperature and fan speed. The fan is turned off if the temperature is at or below 25°C. If the temperature is above 25°C, the fan speed is increased proportionally to the temperature and potentiometer value.