M. Brus
Published © GPL3+

Smart PIR Motion Light Control with WiFIRCard

Automate your lights with PIR motion sensing + WiFIRCard. ESP32-S3 powered, Wi-Fi ready, and dual-relay control in a credit-card size board.

IntermediateFull instructions provided2 hours31
Smart PIR Motion Light Control with WiFIRCard

Things used in this project

Hardware components

WiFIRCard
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Light Bulb with Holder
×1
Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Code

PIR Motion with WiFIRCard code

Arduino
// WiFIRCard with PIR Sensor interfacing and Relay Control
// PIR sensor output -> GPIO43
// Relay module input -> GPIO9

const int PIR_PIN   = 43;   // PIR sensor signal pin
const int RELAY_PIN = 9;    // Relay control pin

void setup() {
  Serial.begin(115200);
  
  pinMode(PIR_PIN, INPUT);       // PIR as input
  pinMode(RELAY_PIN, OUTPUT);    // Relay as output
  digitalWrite(RELAY_PIN, LOW);  // Start with relay OFF
  
  Serial.println("PIR + Relay setup complete.");
}

void loop() {
  int motion = digitalRead(PIR_PIN);

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

  delay(200); // Small delay to avoid rapid toggling
}

Credits

M. Brus
1 project • 0 followers
Maker at heart, educator by choice—simplifying electronics for everyone.

Comments