Intro: Smart Pill Box (IDC2018IOT)
This is Jonathan Braslaver and Maor Stamati Final project in IDC's IOT course of 2018.
In this Instructable you will walk through
the steps to build an IoT smart pill box. This is a fully working prototype with the following features:
1. It sends SMS to the user if the temperature or humidity in the box is too high.
2. It lights a led in the right pill compartment when it’s time for the user to take his pills.
3. The led turns of when the user takes his pills from the compartment.
4. If the user forgets to take his pills, after an hour a reminder SMS is sent.
5. Send a reminder on Saturdays to fill the box again.
We hope this product can reminder people to take their medicine on time, and help them keep it in the right conditions.
Step 1: Parts:
1. Node MCU board.
2. dht22 temperature and humidity sensor
3.MPR121, Proximity Capacitive Touch Sensor Controller
4. 7 simple leds.
9. Duct Tape.
10.A box with 7 comparments.
Step 2: Create Pill Taking Scheudle File
The the file is in json format,
its an array of arrays ,
each array is a day of the week, meaning the array at 0 is sunday and the array at 5 is Friday.
The elments of the array are string of the form "HH:MM" like "14:00".
You can create the file mannauly or progmatticaly with your favorite method.
keep the path of the file in your computer as we will need it for later.
Step 3: Connect the Board and Components:
1.Cover the inside of each pill comparment with tin foil, make sure they don't touch each other.
The tin foil will act as conductor, so when you take a pill and touch the compartment the copacitance sensor will act.
2.follow the attached schema:
(it currently supports only 5 leds, you can add more with a mux )
3. paste the leds behind each compartment.
4. connect entries 0-6 of the MPR121 to each compartment tin-foil.
Step 4: Create Io.adafruit Account
io.adafuit will let you use their MQTT server for free!
Go to https://accounts.adafruit.com/users/sign_up and sign up,
create the following feeds as seen in the image.
than copy your AIO KEY.
Step 5: Load Code Into Your Board.
make sure to set your adafruit mqtt server details here:
//MQTT SERVER CONFIG
#define AIO_USERNAME "your user name"
#define AIO_KEY "your key"
and your wifi details :
#define WLAN_SSID "network name"
#define WLAN_PASS "password"
Step 6: IFTT
IFTTT (IF This Then That) is a free web-based service to create chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Telegram, Instagram, or Pinterest.
We will use IFTT to create webhook which when called by HTTP rest will send an SMS to the user.
1. create am IFTT account.
2. Click on "My Applets" and than on new Applet, and chooe Webhooks as the first part, for the second use SMS.
3. see the configurations from the picture.
Step 7: NodeRed
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.
- Download and follow installation instructions from https://nodered.org/.
- Launch node-red from
- Download the nodes.json file and replace the following:
- IFTTT_KEY with your IFTTT key
- IFTTT_USER with your IFTTT user name
- PATH_TO_File with the path of the schedules file.
- click on the top right corner -> import -> clipboard and paster the content of the attached nodes.json file
The result should look like the attached picture.
5 flows will be created:
1.run every 10 minutes -> read the schedule file -> convert to js object -> check if you need to take a pill in the next 10 minutes -> limit to 1 msg per 10 minutes -> send the day code -> mqtt publish to the led feed.
2.get the day of the week -> if saturday HTTP call to IFTT to send SMS to the user to fill the pill box.
3. listen on mqtt humidity feed -> limit for one msg every 3 hours -> add the humidity to the IFTTT url -> call IFTTT to send SMS.
4. 3. listen on mqtt temperature feed -> limit for one msg every 3 hours -> call IFTTT to send SMS.
5. Listen to mqtt forgot feed -> call IFTTT to send SMS.
Step 8: Challenges & Next Step
We had some challenges using the mqttt server , first we tried to run one locally which didn't seem to work (blocked ports) so we used a cloud one.
Also we are currently limited to 5 leds where we need 7, we tried using a mux but it also didn't seem to work.
Fully functional UI to schedule the pill taking time.
Get a fancier pill box without tin foil and the board hidden.
We hope you find our instrictions useful and enjoy building this project!