Relay Module

Z2M Part: EMA-00008-A

Control relay with PIR motion sensor trigger.

Circuit Diagram
Circuit diagram for Relay Module
Wire Connections & Pin Configuration

Wire Color Connections:

Yellow → Pin 12 to Relay IN, Pin 3 to PIR OUT
Red → 5V to Relay VCC, PIR VCC
Black → GND to Relay GND, PIR GND

Pin Configuration:

COMPLETE PIN CONFIGURATION:

Arduino → Relay Module (Keyes SRD-05VDC-SL-C):
Arduino Digital Pin 12 → Relay IN (control)
Arduino 5V → Relay VCC
Arduino GND → Relay GND

Arduino → PIR Sensor:
Arduino Digital Pin 3 → PIR OUT (signal)
Arduino 5V → PIR VCC
Arduino GND → PIR GND

Relay Output (connect load):
COM → Common terminal
NO → Normally Open (closes when relay ON)
NC → Normally Closed (opens when relay ON)
Arduino Code
Edit
#define relay 12  // Relay IN pin connected to pin 12
#define pir 3     // PIR sensor OUT connected to pin 3

void setup() {
  pinMode(relay, OUTPUT);  // Set relay pin as output
  pinMode(pir, INPUT);     // Set PIR sensor pin as input

  digitalWrite(relay, LOW); // Initialize relay in OFF (Normally Open) state
  Serial.begin(9600);
  Serial.println(\"Relay Module Initialized. Waiting for motion...\");
}

void loop() {
  int pir_value = digitalRead(pir); // Read PIR sensor value

  if (pir_value == HIGH) {          // Motion detected
    digitalWrite(relay, HIGH);      // Turn ON relay
    Serial.println(\"Motion detected - Relay ON\");
  }
  else {                            // No motion detected
    digitalWrite(relay, LOW);       // Turn OFF relay
    Serial.println(\"No motion - Relay OFF\");
  }

  delay(200); // Small delay for stability
}

Instruction Details

Wiring: Connect relay IN to Digital Pin 12, VCC to 5V, GND to GND. Connect PIR OUT to Digital Pin 3, VCC to 5V, GND to GND. Connect load to relay COM and NO/NC terminals.
Library: Not required (built-in).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Relay turns ON when PIR detects motion. Open Serial Monitor for status. Use COM/NO/NC for loads. Caution with AC power.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • 5V Relay Module
  • PIR Motion Sensor Module
  • Breadboard
  • Jumper Wires
  • Load (LED, bulb, etc. for relay output)

Category: Motors & Servos