กลับไปหน้ารวมไฟล์
ultrasonic-home-security-system-cameran-a127cf-en.md

My Home Security System aka Cameran is a simple and reliable security system. Cameran uses an Ultrasonic Distance Sensor to detect how far away someone is from your doorway.

If someone is 100 feet away, the system activates, and a green LED light comes on. If the trespasser comes closer than 75 feet, a warning is signaled in the form of a yellow LED light. This should discourage a trespasser from coming closer. If the trespasser comes closer than 25 feet at the door, a buzzer goes off and a red LED light comes on. If it is a family member or an authorized person, they can enter a valid 4-digit passcode to silence the alarm. If the passcode is incorrect, the buzzer will continue to sound the alarm and a red LED light begins to flash to indicate that there is a potential intruder.

For the sake of this prototype, I have designed the system

  • to activate with a green LED when movement is detected between 75 cm & 100 cm.
  • to show a warning yellow LED when movement is detected between 25 cm & 75 cm.
  • to show the red LED with the sounding buzzer when movement is sensed at less than 25 cm.

Perimeter Breach Detection: Ultrasonic Sonar Security

Relying purely on mechanical magnetic door switches allows intruders to shatter windows effortlessly without triggering an alarm. The Ultrasonic Home Security System fundamentally alters defensive architecture by establishing an invisible acoustic volumetric radar! The Arduino continuously pulses 40,000 Hertz sound waves into the room. It mathematically calculates the absolute empty volume of the hallway. The exact nanosecond a human physically enters the zone, the bouncing soundwaves crash back into the microphone exponentially faster. The processor detects this latency anomaly and violently initiates a terrifying multi-tone siren matrix to disorient the attacker immediately!

Demystifying The Acoustic Radar (pulseIn)

The HC-SR04 cannot just act as a simple HIGH/LOW pin; it requires severe timing orchestration natively.

  1. The Trig Pin demands a 10-microsecond aggressive HIGH pulse to physically command the speaker module to fire its 8-cycle sonic burst.
  2. The Arduino must aggressively halt using pulseIn() to wait for the returning echo.
  3. Because the speed of sound is 343m/s, dividing the microsecond duration by 58.2 yields the exact absolute distance in centimeters!
#define TRIG_PIN 9
#define ECHO_PIN 10
#define SIREN_PIN 8

int baselineDistance = 0; // The calibrated empty room!

void setup() {
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  
  // Power up and calculate the room's normal state!
  baselineDistance = measureDistance(); 
}

void loop() {
  int currentDistance = measureDistance();
  
  // If the distance drops massively (e.g., someone walked in front of it!)
  if (currentDistance < (baselineDistance - 15)) { 
    // INTRUDER CONFIRMED! BLAST SIREN!
    tone(SIREN_PIN, 2000); 
    delay(200);
    tone(SIREN_PIN, 1000);
    delay(200);
  }
}

Creating Dynamic Calibration Architecture

A naive script hardcodes if (distance < 100). If you later move the sensor to a smaller hallway, it will constantly alarm false-positives!

  • Absolute dynamic calibration is crucial!
  • In setup(), the Arduino natively runs a loop 10 times, taking distance readings of the empty room, averaging them, and storing it as baselineDistance.
  • This ensures that if the homeowner moves the device, the system physically teaches itself the dimensions of the new environment autonomously upon every single boot!

Defensive Infrastructure Loadout

  • Arduino Uno/Nano (Handling the precise internal microsecond acoustic timers flawlessly).
  • HC-SR04 Ultrasonic Distance Sensor (Ensure the acoustic metallic meshes are completely unobstructed; placing this behind glass entirely destroys the sensor as sound cannot pass through it!).
  • High-Decibel Active Piezo Buzzer or a 5V Relay Module attached to an authentic 120dB 12V Home Security House Siren.
  • Hidden Arming/Disarming Keystroke Matrix (To allow the homeowner to bypass the acoustic field securely without triggering the alarm themselves!).

When working on this project I came across an issue of shorting when I connected the 5V pin to the ground. If you see this issue as well, check out my post about how to resolve it here: https://theridgeguy.com/arduino-5v-shorting-problem/

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
author: "theridgeguy"
category: "Security & Monitoring"
components:
  - "1x Breadboard (generic)"
  - "4x Resistor 10k ohm"
  - "2x 5 mm LED: Red"
  - "1x Buzzer"
  - "1x Ultrasonic Sensor - HC-SR04 (Generic)"
  - "1x Arduino UNO"
  - "6x Resistor 220 ohm"
  - "1x 5 mm LED: Yellow"
  - "4x Tactile Switch, Top Actuated"
  - "1x USB-A to B Cable"
  - "1x Jumper wires (generic)"
  - "2x 5 mm LED: Green"
description: "Acoustic spatial triangulation! Deploy massive HC-SR04 sonar arrays executing microsecond ping vectors to establish an invisible impenetrable hardware security perimeter natively attached to high-decibel piezo siren architectures."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles:
  - "https://projects.arduinocontent.cc/0f82637e-eac8-4d25-ad8a-44299f2885d4.ino"
encryptedPayload: "U2FsdGVkX1+dPkPVNLwpqfdF22urqHafD3iswcm3CWmFPNoyd9bsfCC/YLR1oKaB5Spc0m/2jHKdW+cBt/3lESLnA/QAVbaPuuso4Kyshds="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/ultrasonic-home-security-system-cameran-a127cf_cover.jpg"
lang: "en"
likes: 1
passwordHash: "c370a576fd9d79f1346f70b85eb9d36c7f91f347c91276322edf36e2edbbd3d0"
price: 299
seoDescription: "Build a DIY Ultrasonic Home Security System. Use an Ultrasonic sensor to trigger an Alarm and a Passcode to deactivate it."
tags:
  - "home automation"
  - "security"
  - "monitoring"
title: "Ultrasonic Home Security System (Cameran)"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/o1Gup36sC6U"
views: 11988