{"id":4138,"date":"2026-05-12T09:00:00","date_gmt":"2026-05-12T09:00:00","guid":{"rendered":"https:\/\/pirhome.com\/?p=3923"},"modified":"2026-05-12T09:00:00","modified_gmt":"2026-05-12T09:00:00","slug":"pir-medicine-reminder","status":"publish","type":"post","link":"http:\/\/www.pirhome.com\/?p=4138","title":{"rendered":"PIR Sensor for Medicine Reminder: Never Miss a Dose"},"content":{"rendered":"<h2>Project Overview<\/h2>\n<p>This project creates a medicine reminder system that helps elderly or forgetful individuals remember to take their medication. A PIR sensor detects when someone approaches the medicine cabinet, and if it is time for medication, the system plays a reminder message and lights up LEDs.<\/p>\n<p><strong>Difficulty:<\/strong> Intermediate<br \/>\n<strong>Estimated time:<\/strong> 2-3 hours<br \/>\n<strong>Estimated cost:<\/strong> $30-40<\/p>\n<h2>How It Works<\/h2>\n<p>A PIR sensor at the medicine cabinet detects when someone approaches. The system checks the current time against a schedule of medication times. If it is within the reminder window, it plays a recorded message (via DFPlayer Mini) and lights up LEDs. If the person opens the cabinet (detected by a reed switch), the reminder is marked as taken.<\/p>\n<h2>Materials Needed<\/h2>\n<ul>\n<li>ESP32 or Arduino Uno (1)<\/li>\n<li>HC-SR501 PIR sensor (1)<\/li>\n<li>DS3231 Real-Time Clock (1)<\/li>\n<li>DFPlayer Mini MP3 module (1)<\/li>\n<li>MicroSD card with reminder audio files<\/li>\n<li>Small speaker (3W, 4-8\u03a9)<\/li>\n<li>LEDs (red, green, blue) for status<\/li>\n<li>220\u03a9 resistors for LEDs<\/li>\n<li>Reed switch for cabinet door detection<\/li>\n<li>Magnet<\/li>\n<li>Jumper wires<\/li>\n<li>Power supply (5V 2A)<\/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>DS3231 RTC<\/th>\n<p> SDA<\/th>\n<p> GPIO 21<\/th>\n<th>DS3231 RTC<\/th>\n<p> SCL<\/th>\n<p> GPIO 22<\/th>\n<th>DFPlayer Mini<\/th>\n<p> TX<\/th>\n<p> GPIO 16<\/th>\n<th>DFPlayer Mini<\/th>\n<p> RX<\/th>\n<p> GPIO 17<\/th>\n<th>Red LED<\/th>\n<p> Anode<\/th>\n<p> GPIO 5<\/th>\n<th>Green LED<\/th>\n<p> Anode<\/th>\n<p> GPIO 18<\/th>\n<th>Blue LED<\/th>\n<p> Anode<\/th>\n<p> GPIO 19<\/th>\n<th>Reed Switch<\/th>\n<p> One side<\/th>\n<p> GPIO 23<\/th>\n<\/tbody>\n<p>\u8868<\/p>\n<h2>Arduino Code<\/h2>\n<pre><code>\/\/ Medicine Reminder System\n#include &lt;Wire.h&gt;\n#include &lt;RTClib.h&gt;\n#include &lt;SoftwareSerial.h&gt;\n#include &lt;DFRobotDFPlayerMini.h&gt;\n\nRTC_DS3231 rtc;\nSoftwareSerial mySoftwareSerial(16, 17);\nDFRobotDFPlayerMini myDFPlayer;\n\nconst int pirPin = 4;\nconst int redLedPin = 5;\nconst int greenLedPin = 18;\nconst int blueLedPin = 19;\nconst int doorSensorPin = 23;\n\nstruct MedTime {\n  int hour;\n  int minute;\n  int messageFile;\n  bool taken;\n};\n\nMedTime medTimes[] = {\n  {8, 0, 1, false},\n  {12, 0, 2, false},\n  {18, 0, 3, false}\n};\nconst int numMedTimes = 3;\n\nbool reminderActive = false;\nint activeMedIndex = -1;\nunsigned long lastMotionTime = 0;\nconst unsigned long reminderDuration = 60000;\n\nvoid setup() {\n  Serial.begin(115200);\n  \n  pinMode(pirPin, INPUT);\n  pinMode(redLedPin, OUTPUT);\n  pinMode(greenLedPin, OUTPUT);\n  pinMode(blueLedPin, OUTPUT);\n  pinMode(doorSensorPin, INPUT_PULLUP);\n  \n  digitalWrite(redLedPin, LOW);\n  digitalWrite(greenLedPin, LOW);\n  digitalWrite(blueLedPin, LOW);\n  \n  rtc.begin();\n  mySoftwareSerial.begin(9600);\n  myDFPlayer.begin(mySoftwareSerial);\n  myDFPlayer.volume(20);\n  \n  delay(60000);\n}\n\nvoid checkScheduledTimes() {\n  DateTime now = rtc.now();\n  int currentHour = now.hour();\n  int currentMinute = now.minute();\n  \n  for (int i = 0; i < numMedTimes; i++) {\n    if (!medTimes[i].taken &#038;&#038; currentHour == medTimes[i].hour &#038;&#038; \n        currentMinute >= medTimes[i].minute && currentMinute < medTimes[i].minute + 30) {\n      if (!reminderActive) {\n        reminderActive = true;\n        activeMedIndex = i;\n        digitalWrite(blueLedPin, HIGH);\n      }\n      return;\n    }\n  }\n}\n\nvoid playReminder() {\n  if (activeMedIndex >= 0) {\n    myDFPlayer.play(medTimes[activeMedIndex].messageFile);\n  }\n}\n\nvoid markTaken() {\n  if (activeMedIndex >= 0) {\n    medTimes[activeMedIndex].taken = true;\n    reminderActive = false;\n    activeMedIndex = -1;\n    \n    digitalWrite(blueLedPin, LOW);\n    digitalWrite(greenLedPin, HIGH);\n    myDFPlayer.play(4);\n    delay(2000);\n    digitalWrite(greenLedPin, LOW);\n  }\n}\n\nvoid loop() {\n  checkScheduledTimes();\n  \n  bool motion = digitalRead(pirPin) == HIGH;\n  bool doorOpen = digitalRead(doorSensorPin) == LOW;\n  \n  if (reminderActive && motion) {\n    if (millis() - lastMotionTime > 10000) {\n      playReminder();\n      lastMotionTime = millis();\n    }\n    digitalWrite(redLedPin, HIGH);\n  } else {\n    digitalWrite(redLedPin, LOW);\n  }\n  \n  if (doorOpen && reminderActive) markTaken();\n  \n  if (reminderActive && (millis() - lastMotionTime > reminderDuration)) {\n    digitalWrite(redLedPin, LOW);\n    digitalWrite(blueLedPin, LOW);\n  }\n  \n  delay(100);\n}\n<\/code><\/pre>\n<h2>Installation Steps<\/h2>\n<ol>\n<li>Record reminder messages and place on SD card<\/li>\n<li>Set RTC time using example sketch<\/li>\n<li>Assemble circuit and test<\/li>\n<li>Mount PIR sensor near medicine cabinet<\/li>\n<li>Install reed switch on cabinet door and frame<\/li>\n<li>Position speaker where message can be heard clearly<\/li>\n<li>Approach cabinet at medication time to test reminder<\/li>\n<\/ol>\n<h2>Project Extensions<\/h2>\n<ul>\n<li>Add Wi-Fi to send alerts to caregivers<\/li>\n<li>Add servo to dispense pills when door is opened<\/li>\n<li>Add voice recognition for confirmation<\/li>\n<li>Track adherence and send reports<\/li>\n<li>Add RFID to identify which person is taking medication<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>This medicine reminder system helps ensure medications are taken on time, especially helpful for elderly individuals or anyone who struggles with remembering medications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Project Overview This project creates a medicine reminder system that helps elderly or forgetful individuals remember to take their medication. A PIR sensor detects when someone approaches the medicine cabinet, and if it is time for medication, the system plays a reminder message and lights up LEDs. Difficulty: Intermediate Estimated time: 2-3 hours Estimated cost: [&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-4138","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 Medicine Reminder: Never Miss a Dose - 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=\"http:\/\/www.pirhome.com\/?p=4138\" \/>\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 Medicine Reminder: Never Miss a Dose - PIRHOME\" \/>\r\n<meta property=\"og:description\" content=\"Project Overview This project creates a medicine reminder system that helps elderly or forgetful individuals remember to take their medication. A PIR sensor detects when someone approaches the medicine cabinet, and if it is time for medication, the system plays a reminder message and lights up LEDs. Difficulty: Intermediate Estimated time: 2-3 hours Estimated cost: [&hellip;]\" \/>\r\n<meta property=\"og:url\" content=\"http:\/\/www.pirhome.com\/?p=4138\" \/>\r\n<meta property=\"og:site_name\" content=\"PIRHOME\" \/>\r\n<meta property=\"article:published_time\" content=\"2026-05-12T09: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\":\"http:\\\/\\\/www.pirhome.com\\\/?p=4138#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/?p=4138\"},\"author\":{\"name\":\"nic@nicsky.com\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#\\\/schema\\\/person\\\/41049b5236f9c77c9314997d070db3e3\"},\"headline\":\"PIR Sensor for Medicine Reminder: Never Miss a Dose\",\"datePublished\":\"2026-05-12T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/?p=4138\"},\"wordCount\":333,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#organization\"},\"articleSection\":[\"Projects\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\\\/\\\/www.pirhome.com\\\/?p=4138#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/?p=4138\",\"url\":\"http:\\\/\\\/www.pirhome.com\\\/?p=4138\",\"name\":\"PIR Sensor for Medicine Reminder: Never Miss a Dose - PIRHOME\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/#website\"},\"datePublished\":\"2026-05-12T09:00:00+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/?p=4138#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.pirhome.com\\\/?p=4138\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.pirhome.com\\\/?p=4138#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.pirhome.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PIR Sensor for Medicine Reminder: Never Miss a Dose\"}]},{\"@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":"PIR Sensor for Medicine Reminder: Never Miss a Dose - 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":"http:\/\/www.pirhome.com\/?p=4138","og_locale":"en_US","og_type":"article","og_title":"PIR Sensor for Medicine Reminder: Never Miss a Dose - PIRHOME","og_description":"Project Overview This project creates a medicine reminder system that helps elderly or forgetful individuals remember to take their medication. A PIR sensor detects when someone approaches the medicine cabinet, and if it is time for medication, the system plays a reminder message and lights up LEDs. Difficulty: Intermediate Estimated time: 2-3 hours Estimated cost: [&hellip;]","og_url":"http:\/\/www.pirhome.com\/?p=4138","og_site_name":"PIRHOME","article_published_time":"2026-05-12T09: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":"http:\/\/www.pirhome.com\/?p=4138#article","isPartOf":{"@id":"http:\/\/www.pirhome.com\/?p=4138"},"author":{"name":"nic@nicsky.com","@id":"http:\/\/www.pirhome.com\/#\/schema\/person\/41049b5236f9c77c9314997d070db3e3"},"headline":"PIR Sensor for Medicine Reminder: Never Miss a Dose","datePublished":"2026-05-12T09:00:00+00:00","mainEntityOfPage":{"@id":"http:\/\/www.pirhome.com\/?p=4138"},"wordCount":333,"commentCount":0,"publisher":{"@id":"http:\/\/www.pirhome.com\/#organization"},"articleSection":["Projects"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/www.pirhome.com\/?p=4138#respond"]}]},{"@type":"WebPage","@id":"http:\/\/www.pirhome.com\/?p=4138","url":"http:\/\/www.pirhome.com\/?p=4138","name":"PIR Sensor for Medicine Reminder: Never Miss a Dose - PIRHOME","isPartOf":{"@id":"http:\/\/www.pirhome.com\/#website"},"datePublished":"2026-05-12T09:00:00+00:00","breadcrumb":{"@id":"http:\/\/www.pirhome.com\/?p=4138#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.pirhome.com\/?p=4138"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.pirhome.com\/?p=4138#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.pirhome.com\/"},{"@type":"ListItem","position":2,"name":"PIR Sensor for Medicine Reminder: Never Miss a Dose"}]},{"@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\/4138","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=4138"}],"version-history":[{"count":1,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/4138\/revisions"}],"predecessor-version":[{"id":4661,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=\/wp\/v2\/posts\/4138\/revisions\/4661"}],"wp:attachment":[{"href":"http:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4138"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pirhome.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}