Smart Fan Project using PIR Motion Sensor (DC Motor)

This project will allow you to control a small DC motor (representing the fan) based on motion detected by a PIR sensor. When the sensor detects motion, the motor will turn on, and when no motion is detected, the motor will turn off.

Components Needed:

  1. PIR Motion Sensor
  2. DC Motor
  3. Arduino (e.g., Arduino Uno)
  4. Relay Module (Optional: but necessary for higher current motor control)
  5. External Power Supply (for motor if necessary)
  6. Jumper Wires
  7. Breadboard

Step 1: Circuit Connection

Since you will not be using diodes and transistors, we’ll use a simple relay module to switch the DC motor on and off, driven by the Arduino. The relay module will handle the higher current needed by the DC motor, while the Arduino will only control the relay.

Circuit Setup Description:

  1. PIR Motion Sensor:
    • VCC to 5V pin on Arduino.
    • GND to GND on Arduino.
    • OUT to a digital input pin (e.g., pin 2 on Arduino).
  2. Relay Module:
    • VCC to 5V pin on Arduino.
    • GND to GND on Arduino.
    • IN (control pin) to a digital output pin on Arduino (e.g., pin 8).
    • COM (Common) to the positive terminal of the DC motor.
    • NO (Normally Open) to the positive terminal of the external power supply (5V or 9V, depending on your motor’s voltage).
    • The negative terminal of the DC motor goes to the negative terminal of the external power supply.
  3. DC Motor:
    • The motor is controlled via the relay (switching the motor on/off).

Step 2: Arduino Code

Here is a simple Arduino code to achieve the desired functionality:

// Pin Definitions
int pirPin = 2; // PIR sensor input pin
int relayPin = 8; // Relay control pin

void setup() {
  // Set up pins
  pinMode(pirPin, INPUT);  // PIR sensor as input
  pinMode(relayPin, OUTPUT);  // Relay as output
  
  // Initialize the relay state to OFF
  digitalWrite(relayPin, LOW);  
}

void loop() {
  // Read the PIR sensor
  int pirState = digitalRead(pirPin);
  
  if (pirState == HIGH) { // Motion detected
    digitalWrite(relayPin, HIGH); // Turn on the motor
  } else { // No motion detected
    digitalWrite(relayPin, LOW); // Turn off the motor
  }
  
  delay(100); // Small delay to stabilize the sensor readings
}

Step 3: Working Explanation

  • PIR Sensor: The PIR motion sensor detects motion by sensing infrared radiation (body heat). When motion is detected, the sensor sends a HIGH signal to the Arduino.
  • Arduino: The Arduino reads the input from the PIR sensor and turns the relay on (HIGH) when motion is detected. It then turns the relay off (LOW) when no motion is detected.
  • Relay Module: The relay module acts as a switch for the DC motor. When the Arduino signals the relay to close the circuit, the motor turns on. When the relay is open, the motor is turned off.

Step 4: Powering the Circuit

  1. Arduino: Powered via USB or external 5V supply.
  2. DC Motor: If the motor requires more current than the Arduino can supply, use an external power source to drive the motor. Ensure the relay’s voltage rating matches the motor’s operating voltage (e.g., 5V or 9V).
  3. PIR Sensor: Powered by the 5V output of the Arduino.

Step 5: Testing

  1. Upload the Code: Upload the provided Arduino code to the Arduino.
  2. Place the PIR Sensor: Place the PIR sensor in a location where it can detect motion (for example, near a doorway).
  3. Test the Motor: Move in front of the sensor and see if the motor turns on. When no motion is detected, the motor should stop.

Notes:

  • Relay: If you are using a higher voltage or higher current motor, you need to ensure the relay you choose can handle that power. For a small DC motor, a 5V relay module should work fine.
  • Arduino Power Supply: If the motor consumes a lot of power, ensure that the Arduino’s power supply is not overloaded. You can use a separate power source for the motor if needed.
  • Sensor Sensitivity: You can adjust the sensitivity of the PIR sensor by turning the potentiometer on the sensor module to adjust the detection range.

Conclusion

With this setup, you now have a basic smart fan that automatically turns on when motion is detected and turns off when no motion is present. This simple project demonstrates the integration of a PIR sensor, relay, and Arduino to control a DC motor.