Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO-Based Smart Fan Controller with Temperature Sensor and Bluetooth Connectivity

Image of Arduino UNO-Based Smart Fan Controller with Temperature Sensor and Bluetooth Connectivity

Circuit Documentation

Summary

This circuit is designed to monitor temperature using a DHT11 sensor and control a fan based on the temperature readings. The system includes an Arduino UNO microcontroller, a 5V relay, an LCM1602 IIC LCD display, a DHT11 temperature and humidity sensor, an HC-05 Bluetooth module, and a fan. The Arduino UNO reads the temperature from the DHT11 sensor and displays it on the LCD. If the temperature exceeds a predefined threshold, the Arduino activates the relay to turn on the fan. The HC-05 Bluetooth module allows for wireless communication.

Component List

Arduino UNO

  • Description: Microcontroller board based on the ATmega328P.
  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0

5V Relay

  • Description: Electromechanical relay used to control high voltage devices.
  • Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC

LCM1602 IIC

  • Description: 16x2 LCD display with I2C interface.
  • Pins: GND, VCC, SDA, SCL, D6, D7, A, K, VSS, VDD, V0, RS, D2, D3, D4, D5, RW, E, D0, D1, LED_A, LED_B

Fan

  • Description: 5V DC fan.
  • Pins: GND, 5V

DHT11

  • Description: Temperature and humidity sensor.
  • Pins: DATA, GND, VCC

Power 220V

  • Description: 220V AC power source.
  • Pins: hot wire, neutral wire

HC-05 Bluetooth Module

  • Description: Bluetooth module for wireless communication.
  • Pins: Key, VCC, GND, TXD, RXD, State

Wiring Details

Arduino UNO

  • 5V: Connected to VCC of DHT11, LCM1602 IIC, 5V relay, and HC-05 Bluetooth Module.
  • GND: Connected to GND of DHT11, 5V relay, HC-05 Bluetooth Module, and LCM1602 IIC.
  • A4: Connected to SDA of LCM1602 IIC.
  • A5: Connected to SCL of LCM1602 IIC.
  • D3: Connected to In of 5V relay.
  • D2: Connected to DATA of DHT11.
  • D1: Connected to RXD of HC-05 Bluetooth Module.
  • D0: Connected to TXD of HC-05 Bluetooth Module.

5V Relay

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Connected to GND of Arduino UNO.
  • In: Connected to D3 of Arduino UNO.
  • Normally Open: Connected to 5V of Fan.
  • Common terminal: Connected to hot wire of Power 220V.

LCM1602 IIC

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Connected to GND of Arduino UNO.
  • SDA: Connected to A4 of Arduino UNO.
  • SCL: Connected to A5 of Arduino UNO.

Fan

  • 5V: Connected to Normally Open of 5V relay.
  • GND: Connected to neutral wire of Power 220V.

DHT11

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Connected to GND of Arduino UNO.
  • DATA: Connected to D2 of Arduino UNO.

Power 220V

  • hot wire: Connected to Common terminal of 5V relay.
  • neutral wire: Connected to GND of Fan.

HC-05 Bluetooth Module

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Connected to GND of Arduino UNO.
  • RXD: Connected to D1 of Arduino UNO.
  • TXD: Connected to D0 of Arduino UNO.

Code Documentation

#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define DHTPIN 2             // DHT sensor connected to digital pin 2
#define DHTTYPE DHT11        // DHT 11 or DHT 22, depending on your sensor
#define RELAY_PIN 3          // Relay connected to digital pin 3
#define TEMP_THRESHOLD 30    // Temperature threshold in Celsius

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address for 16x2 LCD

void setup() {
  Serial.begin(9600);
  dht.begin();
  lcd.init();
  lcd.backlight();          // Turn on the LCD backlight
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, HIGH);  // Initially turn off the fan
}

void loop() {
  float temperature = dht.readTemperature(); // Read temperature in Celsius
  
  // Check if the reading is valid
  if (isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!");
    lcd.setCursor(0, 0);
    lcd.print("Sensor Error    ");
    delay(2000);
    return;
  }

  // Display temperature on the Serial Monitor and LCD
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");
  
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print(" C ");

  // Fan control based on temperature
  if (temperature >= TEMP_THRESHOLD) {
    digitalWrite(RELAY_PIN, LOW);  // Turn on the fan
    lcd.setCursor(0, 1);
    lcd.print("Fan: ON         ");
  } else {
    digitalWrite(RELAY_PIN, HIGH); // Turn off the fan
    lcd.setCursor(0, 1);
    lcd.print("Fan: OFF        ");
  }

  delay(2000);  // Delay between readings
}

This code initializes the DHT11 sensor and the LCD display, reads the temperature from the DHT11 sensor, and displays it on the LCD. If the temperature exceeds the threshold, the relay is activated to turn on the fan. The system also prints the temperature readings to the Serial Monitor for debugging purposes.