Introduction: IoT Pill Bottle
This Instructables show how to build a IoT pill bottle prototype.
This is my colleague, Roy's idea, I just help him PoC.
This IoT bottle use 2 type of sensors for helping doctor and patient:
- A cap button for detect pill bottle opened, it help to monitor the time pattern of patient take the pill
- An IR sensor for detect the pill fill status, it help to alert the refill schedule
Step 1: Preparation
- ESP8266 board, ESP-07 or 12E should be ok
- USB to TTL converter (for reprogramming ESP board)
- A small Lipo battery, I use 302020 this time
- A pill bottle with a cap big enough to squeeze all components
- A pair of IR emitter and receiver
- 2 switches for changing program mode and switching Lipo power
- 1 small button for detect bottle opened
- 220 Ohm resistor
- 1.0 m Ohm resistor (this value require fin tune)
- 4 pins pin socket
- 1 multipurpose PC board
- Some coated wire
- A little piece of transparent plastic plate
Step 2: Patch the Bottle Cap
Empty the cap content to free enough space for the IoT component.
Step 3: Cut a Transparent Cap Cover
We need a transparent cover at the cap bottom to seal the pill bottle but still allow IR pass through it.
Step 4: Cut the PC Board
Cut the multipurpose PC board to fit in the cap. Round shape is not essential if you found hard to make it.
Step 5: Design the Circuit
Here is the summary of the circuit:
ADC pin -> 1.0 M Ohm resistor -> GND (pull down)
-> IR sensor -> Vcc
EN pin -> Vcc
GPIO 13 pin -> Cap opened detector (button)
VCC pin -> Vcc
Tx (GPIO 1) pin -> IR emitter -> 220 Ohm resistor -> Vcc
GPIO 0 pin -> program switch -> GND
GPIO 15 pin -> GND
GND pin -> GND
+ve -> Vcc
-ve -> power switch -> GND
Step 6: Install the Cap Opened Detector
This cap have some elastic, when the cap close, it will squeeze a little bit. I will use this feature to detect the cap opened.
Cut the PC board a little bit then place the button between the cap and the PC board. Check the gap between the button and the cap and use some plastic to fill the gap.
Then solder the button on the PC board.
Step 7: Assembly
Use a sponge double side tape insulate between ESP board and PC board. Then solder all component according to the circuit designed.
IR emitter and receiver face bottom and the Lipo also put at the bottom and help to separate the IR emitter and receiver.
The 4 pins pin socket connect to Vcc, GND, Tx and Rx. This can help you reprogram the ESP board. The Vcc and GND pins also can help you connect external Lipo charger to charge the Lipo battery.
Step 8: Program ESP Board
If you not yet have Arduino with ESP support, try to follow this Instructables:
Download my sample code from Github:
Change your AP name and password. And optional, if you have already register ThingSpeak, fill your API details. Then switch on the program switch, connect the USB to TTL converter, then upload the sketch.
Switch off the program switch and reconnect the power for resetting the ESP to normal run.
Step 9: Happy IoT!
You may goto my ThinkSpeak channel to see the bottle real time status. (If I turned on the power)
Step 10: What's Next?
This prototype is only for PoC, there are still many thing in the todo list, e.g.:
- add 3.3V regulator between Lipo battery and ESP board
- add resistors in all pull up and pull down circuit
- adjust the IR sensor circuit, such as the pull down resistor value
- ESP deep sleep coding still in progress
- for the real use case, the clinic or hospital require build their own IoT server
We have a be nice policy.
Please be positive and constructive.