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

Arduino-Controlled HVAC Automation System with Bluetooth and Real-Time Clock

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled HVAC Automation System with Bluetooth and Real-Time Clock

Circuit Documentation

Summary

This circuit is designed to control an HVAC system using an Arduino UNO microcontroller. The system interfaces with various components such as a 5V 8-channel relay module, an AM2302 humidity and temperature sensor, a DS3231 Real-Time Clock (RTC), and a Bluetooth HC-06 module for wireless communication. The relay module controls five AC-powered devices, including a heater, an air conditioner (AC), a fan, a light, and a humidifier. The AM2302 sensor provides environmental feedback, which is used by the Arduino to make decisions about activating or deactivating the connected devices based on temperature and humidity levels. The RTC module is used to maintain accurate time, which can be useful for time-based control scenarios. The Bluetooth module allows for remote communication with the system.

Component List

Arduino UNO

5V 8-Channel Relay

AM2302 Humidity and Temperature Sensor

Heater

AC (Air Conditioner)

Fan

Light

Humidifier

120V Outlet (x5)

Bluetooth HC-06

RTC DS3231

DC Source 5V

Wiring Details

Arduino UNO

5V 8-Channel Relay

AM2302 Humidity and Temperature Sensor

Heater, AC, Fan, Light, Humidifier

120V Outlet

Bluetooth HC-06

RTC DS3231

DC Source 5V

Documented Code

/*
 * This Arduino Sketch controls an HVAC system using relays and sensors.
 * The system powers on/off HVAC components based on temperature and humidity.
 * Components:
 * - 5 AC devices connected to relay channels
 * - AM2302 sensor for temperature and humidity
 * - RTC DS3231 for real-time clock
 * - Bluetooth HC-06 for communication
 */

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

#define DHTPIN 9          // Define the pin connected to the AM2302 data pin
#define DHTTYPE DHT22     // Specify the type of DHT sensor

DHT dht(DHTPIN, DHTTYPE); // Initialize the sensor
RTC_DS3231 rtc;            // Initialize the RTC

// Array to hold the relay control pins
const int relayPins[] = {11, 2, 3, 4, 5, 6, 7, 8};

void setup() {
  Serial.begin(9600);      // Start serial communication at 9600 baud rate
  dht.begin();             // Start the DHT sensor
  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC"); // Check if RTC is connected
    while (1);
  }
  if (rtc.lostPower()) {
    // Check if the RTC lost power and if so, set the time
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  for (int i = 0; i < 8; i++) {
    pinMode(relayPins[i], OUTPUT);       // Set relay pins as outputs
    digitalWrite(relayPins[i], HIGH);    // Initialize relays to off (active low)
  }
}

void loop() {
  float humidity = dht.readHumidity();    // Read humidity
  float temperature = dht.readTemperature(); // Read temperature
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!"); // Check for sensor reading errors
    return;
  }
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" *C");

  // Example control logic based on temperature and humidity
  if (temperature > 25) {
    digitalWrite(relayPins[0], LOW); // Turn on AC if temperature is above 25 degrees Celsius
  } else {
    digitalWrite(relayPins[0], HIGH); // Turn off AC otherwise
  }
  if (humidity < 40) {
    digitalWrite(relayPins[1], LOW); // Turn on Humidifier if humidity is below 40%
  } else {
    digitalWrite(relayPins[1], HIGH); // Turn off Humidifier otherwise
  }
  // Additional control logic can be added here

  delay(2000); // Wait for 2 seconds before the next loop iteration
}

This code is responsible for reading temperature and humidity data from the AM2302 sensor and controlling the AC and humidifier via the relay module based on the readings. It also initializes the RTC and sets up serial communication for debugging purposes. The relays are controlled using an array of pins, and the relays are set to an initial state of HIGH (off) since they are active low. The control logic within the loop function can be expanded to include additional functionality as needed.