Skip to content
← Projects
Embedded / IoT2025Complete

MediBox: A Smart Medicine Box

An ESP32 pill box that keeps its own time from the internet, rings for each dose, and watches the temperature and humidity its contents are stored at.

  • ESP32
  • C++ / Arduino
  • PlatformIO
  • Wokwi
  • SSD1306 OLED
  • DHT22
  • NTP

The idea

A pill box that remembers doses for you is only useful if it is right about the time - and a microcontroller has no idea what time it is when you switch it on. MediBox gets that from the internet, keeps two alarms, and, because a lot of medicine is fussier about storage than people realise, also watches the conditions inside the box.

What it does

Knows the time without being told. On boot it joins Wi-Fi and asks an NTP server, then stays on that reference. The time zone is set on the device itself, in half-hour steps - an offset in whole hours would exclude Sri Lanka, which sits at UTC+5:30, along with India, Iran and parts of Australia.

Rings, and takes no for an answer twice. Two alarms, each with its own hour and minute. When one fires, an LED lights and the buzzer plays a rising eight-note melody rather than a flat beep, so it reads as a reminder and not a fault. OK dismisses it; Cancel snoozes for five minutes, rolling the hour over correctly when the snooze crosses the top of one.

Watches the storage conditions. A DHT22 reads temperature and humidity, and the box warns when either leaves the band medicine wants - the display names which one, and the LED comes on.

Fits on four buttons. Everything - set the time, set or disable either alarm, review or delete alarms, change the time zone - runs through a menu on a small OLED driven by OK, Cancel, Up and Down. No app, no phone, nothing to pair.

How it is built

C++ on an ESP32, split into modules with their own headers rather than one long sketch: time, alarms, sensor, display, buttons and Wi-Fi each own their file, which is what makes a seven-item menu tractable.

Built with PlatformIO, and developed against a Wokwi simulation of the whole circuit - breadboard, OLED, buzzer, buttons, LEDs and all - checked into the repo as diagram.json. Being able to run the firmware before the hardware existed, and to hand someone else a circuit that boots in their browser, is worth the small effort of keeping that file honest.