SYSTEM INTEGRATION

MediBee

Mood Board

Mood Board
MediBee Mood Board

Image Credits

User Flow Diagram

User Flow Diagram

Functionality Diagram

Functional Diagram

The hardware is a custom PCB built around a XIAO ESP32C6, driving a 28BYJ-48 stepper motor (rotating a medication disc), a servo (controlling the dispensing gate), a solenoid lock, a passive buzzer, and an SSD1306 OLED display.

On the software side, a React Native Android app communicates with the device over WiFi via a REST API hosted on the ESP32.

Each subsystem had been developed separately across previous weeks. System integration meant wiring them into a single enclosure, resolving hardware conflicts, and validating end-to-end behaviour from the phone app down to physical actuation.

System Architecture

The full system has four layers:

Integration Order

  1. Mechanical assembly — build the pill wheel, gate, solenoid-locked door, and enclosure, and check that they move freely by hand before any motor is attached.
  2. Electronics bring-up — power the PCB and test the stepper driver, servo, solenoid, OLED, buzzer, and Hall sensors one at a time, off the bench, before combining them into one sketch.
  3. Firmware bring-up — flash the combined firmware and check WiFi connection, NTP time sync, and every REST endpoint with a plain HTTP client (browser or curl), before the app is involved at all.
  4. App integration — point the React Native app at the device's IP and walk through each screen (Home, Schedule, History, Settings) against the real device.
  5. End-to-end validation — run full day-long dispense cycles and repeated manual dispenses to check timing accuracy, missed-dose detection, and mechanical reliability.

Mechanical Integration

The enclosure was designed in Fusion 360 and printed in PLA..

Disc and Motor Alignment

The medication disc was designed to rotate on a 8 mm steel rod. But there was a worry that it'll slip under the load. So I made a hole to put nails into the disc. So the disc is securely attached to the motor shaft. Under the same hole, I put another one to attch a magnet. This magnet is used for homing the disc.

The Stepper motor will rotate only once during the day. Preferable in the morning, right before the first dose.

Disc and motor alignment

Then I made a mokeup in 3D printer.

Initial Mechanism designing and testing

This was the cardboard mokeup I made first. This made me decide that the diameter of the pill case was too large.

Initial mechanism design

Servo Gate Mechanism

The servo controls the dispensing gate, a hinged flap that opens to drop a pill into the output chute.

Servo gate mechanism

With this mechanism, I can control which slot must dispense at one time. From the image, you can see that the compartment at the center is not covered. This dispenses the morning dose.

At noon, the servo rotated the door to the center, which opens the compartment at the side, and the noon dose dispenses.

Solenoid Mounting

The solenoid lock is mounted to the enclosure using two M2 screws through a printed bracket. Getting the angle right was important. If the solenoid was even slightly off, the plunger would catch on the latch instead of sliding through cleanly.

Solenoid mounting

When the solenoid is activated, the plunger retracts and releases the door. The servo rotates the other door to the center. Then rotates back to the original position, which opens the compartment at the side, and the noon dose dispenses.

This is possible by attaching magnets to the side of the doors.

Wire Routing

This was the hard part. The PCB, stepper motor, servo, solenoid, buzzer, OLED, and Hall sensors together produce about 30 cm of wiring inside the enclosure.

Solenoid mounting

I added slots in the side of the lower half to mount the main PCB.

I imported the 3D design from Kicad and added it to the enclosure.

Solenoid mounting

Enclosure

The enclosure is a two-part 3D-printed shell in PLA, split into an upper half housing the disc and gate mechanism, and a lower half housing the PCB, wiring, and solenoid. The two halves are held together with Magnets.

Enclosure Enclosure Enclosure

Electronics Integration

I designed the circuit boards in Kicad.

I needed two boards. One was the main board that connects to the Stepper and Servo motors, the solenoid and the buzzer. The second was the board for the Hall Effect sensors. This board will be placed close to the magnets in the enclosure.

Main Board
Hall Effect Sensor Board

Bill of Materials

# Category Part Qty Unit Cost (INR) Subtotal (INR) Subtotal (USD) Source Link
1 MCU XIAO ESP32-S3 module 1 979 979 $10.14 Lab stock Link
2 MCU ATtiny 1624 1 139 139 $1.44 Lab stock Link
4 Electronics Schottky Diode 1 13 13 $0.13 Lab stock Link
5 Electronics MP1584EN buck converter 1 15 15 $0.16 Lab stock Link
6 Electronics SSD1306 OLED 0.96" 128x64 I2C 1 169 169 $1.75 Lab stock Link
7 Electronics 12mm tactile push button 1 3 3 $0.03 Lab stock Link
9 Electronics Active piezo buzzer 3.3–5V 1 16 16 $0.17 Lab stock Link
10 Electronics Hall Effect Sensor 1 39 39 $0.40 Lab stock Link
11 Electronics 28BYJ-48 stepper motor (5V) 4 92 368 $3.81 Lab stock Link
12 Electronics ULN2003 driver board 3 41 123 $1.27 Lab stock Link
14 Electronics Resistor 1k 5 .66 .66 $0.0068 Lab stock Link
13 Electronics Resistor 10k 2 .66 .66 $0.0068 Lab stock Link
16 Electronics Capacitor 100nF 4 5 20 $0.21 Lab stock Link
17 Electronics Capacitor 10µF 1 16 16 $0.17 Lab stock Link
Total ₹1,488 $15.41

Firmware Integration

Electronics Flowchart

Firmware Flow

This is how the firmware behaves from power-on: it connects to WiFi and NTP once, then runs a loop that simultaneously serves the app's REST requests, keeps the OLED updated, and checks every ten seconds whether a dose is due.

Mobile App

The companion app is a React Native app with four tabs — Home, Schedule, History, and Settings — that all talk to the ESP32 over the same REST API described above. It stores the device's IP address (and, optionally, WiFi credentials to push to the device) locally on the phone using AsyncStorage, so it reconnects automatically the next time the app opens.

The app polls /status every 15 seconds in the background to show an online/offline badge, independent of whichever tab is open.

Project Development
18

Project Development

Full documentation of the MediBee pill dispenser