{"id":4126,"date":"2026-04-30T09:00:00","date_gmt":"2026-04-30T09:00:00","guid":{"rendered":"https:\/\/pirhome.com\/?p=3911"},"modified":"2026-04-30T09:00:00","modified_gmt":"2026-04-30T09:00:00","slug":"pir-garage-door-automation","status":"publish","type":"post","link":"https:\/\/www.pirhome.com\/?p=4126","title":{"rendered":"PIR Sensor for Garage Door Automation: Vehicle Detection"},"content":{"rendered":"<h2>Project Overview<\/h2>\n<p>This project creates a hands-free garage door opener that detects when your car approaches and automatically opens the door. Using a PIR sensor mounted near the driveway, the system detects your vehicle&#8217;s heat signature and triggers a relay that simulates pressing the garage door opener button.<\/p>\n<p><strong>Difficulty:<\/strong> Intermediate<br \/>\n<strong>Estimated time:<\/strong> 2-3 hours<br \/>\n<strong>Estimated cost:<\/strong> $25-35<\/p>\n<h2>How It Works<\/h2>\n<p>A PIR sensor placed at the driveway entrance detects the heat signature of your approaching car. When a vehicle is detected (after a short delay), the system activates a relay that connects across the garage door opener&#8217;s wall button terminals, simulating a button press. An optional reed switch on the garage door can detect whether the door is already open.<\/p>\n<h2>Materials Needed<\/h2>\n<ul>\n<li>ESP32 or Arduino Uno (1)<\/li>\n<li>HC-SR501 PIR sensor (1) or AM312 for lower power<\/li>\n<li>Relay module (5V, single channel)<\/li>\n<li>Reed switch (normally open) for door position detection (optional)<\/li>\n<li>Magnet for reed switch<\/li>\n<li>12V to 5V converter (if using 12V garage door supply)<\/li>\n<li>Waterproof enclosure (for outdoor PIR sensor)<\/li>\n<li>Jumper wires<\/li>\n<\/ul>\n<h2>Understanding Your Garage Door Opener<\/h2>\n<p>Most garage door openers have a wall button that simply shorts two wires together to trigger the door. You can connect a relay across these terminals to simulate a button press. The wires are low voltage (usually 12-24V DC), so it is safe to interface with.<\/p>\n<p><strong>Important:<\/strong> Identify the correct wires before connecting. Use a multimeter to find the pair that shows continuity when the wall button is pressed.<\/p>\n<h2>Circuit Diagram<\/h2>\n<h3>Connection Table<\/h3>\n<table border=\"1\">\n<thead>\n<th>Component<\/th>\n<th>Pin<\/th>\n<th>ESP32 Pin<\/th>\n<\/thead>\n<tbody>\n<th>PIR Sensor<\/th>\n<p> VCC<\/th>\n<p> 3.3V or VIN<\/th>\n<th>PIR Sensor<\/th>\n<p> GND<\/th>\n<p> GND<\/th>\n<th>PIR Sensor<\/th>\n<p> OUT<\/th>\n<p> GPIO 4<\/th>\n<th>Relay Module<\/th>\n<p> IN<\/th>\n<p> GPIO 5<\/th>\n<th>Reed Switch<\/th>\n<p> One side<\/th>\n<p> GPIO 12 (with 10k pull-up)<\/th>\n<th>Reed Switch<\/th>\n<p> Other side<\/th>\n<p> GND<\/th>\n<\/tbody>\n<p>\u8868<\/p>\n<h2>Arduino Code<\/h2>\n<pre><code>\/\/ Automatic Garage Door Opener with PIR\n#include &lt;WiFi.h&gt;\n#include &lt;WebServer.h&gt;\n\nconst int pirPin = 4;\nconst int relayPin = 5;\nconst int doorSensorPin = 12;\n\nWebServer server(80);\n\nunsigned long lastTriggerTime = 0;\nconst unsigned long triggerDelay = 1000;\nconst unsigned long relayDuration = 500;\nconst unsigned long cooldownPeriod = 30000;\n\nbool motionDetected = false;\nbool doorOpen = false;\nunsigned long motionStartTime = 0;\n\nvoid setup() {\n  Serial.begin(115200);\n  \n  pinMode(pirPin, INPUT);\n  pinMode(relayPin, OUTPUT);\n  pinMode(doorSensorPin, INPUT_PULLUP);\n  \n  digitalWrite(relayPin, LOW);\n  \n  WiFi.begin(\"YourSSID\", \"YourPassword\");\n  while (WiFi.status() != WL_CONNECTED) delay(500);\n  \n  server.on(\"\/\", []() {\n    String html = \"&lt;html&gt;&lt;body&gt;&lt;h1&gt;Garage Door&lt;\/h1&gt;&lt;p&gt;Status: \";\n    html += doorOpen ? \"OPEN\" : \"CLOSED\";\n    html += \"&lt;\/p&gt;&lt;a href='\/open'&gt;&lt;button&gt;Open&lt;\/button&gt;&lt;\/a&gt;&lt;\/body&gt;&lt;\/html&gt;\";\n    server.send(200, \"text\/html\", html);\n  });\n  server.on(\"\/open\", []() {\n    triggerDoor();\n    server.sendHeader(\"Location\", \"\/\");\n    server.send(303);\n  });\n  server.begin();\n  \n  doorOpen = digitalRead(doorSensorPin) == LOW;\n  delay(60000);\n}\n\nvoid triggerDoor() {\n  digitalWrite(relayPin, HIGH);\n  delay(relayDuration);\n  digitalWrite(relayPin, LOW);\n  delay(2000);\n  doorOpen = digitalRead(doorSensorPin) == LOW;\n  lastTriggerTime = millis();\n}\n\nvoid loop() {\n  server.handleClient();\n  \n  bool pirState = digitalRead(pirPin) == HIGH;\n  \n  if (pirState && !motionDetected) {\n    motionDetected = true;\n    motionStartTime = millis();\n  }\n  \n  if (motionDetected && (millis() - motionStartTime > triggerDelay)) {\n    if (!doorOpen && (millis() - lastTriggerTime > cooldownPeriod)) {\n      triggerDoor();\n    }\n    motionDetected = false;\n  }\n  \n  if (motionDetected && !pirState && (millis() - motionStartTime < triggerDelay)) {\n    motionDetected = false;\n  }\n  \n  bool newDoorState = digitalRead(doorSensorPin) == LOW;\n  if (newDoorState != doorOpen) {\n    doorOpen = newDoorState;\n  }\n  \n  delay(100);\n}\n<\/code><\/pre>\n<h2>Installation Steps<\/h2>\n<ol>\n<li>Identify the wall button terminals on your garage door opener<\/li>\n<li>Wire the relay COM and NO terminals across those terminals<\/li>\n<li>Mount PIR sensor at driveway entrance, 1.5-2m high, angled to detect vehicle approach<\/li>\n<li>Mount reed switch on door frame and magnet on door<\/li>\n<li>Place ESP32 and relay in waterproof enclosure near the garage door opener<\/li>\n<li>Test by driving vehicle toward garage and verifying door opens automatically<\/li>\n<\/ol>\n<h2>Project Extensions<\/h2>\n<ul>\n<li>Add Wi-Fi dashboard to monitor door status and manually control<\/li>\n<li>Integrate with Home Assistant via ESPHome<\/li>\n<li>Add ESP32-CAM to capture images when door opens<\/li>\n<li>Add RFID for vehicle-specific control<\/li>\n<li>Add timer to automatically close door if left open<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>This automatic garage door opener adds convenience and a modern touch to your home. With proper installation, it will reliably open your garage door as you arrive.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Project Overview This project creates a hands-free garage door opener that detects when your car approaches and automatically opens the door. Using a PIR sensor mounted near the driveway, the system detects your vehicle&#8217;s heat signature and triggers a relay that simulates pressing the garage door opener button. Difficulty: Intermediate Estimated time: 2-3 hours Estimated [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-4126","post","type-post","status-publish","format-standard","hentry","category-projects"],"blocksy_meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>PIR Sensor for Garage Door Automation: Vehicle Detection - PIRHOME<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.pirhome.com\/?p=4126\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"PIR Sensor for Garage Door Automation: Vehicle Detection - PIRHOME\" \/>\r\n<meta property=\"og:description\" content=\"Project Overview This project creates a hands-free garage door opener that detects when your car approaches and automatically opens the door. Using a PIR sensor mounted near the driveway, the system detects your vehicle&#8217;s heat signature and triggers a relay that simulates pressing the garage door opener button. Difficulty: Intermediate Estimated time: 2-3 hours Estimated [&hellip;]\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.pirhome.com\/?p=4126\" \/>\r\n<meta property=\"og:site_name\" content=\"PIRHOME\" \/>\r\n<meta property=\"article:published_time\" content=\"2026-04-30T09:00:00+00:00\" \/>\r\n<meta name=\"author\" content=\"nic@nicsky.com\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"nic@nicsky.com\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4126#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4126\"},\"author\":{\"name\":\"nic@nicsky.com\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#\\\/schema\\\/person\\\/41049b5236f9c77c9314997d070db3e3\"},\"headline\":\"PIR Sensor for Garage Door Automation: Vehicle Detection\",\"datePublished\":\"2026-04-30T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4126\"},\"wordCount\":432,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#organization\"},\"articleSection\":[\"Projects\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pirhome.com\\\/?p=4126#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4126\",\"url\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4126\",\"name\":\"PIR Sensor for Garage Door Automation: Vehicle Detection - PIRHOME\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#website\"},\"datePublished\":\"2026-04-30T09:00:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4126#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pirhome.com\\\/?p=4126\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4126#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.pirhome.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PIR Sensor for Garage Door Automation: Vehicle Detection\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#website\",\"url\":\"http:\\\/\\\/www.pirhome.com\\\/\",\"name\":\"PIRHOME\",\"description\":\"PIR &amp; Motion Sensor\",\"publisher\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/www.pirhome.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#organization\",\"name\":\"PIRHOME\",\"url\":\"http:\\\/\\\/www.pirhome.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.pirhome.com\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/cropped-\u5fae\u4fe1\u56fe\u7247_2026-02-19_222409_472.jpg\",\"contentUrl\":\"https:\\\/\\\/www.pirhome.com\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/cropped-\u5fae\u4fe1\u56fe\u7247_2026-02-19_222409_472.jpg\",\"width\":512,\"height\":512,\"caption\":\"PIRHOME\"},\"image\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#\\\/schema\\\/person\\\/41049b5236f9c77c9314997d070db3e3\",\"name\":\"nic@nicsky.com\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/271d4eaab48e299e4fce771a8c43c537be3ac77a3115cc7de802a6c8b692d971?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/271d4eaab48e299e4fce771a8c43c537be3ac77a3115cc7de802a6c8b692d971?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/271d4eaab48e299e4fce771a8c43c537be3ac77a3115cc7de802a6c8b692d971?s=96&d=mm&r=g\",\"caption\":\"nic@nicsky.com\"},\"sameAs\":[\"http:\\\/\\\/www.pirhome.com\"],\"url\":\"https:\\\/\\\/www.pirhome.com\\\/?author=1\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PIR Sensor for Garage Door Automation: Vehicle Detection - PIRHOME","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pirhome.com\/?p=4126","og_locale":"en_US","og_type":"article","og_title":"PIR Sensor for Garage Door Automation: Vehicle Detection - PIRHOME","og_description":"Project Overview This project creates a hands-free garage door opener that detects when your car approaches and automatically opens the door. Using a PIR sensor mounted near the driveway, the system detects your vehicle&#8217;s heat signature and triggers a relay that simulates pressing the garage door opener button. Difficulty: Intermediate Estimated time: 2-3 hours Estimated [&hellip;]","og_url":"https:\/\/www.pirhome.com\/?p=4126","og_site_name":"PIRHOME","article_published_time":"2026-04-30T09:00:00+00:00","author":"nic@nicsky.com","twitter_card":"summary_large_image","twitter_misc":{"Written by":"nic@nicsky.com","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pirhome.com\/?p=4126#article","isPartOf":{"@id":"https:\/\/www.pirhome.com\/?p=4126"},"author":{"name":"nic@nicsky.com","@id":"http:\/\/www.pirhome.com\/#\/schema\/person\/41049b5236f9c77c9314997d070db3e3"},"headline":"PIR Sensor for Garage Door Automation: Vehicle Detection","datePublished":"2026-04-30T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pirhome.com\/?p=4126"},"wordCount":432,"commentCount":0,"publisher":{"@id":"http:\/\/www.pirhome.com\/#organization"},"articleSection":["Projects"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pirhome.com\/?p=4126#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pirhome.com\/?p=4126","url":"https:\/\/www.pirhome.com\/?p=4126","name":"PIR Sensor for Garage Door Automation: Vehicle Detection - PIRHOME","isPartOf":{"@id":"http:\/\/www.pirhome.com\/#website"},"datePublished":"2026-04-30T09:00:00+00:00","breadcrumb":{"@id":"https:\/\/www.pirhome.com\/?p=4126#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pirhome.com\/?p=4126"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pirhome.com\/?p=4126#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.pirhome.com\/"},{"@type":"ListItem","position":2,"name":"PIR Sensor for Garage Door Automation: Vehicle Detection"}]},{"@type":"WebSite","@id":"http:\/\/www.pirhome.com\/#website","url":"http:\/\/www.pirhome.com\/","name":"PIRHOME","description":"PIR &amp; Motion Sensor","publisher":{"@id":"http:\/\/www.pirhome.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.pirhome.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/www.pirhome.com\/#organization","name":"PIRHOME","url":"http:\/\/www.pirhome.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.pirhome.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.pirhome.com\/wp-content\/uploads\/2026\/02\/cropped-\u5fae\u4fe1\u56fe\u7247_2026-02-19_222409_472.jpg","contentUrl":"https:\/\/www.pirhome.com\/wp-content\/uploads\/2026\/02\/cropped-\u5fae\u4fe1\u56fe\u7247_2026-02-19_222409_472.jpg","width":512,"height":512,"caption":"PIRHOME"},"image":{"@id":"http:\/\/www.pirhome.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"http:\/\/www.pirhome.com\/#\/schema\/person\/41049b5236f9c77c9314997d070db3e3","name":"nic@nicsky.com","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/271d4eaab48e299e4fce771a8c43c537be3ac77a3115cc7de802a6c8b692d971?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/271d4eaab48e299e4fce771a8c43c537be3ac77a3115cc7de802a6c8b692d971?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/271d4eaab48e299e4fce771a8c43c537be3ac77a3115cc7de802a6c8b692d971?s=96&d=mm&r=g","caption":"nic@nicsky.com"},"sameAs":["http:\/\/www.pirhome.com"],"url":"https:\/\/www.pirhome.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/4126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4126"}],"version-history":[{"count":1,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/4126\/revisions"}],"predecessor-version":[{"id":4644,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/4126\/revisions\/4644"}],"wp:attachment":[{"href":"https:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}