Pill Dispenser Monitor
Ever had a moment and thought did I take the pill today? Our project aims to target situation where an elderly parent/grandparent might do that mistake and take the pill of the wrong day.
What are we going to build?
We are going to take a pill dispenser and equip it with IOT technology to make sure that the right pill of the right day is taken.
How are we going to make this work?
The devices would be connected to any generic pill dispenser, to two Arduino devices connected to Blynk and Integromat to notify the family or caregiver to send a notification via Telegram.
About Us
This project is part of a college class in IOT, built by Lior Baruch and Eitan Alroy at IDC.
Supplies
Technical Supplies:
- Pill dispenser (plastic/non conductive)
- Aluminum foil
- Sellotape (duck tape)
- Acrylic core tape
- Stickers (for fun aesthetics)
- Scissors
Electronic Supplies:
- 2x Circuit Playground Express devices (or any Arduino with ESP8266 capability)
- 15x electrical wires (any kind)
- 15x connection wire with alligator clips (jumper cables)
- 7x "Pixel" colored LEDs
- 2x Batteries/micro USB cables with a power source
- Stable WiFi connection
Attach Capacity Detection (Aluminum Foil)
Take and cut the aluminum foil into pieces that match the size of each pill cell.
Now using tape, glue the each of the pieces to the top of each of the pill cells.
Then you may take the same colored sticker as the pill dispenser and cover the taped aluminum foil with stickers and leave only the tips uncovered by the sticker that a small amount of aluminum is still sticking out.
Prepare and Setup LEDs
Now take 7 LEDs and 14 wire cables (must be conductive) and attach to each side of the LED one of the wires.
We recommend that you use color coding, so that the side of the ground (-) and the side of the voltage (+) should be a different shade of colors, personally we used dark and blue colors to denote grounding and bright colors to denote voltage, very important make sure the left is voltage.
Attach LEDs to Pill Dispenser
After you have 7 sets of LEDs attached with wires, you can take the pill dispenser and place it on the side so the back would be facing upwards, then placing each of the LEDs on each of the cells.
Important, now wrap from one side to the other with clear/duck tape then when all the LEDs are attached to the dispenser, double wrap it in a circular covering each of the attachments with dual layer of tape.
Bind Pill Dispenser to Place
After combining the LEDs and attaching them to the pill dispenser, we are going to attach it to the table.
First, place on the table double sided tape in where you would like the device to stay, second place the pill dispenser (w/combined wires) on the tape, third take the wires duck tape (or use strong adhesive tape) them to the back side of the table.
Make sure the device is very stable on the table, and the wires are easily accessible from the bottom of the table.
Setup Blynk Application
To start using the application:
1. Download Blynk App: http://j.mp/blynk_Android or http://j.mp/blynk_Android
2. Touch the QR-code icon and point the camera to the code below
3. Test the app with the Arduino
You will see on the dashboard the following widgets:
1. Big button with the text "no problem", this will set or reset the flag that notifies if the patient took the wrong.
2. Small clear button with the text "Clear" that will reset all flags including the status of the pill taken today.
3. Temperature Gauge is the circular indication to notice the current temperature of the pills and the dispenser.
4 + 5. Webhooks with the URL to Integromat (place the hook from the following step https://hook.integromat.com/...) and use the following JSON as put function:
- pill webhook: {"right_pill":/pin[0]/, "wrong_pill":/pin[1]/, "end_day":/pin[2]/}
- temp webhook: {"temperature":/pin[0]/, "temp_status":/pin[1]/}
6. RTC - Real-Time Clock settings and set the time-zone to the place you are in right now.
7. Simple status LED to indicate the current pill situation.
Make sure you copy the authentication key into the attached code! indicated in --insert Blynk authentication here--
Insert your router Wifi name (SSID) in --insert Wifi SSID here--, then insert your Wifi password in --insert Wifi password here-- in the code.
Use the following virtual pins in your setup in Blynk (they should already be setup correctly in the code and in the project):
V0 - Post (Current Temperature, Temperature Status), V1 - Temperature Value Blynk
V2 - Post (Right Pill, Wrong Pill, End Day), V3 - Receive Wrong Pill, V4 - Reset Pills, V5 - Pill Status
Setup Integromat Scenario
Integromat could be a tricky part to setup so follow those steps closely:
- Create a new scenario
- Add a Webhook (copy the link to the Blynk webhooks from the previous step)
- Add a Router
- ->Go to Google Sheets and create a Spreadsheet, then create three sheets in that document.
- Do the following steps to a different rout in the router
- 4xGoogle Sheets, Filtered by:
temp_status
right_pill
wrong_pill
end_day
For each of them add the date as first value of the row: {{formatDate(now; "YYYY-MM-DD HH:mm:ss"; "Asia/Jerusalem")}}
To the second and third the pill flag/temperature flag.
- 4xTelegram, such that each sheet will later be connected to a telegram bot message*.
* To set up a telegram bot:
- Open the Telegram Messenger application
- Enter @Botfather in the search tab and select it
- Click “Start” to activate BotFather bot
- Choose or type the /newbot then click send.
- Choose a name to your bot.
- Choose a username with _bot ending.
- Take the authentication token and copy it to the "connection" settings in Integromat
- Create a group and add the bot to the group
- Copy the chat ID and place it into the chat ID section in Integromat
Circuit Playground Devices Upload and Attach Wires
Take the two Arduino Circuit Playground Devices (working with ESP8266, see pictures for schema), for one upload "Part 1 Touch Monitor" and for the other upload "Part 2 LED Control" of the attached code files (make sure you changed the Auth, SSID and Password in the code to yours!!).
Take device "Part 1 Touch Monitor" and attach an alligator clip (jumper) to each of the pins and the other side of the clip to the tip of the aluminum foil (start from A0 for Sunday, A1 for Monday,..), when you are done, attach the Arduino device itself and stick it firmly to the table.
Take "Part 2 LED Control" and attach an alligator clip (jumper) to each of the pins and attach the other side to the voltage of the electric wires attached to the LEDs in the pill dispenser, connect all the ground wires of the LEDs together and attach them to a side of an alligator clip and using the other side of the alligator clip attach it to the GND pin on the device, finally attach the Arduino device itself and stick it firmly to the table.
Test Device and Make Sure Connection Works!
When you are done, open the Blynk app, and turn on the scenario in Integromat then test each device in the following manner:
For device "Part 1 Touch Monitor", test the following four scenarios, that the device without touch is blue, then touch the correct day pill cell wait a few seconds and get an alert and the device LEDs and Blynk LED status turns green (including in telegram) for a correct pill taken, reset and test the wrong pill wait a few seconds then get an alert and the device LEDs and Blynk LED status turns yellow, finally you can turn up the heat and check if the overheat sensor is detected and shows red, then you cool the room and it should set itself back to blue (make sure the pill and dispenser is placed in a shaded place for the pills to be blemished).
For device "Part 2 LED Control", the test is much more simple, just check the number of Neopixels turned on correspondence to the current day and make sure the LED connected to the correct pill cell is the only one turned on (it is recommended to check that each of the pill cells LED is attached by order by manually moving it temporary to the current day and back to it's intended pin).
If everything works, you are done, congrats, now you can use it to help monitor the pills of your dearest in need.