{"id":3007,"date":"2026-02-19T21:36:05","date_gmt":"2026-02-19T13:36:05","guid":{"rendered":"https:\/\/pirhome.com\/?p=3007"},"modified":"2026-02-19T21:36:12","modified_gmt":"2026-02-19T13:36:12","slug":"pir-esp32-home-assistant","status":"publish","type":"post","link":"http:\/\/www.pirhome.com\/?p=3007","title":{"rendered":"Using PIR Sensors with ESP32 and Home Assistant"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Home Assistant is a popular open-source home automation platform. Combining it with ESP32 and PIR sensors lets you create powerful automations. This guide walks you through the setup.<\/p>\n<h2>Hardware Needed<\/h2>\n<ul>\n<li>ESP32 development board (e.g., NodeMCU-32S)<\/li>\n<li>PIR sensor (AM312 or HC-SR501)<\/li>\n<li>Jumper wires<\/li>\n<li>Breadboard (optional)<\/li>\n<li>USB power supply<\/li>\n<\/ul>\n<h2>Step 1: Wiring<\/h2>\n<p>Connect the PIR sensor to the ESP32:<\/p>\n<ul>\n<li>VCC \u2192 3.3V (for AM312) or 5V (for HC-SR501, if using 5V pin)<\/li>\n<li>GND \u2192 GND<\/li>\n<li>OUT \u2192 GPIO pin (e.g., GPIO4)<\/li>\n<\/ul>\n<p><strong>Note:<\/strong> If using HC-SR501 with ESP32, ensure the output voltage is 3.3V compatible (most are). Alternatively, use a voltage divider.<\/p>\n<h2>Step 2: Install ESPHome or Tasmota<\/h2>\n<p>Two popular firmware options:<\/p>\n<h3>ESPHome (Recommended)<\/h3>\n<p>ESPHome integrates seamlessly with Home Assistant. Follow the ESPHome installation guide to flash your ESP32.<\/p>\n<p>Example ESPHome YAML configuration:<\/p>\n<pre><code>esphome:\n  name: motion-sensor\n\nesp32:\n  board: nodemcu-32s\n\nwifi:\n  ssid: \"YourSSID\"\n  password: \"YourPassword\"\n\nmqtt:\n  broker: 192.168.1.100  # Your Home Assistant IP\n\nbinary_sensor:\n  - platform: gpio\n    pin: GPIO4\n    name: \"Living Room Motion\"\n    device_class: motion\n    filters:\n      - delayed_on: 100ms  # Debounce\n<\/code><\/pre>\n<p>Upload the configuration to your ESP32.<\/p>\n<h2>Step 3: Integrate with Home Assistant<\/h2>\n<p>If using ESPHome, the device will auto-discover in Home Assistant. If using MQTT, ensure the MQTT integration is configured.<\/p>\n<p>You&#8217;ll see a binary sensor &#8220;Living Room Motion&#8221; that turns on when motion is detected.<\/p>\n<h2>Step 4: Create Automations<\/h2>\n<p>In Home Assistant, go to Configuration \u2192 Automations. Example: Turn on lights when motion detected after sunset.<\/p>\n<pre><code>alias: \"Living Room Lights on Motion\"\ntrigger:\n  platform: state\n  entity_id: binary_sensor.living_room_motion\n  to: \"on\"\ncondition:\n  condition: sun\n  after: sunset\naction:\n  service: light.turn_on\n  entity_id: light.living_room_lights\n<\/code><\/pre>\n<h2>Step 5: Add More Sensors<\/h2>\n<p>Repeat for multiple rooms. Consider using different GPIO pins or multiple ESP32s.<\/p>\n<h2>Power Considerations<\/h2>\n<p>If using battery power, choose a low-power PIR (AM312) and use deep sleep on ESP32. ESPHome supports deep sleep with wake on motion (requires wiring PIR output to RTC pin).<\/p>\n<h2>Troubleshooting<\/h2>\n<ul>\n<li>Sensor not detected: Check wiring, voltage, and MQTT connection.<\/li>\n<li>False triggers: Add debounce filters in ESPHome.<\/li>\n<li>Range issues: Adjust sensitivity or lens.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Integrating PIR sensors with ESP32 and Home Assistant is straightforward and opens endless automation possibilities. Start with one sensor and expand.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Home Assistant is a popular open-source home automation platform. Combining it with ESP32 and PIR sensors lets you create powerful automations. This guide walks you through the setup. Hardware Needed ESP32 development board (e.g., NodeMCU-32S) PIR sensor (AM312 or HC-SR501) Jumper wires Breadboard (optional) USB power supply Step 1: Wiring Connect the PIR sensor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3007","post","type-post","status-publish","format-standard","hentry","category-news"],"blocksy_meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Using PIR Sensors with ESP32 and Home Assistant - 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=3007\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Using PIR Sensors with ESP32 and Home Assistant - PIRHOME\" \/>\r\n<meta property=\"og:description\" content=\"Introduction Home Assistant is a popular open-source home automation platform. Combining it with ESP32 and PIR sensors lets you create powerful automations. This guide walks you through the setup. Hardware Needed ESP32 development board (e.g., NodeMCU-32S) PIR sensor (AM312 or HC-SR501) Jumper wires Breadboard (optional) USB power supply Step 1: Wiring Connect the PIR sensor [&hellip;]\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.pirhome.com\/?p=3007\" \/>\r\n<meta property=\"og:site_name\" content=\"PIRHOME\" \/>\r\n<meta property=\"article:published_time\" content=\"2026-02-19T13:36:05+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2026-02-19T13:36:12+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=\"2 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=3007#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=3007\"},\"author\":{\"name\":\"nic@nicsky.com\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#\\\/schema\\\/person\\\/41049b5236f9c77c9314997d070db3e3\"},\"headline\":\"Using PIR Sensors with ESP32 and Home Assistant\",\"datePublished\":\"2026-02-19T13:36:05+00:00\",\"dateModified\":\"2026-02-19T13:36:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=3007\"},\"wordCount\":295,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#organization\"},\"articleSection\":[\"Pirsensor News\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pirhome.com\\\/?p=3007#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=3007\",\"url\":\"https:\\\/\\\/www.pirhome.com\\\/?p=3007\",\"name\":\"Using PIR Sensors with ESP32 and Home Assistant - PIRHOME\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#website\"},\"datePublished\":\"2026-02-19T13:36:05+00:00\",\"dateModified\":\"2026-02-19T13:36:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=3007#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pirhome.com\\\/?p=3007\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=3007#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.pirhome.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using PIR Sensors with ESP32 and Home Assistant\"}]},{\"@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\":\"http:\\\/\\\/www.pirhome.com\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/cropped-\u5fae\u4fe1\u56fe\u7247_2026-02-19_222409_472.jpg\",\"contentUrl\":\"http:\\\/\\\/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\":\"http:\\\/\\\/www.pirhome.com\\\/?author=1\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using PIR Sensors with ESP32 and Home Assistant - 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=3007","og_locale":"en_US","og_type":"article","og_title":"Using PIR Sensors with ESP32 and Home Assistant - PIRHOME","og_description":"Introduction Home Assistant is a popular open-source home automation platform. Combining it with ESP32 and PIR sensors lets you create powerful automations. This guide walks you through the setup. Hardware Needed ESP32 development board (e.g., NodeMCU-32S) PIR sensor (AM312 or HC-SR501) Jumper wires Breadboard (optional) USB power supply Step 1: Wiring Connect the PIR sensor [&hellip;]","og_url":"https:\/\/www.pirhome.com\/?p=3007","og_site_name":"PIRHOME","article_published_time":"2026-02-19T13:36:05+00:00","article_modified_time":"2026-02-19T13:36:12+00:00","author":"nic@nicsky.com","twitter_card":"summary_large_image","twitter_misc":{"Written by":"nic@nicsky.com","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pirhome.com\/?p=3007#article","isPartOf":{"@id":"https:\/\/www.pirhome.com\/?p=3007"},"author":{"name":"nic@nicsky.com","@id":"http:\/\/www.pirhome.com\/#\/schema\/person\/41049b5236f9c77c9314997d070db3e3"},"headline":"Using PIR Sensors with ESP32 and Home Assistant","datePublished":"2026-02-19T13:36:05+00:00","dateModified":"2026-02-19T13:36:12+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pirhome.com\/?p=3007"},"wordCount":295,"commentCount":0,"publisher":{"@id":"http:\/\/www.pirhome.com\/#organization"},"articleSection":["Pirsensor News"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pirhome.com\/?p=3007#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pirhome.com\/?p=3007","url":"https:\/\/www.pirhome.com\/?p=3007","name":"Using PIR Sensors with ESP32 and Home Assistant - PIRHOME","isPartOf":{"@id":"http:\/\/www.pirhome.com\/#website"},"datePublished":"2026-02-19T13:36:05+00:00","dateModified":"2026-02-19T13:36:12+00:00","breadcrumb":{"@id":"https:\/\/www.pirhome.com\/?p=3007#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pirhome.com\/?p=3007"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pirhome.com\/?p=3007#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.pirhome.com\/"},{"@type":"ListItem","position":2,"name":"Using PIR Sensors with ESP32 and Home Assistant"}]},{"@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":"http:\/\/www.pirhome.com\/wp-content\/uploads\/2026\/02\/cropped-\u5fae\u4fe1\u56fe\u7247_2026-02-19_222409_472.jpg","contentUrl":"http:\/\/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":"http:\/\/www.pirhome.com\/?author=1"}]}},"_links":{"self":[{"href":"http:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/3007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3007"}],"version-history":[{"count":1,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/3007\/revisions"}],"predecessor-version":[{"id":3014,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/3007\/revisions\/3014"}],"wp:attachment":[{"href":"http:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3007"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}