{"id":4143,"date":"2026-05-17T09:00:00","date_gmt":"2026-05-17T09:00:00","guid":{"rendered":"https:\/\/pirhome.com\/?p=3928"},"modified":"2026-05-17T09:00:00","modified_gmt":"2026-05-17T09:00:00","slug":"pir-fish-tank-feeding-reminder-2","status":"publish","type":"post","link":"https:\/\/www.pirhome.com\/?p=4143","title":{"rendered":"PIR Sensor for Fish Tank Feeding Reminder"},"content":{"rendered":"<h2>Project Overview<\/h2>\n<p>This project creates a smart feeding reminder for your aquarium. When you approach the fish tank, the system checks if it is time to feed and plays a voice reminder if needed. It also tracks the last feeding time and prevents overfeeding.<\/p>\n<p><strong>Difficulty:<\/strong> Beginner<br \/>\n<strong>Estimated time:<\/strong> 1-2 hours<br \/>\n<strong>Estimated cost:<\/strong> $20-30<\/p>\n<h2>How It Works<\/h2>\n<p>A PIR sensor detects when someone approaches the fish tank. The ESP32 checks the current time against a feeding schedule. If it is within the feeding window and the last feeding was more than 8 hours ago, it plays a voice reminder. A button can be pressed to mark feeding as done.<\/p>\n<h2>Materials Needed<\/h2>\n<ul>\n<li>ESP32 (1)<\/li>\n<li>HC-SR501 PIR sensor (1)<\/li>\n<li>DFPlayer Mini MP3 module (1)<\/li>\n<li>MicroSD card with feeding reminder audio<\/li>\n<li>Small speaker (3W)<\/li>\n<li>Push button to mark feeding done<\/li>\n<li>LEDs for status (optional)<\/li>\n<li>220\u03a9 resistors<\/li>\n<li>Jumper wires<\/li>\n<li>Power supply (5V 1A)<\/li>\n<\/ul>\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> OUT<\/th>\n<p> GPIO 4<\/th>\n<th>DFPlayer Mini TX<\/th>\n<p> &#8211;<\/th>\n<p> GPIO 16<\/th>\n<th>DFPlayer Mini RX<\/th>\n<p> &#8211;<\/th>\n<p> GPIO 17<\/th>\n<th>Push Button<\/th>\n<p> One side<\/th>\n<p> GPIO 5<\/th>\n<th>Green LED<\/th>\n<p> Anode<\/th>\n<p> GPIO 2<\/th>\n<th>Red LED<\/th>\n<p> Anode<\/th>\n<p> GPIO 15<\/th>\n<\/tbody>\n<p>\u8868<\/p>\n<h2>Arduino Code<\/h2>\n<pre><code>\/\/ Fish Tank Feeding Reminder\n#include &lt;WiFi.h&gt;\n#include &lt;SoftwareSerial.h&gt;\n#include &lt;DFRobotDFPlayerMini.h&gt;\n#include &lt;time.h&gt;\n\nSoftwareSerial mySoftwareSerial(16, 17);\nDFRobotDFPlayerMini myDFPlayer;\n\nconst int pirPin = 4;\nconst int buttonPin = 5;\nconst int greenLedPin = 2;\nconst int redLedPin = 15;\n\nconst char* ntpServer = \"pool.ntp.org\";\nconst long gmtOffset = 0;\nconst int daylightOffset = 0;\n\nstruct FeedingTime {\n  int hour;\n  int minute;\n};\n\nFeedingTime feedTimes[] = {{8, 0}, {18, 0}};\nconst int numFeedTimes = 2;\n\nunsigned long lastFeedTime = 0;\nbool fedToday[2] = {false, false};\nunsigned long lastReminderTime = 0;\nconst unsigned long reminderCooldown = 3600000;\n\nvoid setup() {\n  Serial.begin(115200);\n  \n  pinMode(pirPin, INPUT);\n  pinMode(buttonPin, INPUT_PULLUP);\n  pinMode(greenLedPin, OUTPUT);\n  pinMode(redLedPin, OUTPUT);\n  \n  digitalWrite(greenLedPin, LOW);\n  digitalWrite(redLedPin, LOW);\n  \n  WiFi.begin(\"YourSSID\", \"YourPassword\");\n  while (WiFi.status() != WL_CONNECTED) delay(500);\n  configTime(gmtOffset, daylightOffset, ntpServer);\n  \n  mySoftwareSerial.begin(9600);\n  myDFPlayer.begin(mySoftwareSerial);\n  myDFPlayer.volume(20);\n  \n  delay(30000);\n}\n\nbool isTimeToFeed(int currentHour, int currentMinute, int feedHour, int feedMinute) {\n  int currentMinutes = currentHour * 60 + currentMinute;\n  int feedMinutes = feedHour * 60 + feedMinute;\n  return (currentMinutes >= feedMinutes && currentMinutes < feedMinutes + 30);\n}\n\nvoid markFed(int feedIndex) {\n  fedToday[feedIndex] = true;\n  lastFeedTime = millis();\n  digitalWrite(greenLedPin, HIGH);\n  myDFPlayer.play(3);\n  delay(2000);\n  digitalWrite(greenLedPin, LOW);\n}\n\nvoid playReminder(int feedIndex) {\n  myDFPlayer.play(feedIndex == 0 ? 1 : 2);\n  digitalWrite(redLedPin, HIGH);\n  delay(2000);\n  digitalWrite(redLedPin, LOW);\n}\n\nvoid resetDaily() {\n  struct tm timeinfo;\n  if (getLocalTime(&#038;timeinfo)) {\n    if (timeinfo.tm_hour == 0 &#038;&#038; timeinfo.tm_min == 0) {\n      for (int i = 0; i < numFeedTimes; i++) fedToday[i] = false;\n    }\n  }\n}\n\nvoid loop() {\n  struct tm timeinfo;\n  if (!getLocalTime(&#038;timeinfo)) return;\n  \n  resetDaily();\n  \n  bool motion = digitalRead(pirPin) == HIGH;\n  bool buttonPressed = digitalRead(buttonPin) == LOW;\n  \n  if (buttonPressed) {\n    delay(50);\n    if (digitalRead(buttonPin) == LOW) {\n      for (int i = 0; i < numFeedTimes; i++) {\n        if (isTimeToFeed(timeinfo.tm_hour, timeinfo.tm_min, feedTimes[i].hour, feedTimes[i].minute)) {\n          markFed(i);\n          break;\n        }\n      }\n      while (digitalRead(buttonPin) == LOW) delay(10);\n    }\n  }\n  \n  if (motion &#038;&#038; (millis() - lastReminderTime > reminderCooldown)) {\n    for (int i = 0; i < numFeedTimes; i++) {\n      if (isTimeToFeed(timeinfo.tm_hour, timeinfo.tm_min, feedTimes[i].hour, feedTimes[i].minute) &#038;&#038; !fedToday[i]) {\n        lastReminderTime = millis();\n        playReminder(i);\n        break;\n      }\n    }\n  }\n  \n  delay(100);\n}\n<\/code><\/pre>\n<h2>Installation Steps<\/h2>\n<ol>\n<li>Mount PIR sensor near fish tank<\/li>\n<li>Position speaker where reminder can be heard clearly<\/li>\n<li>Mount button near fish tank for easy access after feeding<\/li>\n<li>Assemble electronics in small box<\/li>\n<li>Adjust feeding times in code to match your schedule<\/li>\n<li>Approach tank at feeding time to test reminder<\/li>\n<\/ol>\n<h2>Project Extensions<\/h2>\n<ul>\n<li>Add servo to dispense food automatically<\/li>\n<li>Add Wi-Fi dashboard to view feeding history<\/li>\n<li>Add mobile notifications when feeding is missed<\/li>\n<li>Add DS18B20 to monitor tank temperature<\/li>\n<li>Add LED strip to simulate sunrise\/sunset<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>This fish tank feeding reminder ensures your aquatic pets are fed on schedule with voice reminders.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Project Overview This project creates a smart feeding reminder for your aquarium. When you approach the fish tank, the system checks if it is time to feed and plays a voice reminder if needed. It also tracks the last feeding time and prevents overfeeding. Difficulty: Beginner Estimated time: 1-2 hours Estimated cost: $20-30 How It [&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-4143","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 Fish Tank Feeding Reminder - 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=4143\" \/>\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 Fish Tank Feeding Reminder - PIRHOME\" \/>\r\n<meta property=\"og:description\" content=\"Project Overview This project creates a smart feeding reminder for your aquarium. When you approach the fish tank, the system checks if it is time to feed and plays a voice reminder if needed. It also tracks the last feeding time and prevents overfeeding. Difficulty: Beginner Estimated time: 1-2 hours Estimated cost: $20-30 How It [&hellip;]\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.pirhome.com\/?p=4143\" \/>\r\n<meta property=\"og:site_name\" content=\"PIRHOME\" \/>\r\n<meta property=\"article:published_time\" content=\"2026-05-17T09: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=4143#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4143\"},\"author\":{\"name\":\"nic@nicsky.com\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#\\\/schema\\\/person\\\/41049b5236f9c77c9314997d070db3e3\"},\"headline\":\"PIR Sensor for Fish Tank Feeding Reminder\",\"datePublished\":\"2026-05-17T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4143\"},\"wordCount\":288,\"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=4143#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4143\",\"url\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4143\",\"name\":\"PIR Sensor for Fish Tank Feeding Reminder - PIRHOME\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#website\"},\"datePublished\":\"2026-05-17T09:00:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4143#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pirhome.com\\\/?p=4143\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pirhome.com\\\/?p=4143#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.pirhome.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PIR Sensor for Fish Tank Feeding Reminder\"}]},{\"@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 Fish Tank Feeding Reminder - 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=4143","og_locale":"en_US","og_type":"article","og_title":"PIR Sensor for Fish Tank Feeding Reminder - PIRHOME","og_description":"Project Overview This project creates a smart feeding reminder for your aquarium. When you approach the fish tank, the system checks if it is time to feed and plays a voice reminder if needed. It also tracks the last feeding time and prevents overfeeding. Difficulty: Beginner Estimated time: 1-2 hours Estimated cost: $20-30 How It [&hellip;]","og_url":"https:\/\/www.pirhome.com\/?p=4143","og_site_name":"PIRHOME","article_published_time":"2026-05-17T09: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=4143#article","isPartOf":{"@id":"https:\/\/www.pirhome.com\/?p=4143"},"author":{"name":"nic@nicsky.com","@id":"http:\/\/www.pirhome.com\/#\/schema\/person\/41049b5236f9c77c9314997d070db3e3"},"headline":"PIR Sensor for Fish Tank Feeding Reminder","datePublished":"2026-05-17T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pirhome.com\/?p=4143"},"wordCount":288,"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=4143#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pirhome.com\/?p=4143","url":"https:\/\/www.pirhome.com\/?p=4143","name":"PIR Sensor for Fish Tank Feeding Reminder - PIRHOME","isPartOf":{"@id":"http:\/\/www.pirhome.com\/#website"},"datePublished":"2026-05-17T09:00:00+00:00","breadcrumb":{"@id":"https:\/\/www.pirhome.com\/?p=4143#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pirhome.com\/?p=4143"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pirhome.com\/?p=4143#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.pirhome.com\/"},{"@type":"ListItem","position":2,"name":"PIR Sensor for Fish Tank Feeding Reminder"}]},{"@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\/4143","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=4143"}],"version-history":[{"count":1,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/4143\/revisions"}],"predecessor-version":[{"id":4667,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/4143\/revisions\/4667"}],"wp:attachment":[{"href":"https:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}