3. Design Process - KieranThompsonCE/Smart-Pill-Organizer GitHub Wiki

The team made a prototype of the project to demonstrate how a finished product could look. The prototype was created using an Arduino Uno as the microcontroller, and programmed it using the Arduino IDE.

Hardware

The hardware consisted of:

  • Arduino Uno
  • ESP8266 NodeMCU CP2102 ESP-12E Development Board
  • Tiny RTC real time clock module
  • 1602 LCD display
  • 2 SN74HC595N shift registers
  • 20 key keypad
  • Piezoelectric buzzer
  • 14 LEDs

Pill Organizer

Pill Organizer

Keypad

Keypad

To include wireless functionality the team used an ESP8266 Wi-Fi development board to send a notification to a web server that then sends an SMS message to the user's phone. The development board was selected for prototyping, but could be reduced to use only the Wi-Fi module for a production version.

A Real Time Clock Module (RTC) was used to keep more accurate time than using a loop inside the software. The Tiny RTC was selected for it's ease of use with Arduino, and it's included library. This module communicates over serial, and the library is used to compute the full date, time to the second, and 0 - 6 to represent day of the week. The library also takes into account the correct number of days in each month, including leap years.

The team used a 1602 LCD that can display 2 rows of 16 characters. The LCD also uses serial communication to write data to the display.

To organize the medication, a 7 day AM and PM pill organizer was modified to include LEDs in each compartment. To individually address each LED, 2 SN74HC595N shift registers were used in series. This allowed connection of up to 16 LEDs.

A keypad was included to allow the user to edit the time that the alarms are set for directly from the device. An analog keypad with digits 0 - 9 and arrow keys was selected. The keypad was wired into an array of resistor so that the keypad would use just 1 analog pin on the Arduino.

A piezoelectric buzzer was also used to play a simple melody whenever an alarm goes off.

Software

The prototype can store 14 alarms. This is a limit created by the team to match the number of compartments on the organizer, but this limit could be increased if desired. Each alarm has an associated array for if the alarm is on, and the hour, min, and day of the week it is set for. The main loop checks the current time against all the alarm times that are turned on with an included delay of 300ms. In this loop the keypad is also checked using polling to see if a key is being pressed. The team considered using interrupts to check for keypresses, but as the loop is not time dependent because of the RTC, polling was selected for it's simpler implementation. To turn on an LED, the Arduino uses synchronous serial communication to load a value into the shift registers. The LEDs are encoded so that every multiple of 2 represents one LED to be lit. Starting with box 0 = Sunday AM, the value written to the registers is 2^0 = 0b0000 0000 0001. For Thursday PM, it is box number 9, and so the code for the LED is 2^9 = 0b0010 0000 0000. If the value 2^14 - 1 (16,383) were to be written, all of the LEDs would light up.