Intro: IDC2018IOT IoPill Box
This is the IoPill Box - the internet connected weekly pill box.
For our final project of our IoT course, we decided to offer a solution that will help ensure that elderly people (or any other person that uses a weekly pill box) do not forget to take their pills daily, and on time.
In the following steps we will describe the different processes of our project, including future suggested implementations and improvements to the project.
- Day Indication – according to the day of the week, the corresponding cell in the box will be illuminated, indicating which pills are to be taken.
- Indication that the pills of the given day have been taken – through an LDR sensor installed in each cell, the box automatically knows whenever a cell has been opened in order to withdraw the daily pills, all the 7 LEDs will give indication to the patient.
- Reminder 1 – in case the daily pills have not been taken within the time-frame required, an email reminder will be sent to the user, to remind him to take his pills
- Reminder 2 – in case the user has yet to take his pills, after the given time frame and after the first reminder, an email will be sent to a family member or medical assistant – informing them that the daily pills have not been taken
- End of Week reminder – at the end of the week, a reminder to fill up the pills for the next week will be sent to the user, including instructions of the dosages and types of pills for each day – via email.
- Data Log – history of pill taking dates and times is kept in a data log feed via MQTT.
Step 1: Required Hardware, Software and Material
- ESP8266 NodeMCU
- 7 LEDS
- 7 LDR
- 7 x 10k Ohm resistor (for ldrs)
- 7 x 200R Ohm resistors (for leds)
- 4.7k Ohm resistor (for MCP23017)
- Pill Box
- A cardboard box
Step 2: The Box, and the Pill Box
We found some cardboard box and put the circuit in it and glued the pill box on top of it.
Because of the ldr's light sensitivity and our goal to make it's accuracy good - we had to spray paint the pill box.
For each ldr we "drilled" 2 holes on the back of each day of the pill box - using the old fashion "hot needle" method.
For each led we pinched twice the box with the cold needle.
For the power cable we made a hole on the back of the cardboard box.
Step 3: Circuit Diagram
As you can see in the pictures we soldered all the components as in the diagram - we did it after the pill box was painted, the ldrs was inside each day and the leds in the cardboard box as well.
In the pictures you can see just 2 of the ldrs and the leds (the lower ones represent Sunday and the top ones represent Saturday), in order to have all 7 from both just copy those in the diagram and connect them to the gap between those who appear in the diagram.
The nodeMCU will be power by a usb cable.
Step 4: Adafruit MQTT Feed
We set up 2 data feeds:
- IOP_PatientDemoPT - represents timestamps of each day when the patient took that day pills
IOP_PatientDemoHR(not implemented yet, future work) - represents BPM of the patient.
Step 5: IFTTT Configuration
We made 3 IFTTT events:
- reminder_1 - in case the daily pills have not been taken within the time-frame required, an email reminder will be sent to the user, to remind him to take his pills
- reminder_2 - in case the user has yet to take his pills, after the given time frame and after the first reminder, an email will be sent to a family member or medical assistant – informing them that the daily pills have not been taken
- fill_pill - at the end of the week, a reminder to fill up the pills for the next week will be sent to the user, including instructions of the dosages and types of pills for each day – via email
Step 6: The Code
The code is very simple and filled with helpful comments.
For your configuration make sure you changed the IFTTT and Adafruit secret keys, and the wifi configuration as well.
The state machine diagram of the code is as described in the added picture to this step.
Step 7: Extras
Challenges in the project
Do we need to ensure the pills were indeed taken? – this is a question we asked ourselves during the brainstorming process of the project, because at the end of the day, the user is a human being and not a machine, and even if there is an indication of him taking the pills out of the box, there is still a limitation on the indication whether he indeed used the pills or not.
We decided however that this question is not the main focus of our project and this device, and we focused on how to minimize the chances of a user missing a daily dose of his medicine.
Another problem we wanted to solve was ensuring a user doesn’t take pills of a different day. Our solution was a specific and clear indication of the current cell to be used, however there are better and safer solutions to ensure this mistake doesn’t happen, however we didn’t have the tools to support such solutions (e.g a lock on the cells, see future application for the project)
Our project refers to a single weekly box – one dosage of pills per day – the solution can be further extended to support several dosages of pills a day / multiple boxes
Mechanics – we didn’t use any moving parts/engines as these were not part of the course. Could have been useful in order to allow us to lock cells that are not to be used, auto-filling the cells with pills at the end of the week etc.
Future applications/improvements to the project
Heart Rate – adding a sensor to measure the patient heart rate and by pressing a button send the data to a MQTT feed for further tracking
App – a user-friendly app that controls the system - through this app the user can update the different
variables of the device:
- What time to take the pills
- Update pills types and dosages to fill
- Receive the reminders via the app
- Save data and log of drug-use.
- Order drugs through the app when finished
Extend the device to support 2 dosages a day/multiple boxes
Auto-fill of cells – by the end of the week or after the drugs have been used, the device will refill the daily cells with the drugs needed.
Lock cells that are not to be used – all cells but the daily cell to be used will be locked in order to ensure users do not accidentally take the wrong pills/overdose.
Connect device to medical/insurance companies that monitor the users, save relevant information, update subscriptions and send drugs when needed etc.