PIR Sensor for Solar Pathway Lighting

Project Overview

This project creates solar-powered pathway lights that automatically turn on when someone walks by. The system uses a PIR sensor to detect motion and turns on LED strips for a set duration. Solar charging keeps the battery topped up during the day.

Difficulty: Intermediate
Estimated time: 2-3 hours
Estimated cost: $30-45

How It Works

A solar panel charges a lithium battery during the day. A PIR sensor mounted on the pathway detects approaching pedestrians. When motion is detected, the system turns on LED lights for 30-60 seconds. A light sensor can be added to ensure lights only activate at night.

Materials Needed

  • ESP32 or ATtiny85 (1)
  • HC-SR501 PIR sensor (1)
  • Solar panel (5V, 5-10W)
  • 18650 lithium battery (1-2)
  • TP4056 charging module
  • Boost converter to 5V
  • LED strip (12V or 5V)
  • MOSFET or relay for switching
  • LDR photoresistor optional
  • Waterproof enclosure

Circuit Diagram

Power Section

Solar Panel (+) --- TP4056 IN+ --- 18650 Battery (+)
Solar Panel (-) --- TP4056 IN- --- 18650 Battery (-)
Battery (+) --- Boost Converter (3.7V → 5V) --- ESP32 VIN

Arduino Code (ATtiny85 – Ultra Low Power)

// Solar Pathway Lighting with ATtiny85
#include <avr/sleep.h>

const int pirPin = 0;
const int ledPin = 1;
const int ldrPin = 2;

unsigned long lastTrigger = 0;
const unsigned long lightDuration = 30000;

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(ldrPin, INPUT);
  digitalWrite(ledPin, LOW);
  delay(30000);
}

bool isDark() {
  return analogRead(ldrPin) < 500;
}

void goToSleep() {
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_enable();
  sleep_cpu();
  sleep_disable();
}

void loop() {
  bool motion = digitalRead(pirPin) == HIGH;
  bool dark = isDark();
  
  if (motion && dark) {
    digitalWrite(ledPin, HIGH);
    lastTrigger = millis();
  }
  
  if (digitalRead(ledPin) == HIGH && (millis() - lastTrigger > lightDuration)) {
    digitalWrite(ledPin, LOW);
  }
  
  if (!motion && !digitalRead(ledPin)) {
    attachInterrupt(0, wakeUp, RISING);
    goToSleep();
    detachInterrupt(0);
  }
  
  delay(100);
}

void wakeUp() {}

Installation Steps

  1. Assemble power system with solar panel and battery
  2. Test charging in sun to verify voltage increases
  3. Mount PIR sensor at 1m height along pathway
  4. Install LED strips along pathway edges
  5. Enclose electronics in waterproof enclosure with solar panel on top
  6. Walk along pathway at night to test lights

Project Extensions

  • Use RGB LEDs that change color based on battery level
  • Add second PIR for direction detection
  • Add LoRa to report battery level and events
  • Connect to Home Assistant via MQTT
  • Add microphone for sound-reactive lighting

Conclusion

These solar-powered pathway lights add safety and beauty to your walkway without increasing your electric bill.

Leave a Reply

Your email address will not be published. Required fields are marked *