Case study
Medication reminder
An ESP32 medicine box that alarms on a schedule, treats nearby motion as a taken dose, and posts temperature, dose, and help events to ThingsBoard.
DS3231 + PIR + DHT22 → ESP32 → HTTP → ThingsBoard
- Record
- Public repository, and a completed Upwork contract
- When
- Upwork contract 21 Jun 2024 to 28 Sep 2024
- Stack
- ESP32, ThingsBoard, WiFiManager, I2C
- Hardware
- ESP32 WROVER · DS3231 RTC · 20x4 I2C LCD · DHT22 · PIR · Buzzer and three LEDs
- Links
- GitHub
The problem
A reminder that only works while a phone app is open misses the point. The box has to know the time with the network down, make a noise at the dose hour, and give a caregiver a signal when the person needs help.
What I built
The public firmware runs on an ESP32 WROVER. A DS3231 keeps time. A 20x4 I2C LCD shows the clock, the next dose, temperature and humidity, and the active alert. At each scheduled hour the buzzer and one LED fire. A PIR looking at the box is the stand-in for “dose taken”: motion during an active alarm silences it and posts a med_taken event. A long press on the button posts help_request and lights every LED.
Temperature and humidity from a DHT22 go out every 60 seconds. The LCD labels the room Good, Low T, High T, Low H, or High H from fixed bands (15-35 °C and 35-70% humidity).
The same product is the completed Upwork job “Arduino IoT Smart Medicine Box Project”, rated 5.0. The client wrote: “Great working with Roshan, exceptionally talented on Arduino and IoT projects.”
Decisions
Time comes from the RTC, not from NTP, so a dose still happens if Wi-Fi is down. The schedule is a list of hours in the firmware, one LED pin per slot.
Wi-Fi uses WiFiManager. Holding the button at boot opens a captive portal and the saved network can be replaced. The portal times out after 240 seconds.
Telemetry is HTTP POST to ThingsBoard, three payloads: environment, dose taken, and help. The README for this repo calls out that the token is hard-coded and that MQTT with TLS is the production transport if this moves past a prototype. I am not claiming this build already uses TLS.
The PIR is a proxy for a taken dose. It is not a sensor that identifies a pill.
Pins
Buzzer GPIO 13, DHT22 GPIO 32, PIR GPIO 27, button GPIO 18, dose LEDs GPIO 26, 25, and 33. The LCD and the DS3231 share I2C on GPIO 21 and 22.
“Great working with Roshan, exceptionally talented on Arduino and IoT projects.”