Project Overview
This project creates a driveway alert system that detects vehicles or people approaching your property and sends a notification to a receiver inside your home. It’s perfect for long driveways, rural properties, or anywhere you want to know when someone arrives.
Difficulty: Intermediate
Estimated time: 2-3 hours
Estimated cost: $40-60
How It Works
A weatherproof PIR sensor is placed at the driveway entrance. When a vehicle or person passes by, it sends a wireless signal to a receiver unit inside the house. The receiver can play a chime, flash an LED, or send a notification to your phone. For long driveways (up to 100m), LoRa or ESP-NOW is used; for shorter distances, 433MHz RF modules work well.
Materials Needed
- ESP32 or Arduino (2) – one for transmitter, one for receiver
- HC-SR501 PIR sensor (1) – outdoor version or weatherproof enclosure
- LoRa modules (RAK811, Heltec) or NRF24L01 for wireless communication
- Buzzer or speaker (for audible alert)
- LEDs (for visual alert)
- Battery pack (for remote transmitter)
- Solar panel and charger (optional, for long-term deployment)
- Weatherproof enclosure (for transmitter)
- Jumper wires
System Architecture
[Driveway Sensor] ---Wireless (LoRa/NRF24L01)---> [House Receiver]
| |
PIR Sensor Buzzer/LED
Battery/Solar Display
Circuit Diagram
Transmitter Unit
| Component |
Pin |
Arduino Pin |
PIR Sensor |
VCC
| 5V
| PIR Sensor |
GND
| GND
| PIR Sensor |
OUT
| Digital Pin 2
| LoRa/NRF24L01 |
VCC
| 3.3V
| LoRa/NRF24L01 |
GND
| GND
| LoRa/NRF24L01 |
CS/CE
等方面Digital Pins
|
表
Transmitter Code (ESP32 with LoRa)
// Driveway Alert Transmitter
#include <SPI.h>
#include <LoRa.h>
const int pirPin = 2;
const int csPin = 5;
const int rstPin = 14;
const int dio0Pin = 2;
unsigned long lastSendTime = 0;
const unsigned long sendCooldown = 30000; // 30 seconds between alerts
void setup() {
Serial.begin(115200);
pinMode(pirPin, INPUT);
LoRa.setPins(csPin, rstPin, dio0Pin);
if (!LoRa.begin(915E6)) { // Use 868E6 for Europe, 915E6 for US
Serial.println("LoRa init failed");
while (1);
}
Serial.println("Driveway Transmitter Ready");
delay(60000); // PIR warm-up
}
void sendAlert() {
LoRa.beginPacket();
LoRa.print("MOTION");
LoRa.print(",");
LoRa.print(millis());
LoRa.endPacket();
Serial.println("Alert sent");
}
void loop() {
bool motion = digitalRead(pirPin) == HIGH;
if (motion && (millis() - lastSendTime > sendCooldown)) {
lastSendTime = millis();
sendAlert();
delay(2000); // Wait for transmission
}
delay(100);
}
Receiver Code (ESP32 with LoRa and Display)
// Driveway Alert Receiver
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int csPin = 5;
const int rstPin = 14;
const int dio0Pin = 2;
const int buzzerPin = 4;
const int ledPin = 13;
int alertCount = 0;
unsigned long lastAlertTime = 0;
const unsigned long alertDuration = 5000; // 5 seconds
void setup() {
Serial.begin(115200);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Driveway Monitor");
lcd.setCursor(0, 1);
lcd.print("Ready");
LoRa.setPins(csPin, rstPin, dio0Pin);
if (!LoRa.begin(915E6)) {
lcd.clear();
lcd.print("LoRa init failed");
while (1);
}
Serial.println("Receiver Ready");
}
void triggerAlert() {
alertCount++;
lastAlertTime = millis();
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 2000, 500);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Vehicle detected!");
lcd.setCursor(0, 1);
lcd.print("Count: ");
lcd.print(alertCount);
Serial.printf("Alert #%d\n", alertCount);
}
void loop() {
int packetSize = LoRa.parsePacket();
if (packetSize) {
String message = "";
while (LoRa.available()) {
message += (char)LoRa.read();
}
if (message.startsWith("MOTION")) {
triggerAlert();
}
}
if (millis() - lastAlertTime > alertDuration && digitalRead(ledPin) == HIGH) {
digitalWrite(ledPin, LOW);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("System Ready");
lcd.setCursor(0, 1);
lcd.print("Total alerts: ");
lcd.print(alertCount);
}
delay(100);
}
Alternative: NRF24L01 Version (Shorter Range)
For shorter driveways (up to 100m), use NRF24L01 modules:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
}
void sendAlert() {
const char text[] = "MOTION";
radio.write(&text, sizeof(text));
}
Solar Power for Transmitter
For remote driveway sensors, add solar charging:
- 5V solar panel (5-10W)
- TP4056 charging module
- 18650 lithium battery (2000-3000mAh)
- Boost converter to 5V (if needed)
Installation Steps
- Assemble transmitter: Place PIR sensor and ESP32 in weatherproof enclosure.
- Position sensor: Mount at driveway entrance, 1.5-2m high, angled to detect vehicles.
- Test range: Verify wireless communication between transmitter and receiver.
- Assemble receiver: Place receiver unit inside house with buzzer/LED visible.
- Power up: Connect batteries or solar panel to transmitter.
- Final test: Drive vehicle up driveway, verify alert.
Project Extensions
- Vehicle vs. person detection: Use dual sensors to distinguish between vehicles and pedestrians.
- Direction detection: Add second sensor to detect arrival vs. departure.
- Camera integration: Add ESP32-CAM to capture images when motion detected.
- SMS alerts: Add GSM module to send text messages.
- Gate control: Add relay to automatically open gate when vehicle approaches.
Troubleshooting
- No signal: Check antenna connection. Reduce distance. Try different channel.
- False alerts: Adjust PIR sensitivity. Avoid facing road traffic. Add cooldown timer.
- Battery drains quickly: Use deep sleep mode. Reduce transmit frequency.
- Receiver not responding: Check power supply. Verify LoRa initialization.
Conclusion
This driveway alert system provides early warning of visitors, packages, or intruders. With wireless communication, it’s easy to install even on long driveways.