Blog

DIY Automatic Room Ventilation System with Arduino

0
DIY Automatic Room Ventilation System with Arduino

The given project was carried out to address a simple yet prevalent indoor issue: poor air circulation due to high temperature and humidity. Ventilation fans in most rooms, particularly in bedrooms, offices, or small laboratories, are usually manually operated. In practice, people often fail to switch them on or off, which results in discomfort and energy loss.

The concept here was to create an automatic room ventilation system that responds to actual environmental conditions. The system continuously monitors temperature and humidity and automatically switches on the ventilation fan. Arduino was chosen because it provides rapid prototyping and reliable sensor integration.

This was not just a demo build. The system was constructed, tested in a real room, tweaked, and then run for extended periods. The following discussion reflects these experimental tests and developments.

Design Thinking and System Concept

The problem was divided into smaller sub-problems before hardware wiring or coding began.

The system needed to:

  • Take accurate temperature and humidity readings.
  • Determine when ventilation is needed.
  • Turn on a high-power fan safely.
  • Avoid frequent switching on and off.

A decision was made to use a simple rule-based control strategy instead of complex algorithms. Precision control is less important than achieving stable ventilation.

The final architecture consisted of:

  • Arduino Uno as the central controller.
  • Temperature and humidity sensor (DHT11).
  • Relay module to isolate low-voltage control from high-voltage load.
  • Ventilation fan as the output device.
  • Keeping sensing, control switching, and power switching independent makes the system safer and easier to debug.

Components Used

The components used in the project were as follows:

  • Arduino Uno
  • DHT11 temperature-humidity sensor module
  • 5V single-channel relay module
  • AC fan controlled via a relay
  • Breadboard and jumper wires
  • External power supply (used when required by the fan)

The components are all cheap and easily accessible, making this project easy to replicate.

Hardware Connections (Step-by-Step)

The hardware configuration was kept very simple to minimize wiring errors.

DHT11 Sensor Connection:

  • VCC – Arduino 5V
  • GND – Arduino GND
  • DATA – Arduino digital pin 2

A pull-up resistor was already present in the DHT11 module, so no additional parts were needed.

Relay Module Connection:

  • VCC – Arduino 5V
  • GND – Arduino GND
  • IN – Arduino digital pin 8

The live wire of the fan was connected via the Normally Open (NO) terminal of the relay to ensure that the fan remains off at system startup.

⚠️ Safety precaution: AC wiring was done with care and tested separately before being connected to the Arduino-controlled relay.

Control Logic Overview

The control logic follows a simple flow:

  • Read temperature and humidity.
  • Compare the values against preset thresholds.
  • Switch on the fan when limits are surpassed.
  • Switch off the fan when the readings return to normal.
  • Wait before taking the next reading.

This logic proved dependable during long-term testing and did not require unnecessary relay switching.

Arduino Code (Tested and Working)

				
					#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11
#define RELAY_PIN 8

float tempThreshold = 30.0;
float humidityThreshold = 70.0;

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);

  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, HIGH); // Relay OFF (active-LOW)

  dht.begin();
  Serial.println("Automatic Ventilation System Started");
}

void loop() {
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Sensor reading failed");
    delay(2000);
    return;
  }

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print(" °C | Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");

  if (temperature > tempThreshold || humidity > humidityThreshold) {
    digitalWrite(RELAY_PIN, LOW);  // Fan ON
    Serial.println("Fan: ON");
  } else {
    digitalWrite(RELAY_PIN, HIGH); // Fan OFF
    Serial.println("Fan: OFF");
  }

  Serial.println("----------------------");
  delay(3000);
}
				
			

Key Implementation Details

A few minor choices made a tremendous difference in actual application.

The threshold values were initially chosen based on testing. Lower temperatures caused the fan to switch on and off too frequently, so the final value was adjusted to 30 °C.

Second, extensive serial monitoring was conducted during testing. Live monitoring helped confirm the accuracy of the sensor readings and overall system behavior.

Third, care was taken to verify relay behavior. Many relay modules are active-low, which can be confusing for beginners unless tested early.

Practical Challenges Faced

One of the main challenges was the slow response of the DHT11 sensor. Frequent readings led to duplicated values, which was addressed by introducing longer delays between readings.

Short humidity bursts, such as opening doors or cooking nearby, were another challenge. This was mitigated by using delays and stable threshold values.

Initially, there was noticeable relay clicking noise. Reducing the switching frequency not only decreased the noise but also improved the lifespan of the relays.

Lessons Learned

This project demonstrated that simple systems are most effective for basic automation. Complicated logic did not improve performance.

It is important to understand the limitations of sensors. The DHT11 is suitable for simple monitoring tasks but not for fast or precise control.

Above all, electrical safety must not be disregarded when handling relays and AC loads.

The next stage of this project may include:

  • Replace the DHT11 with a DHT22 sensor
  • Add an LCD or OLED display
  • Enable remote monitoring using an ESP32
  • Apply hysteresis for smoother control

Final Thoughts

This automatic room ventilation system demonstrates how Arduino can use simple logic and hardware to solve real-world problems. Testing, adjustments, and hands-on use helped the project evolve from an idea into a fully functional system.

For beginners, it offers a complete learning experience. For more experienced users, it serves as a reminder that good engineering sometimes lies in keeping things simple, stable, and safe.

For those interested in taking projects from prototype to production, whether as a hobbyist or a business, PCBCool offers flexible PCB and PCBA services. From rapid prototyping to small-batch or full-scale manufacturing, our solutions make it easy to turn ideas into real, working electronics.

Frequently Asked Questions (FAQ)

1. Can I use DHT11, or should I use DHT22?

DHT11 is cheap and easy to obtain, ideal for beginners and simple monitoring. DHT22 has faster response and higher accuracy, suitable for precise control applications.

2. Can I use a regular household fan?

Yes, but AC fans must be controlled through a relay to isolate high-voltage circuits.

3. Will frequent relay switching damage the relay?

Frequent switching increases wear and reduces relay lifespan. Adding sampling delays, stable thresholds, or hysteresis can reduce the number of switch cycles.

4. Can the system run continuously for long periods?

Yes, long-term testing showed stable operation.

5. Can I add remote monitoring or a display?

Absolutely. You can add an LCD or OLED for local monitoring, or integrate an ESP32/Wi-Fi module for remote control and monitoring.

6. Can Arduino be replaced with another microcontroller?

Yes. Raspberry Pi, ESP32, or STM32 can be used, but the code and wiring need adjustments.

7. What is the approximate cost of this project?

Using Arduino + DHT11 + relay + small fan, the materials cost is typically $15–$30 (excluding PCB/enclosure), depending on component choice.

8. Can I turn this prototype into a PCB or small-batch production?

Yes! This is where PCBCool comes in. You can quickly create PCB prototypes or small-batch PCBA, turning your experimental project into a reliable, working product.

Farhan A
Farhan A. | Electronics and Embedded Systems Engineer

Farhan A. is an electronic engineer specializing in PCB design, drones, robotics, embedded systems, and AI-based hardware development. His experience in C/C++, Python, AI/ML, and testing helps him develop practical solutions for complex electronics projects.

Related Tags