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

Arduino UNO-Based Automatic Light Control with PIR Sensor and Relay

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Automatic Light Control with PIR Sensor and Relay

Circuit Documentation

Summary

This circuit is designed to control an automatic light using a PIR motion sensor and a relay. When the PIR sensor detects motion, the relay activates to turn on an AC bulb. The circuit also includes a GPS module, a GSM module, a current sensor, a piezo speaker, and a solar charge controller for power management. The Arduino UNO microcontroller is used to control the entire system.

Component List

  1. PIR/Motion Sensor

    • Pins: GND, OUTPUT, VCC
    • Description: Detects motion and outputs a signal when motion is detected.
  2. AC Bulb

    • Pins: P, N
    • Description: Standard AC bulb controlled by the relay.
  3. Arduino UNO

    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
    • Description: Microcontroller used to control the circuit.
  4. Piezo Speaker

    • Pins: pin1, pin2
    • Description: Emits sound when activated.
  5. Solar Charge Controller

    • Pins: Solar Cell +, Solar Cell -, Battery +, Battery -, Load +, Load -
    • Description: Manages the charging of the battery from the solar panel.
  6. 5V Relay

    • Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
    • Description: Controls the AC bulb based on the signal from the Arduino.
  7. MB102 Breadboard Power Supply Module 3.3V/5V

    • Pins: GND, 3.3V, 5V
    • Description: Provides regulated 3.3V and 5V power supply.
  8. LM2596

    • Pins: IN, OUT
    • Description: DC-DC buck converter used to step down voltage.
  9. INA219

    • Pins: VCC, GND, SCL, SDA, VIN -, VIN +
    • Description: Current sensor used to measure current and voltage.
  10. 12V 200Ah Battery

    • Pins: GND, 12V
    • Description: Provides power to the circuit.
  11. Solar Panel

    • Pins: gnd, vcc
    • Description: Generates power from sunlight.
  12. Sim800l

    • Pins: NET, RST, VCC, RXD, TXD, GND
    • Description: GSM module used for communication.
  13. Ublox NEO-M8N GPS module

    • Pins: RF coaxial cable connectors, VCC, RX, TX, GND
    • Description: GPS module used for location tracking.

Wiring Details

PIR/Motion Sensor

AC Bulb

Arduino UNO

Piezo Speaker

Solar Charge Controller

5V Relay

LM2596

INA219

12V 200Ah Battery

Solar Panel

Sim800l

Ublox NEO-M8N GPS module

Code Documentation

/*
 * Proyecto: Luz Automática con Sensor PIR y Relé
 * Descripción: Este código controla una luz automática utilizando un sensor PIR
 * y un relé. Cada vez que el sensor PIR detecta movimiento, el relé se activa
 * para encender una bombilla. Además, el código cuenta el número de veces que
 * se detecta una persona y lo imprime en el monitor serie.
 */

// Definición de pines
const int pirPin = 3; // Pin de salida del sensor PIR
const int relayPin = 4; // Pin de entrada del relé

// Variables
int motionDetected = 0; // Contador de detecciones de movimiento

void setup() {
  // Configuración de pines
  pinMode(pirPin, INPUT);
  pinMode(relayPin, OUTPUT);
  // Inicialización del monitor serie
  Serial.begin(9600);
  // Inicialización del relé en estado apagado
  digitalWrite(relayPin, LOW);
}

void loop() {
  // Lectura del estado del sensor PIR
  int pirState = digitalRead(pirPin);
  if (pirState == HIGH) {
    // Si se detecta movimiento
    digitalWrite(relayPin, HIGH); // Encender la luz
    motionDetected++; // Incrementar el contador
    Serial.print("Movimiento detectado: ");
    Serial.println(motionDetected);
    delay(5000); // Mantener la luz encendida por 5 segundos
  } else {
    // Si no se detecta movimiento
    digitalWrite(relayPin, LOW); // Apagar la luz
  }
  delay(100); // Pequeña espera para evitar rebotes
}

This code controls an automatic light using a PIR sensor and a relay. When motion is detected, the relay is activated to turn on the light, and the number of detections is printed to the serial monitor.