Medkit

Hello i'm Lee De Smedt, i am a first year student at howest MCT and for project one i made this smart pill dispenser. This project named Medkit is as previously mentioned a smart pill dispenser. I made this with caretakers in mind, they already have a busy schedule so this will help get the medication to their patients on time and prevent double dosing
Supplies
- Raspberry Pi (main controller)
- RFID sensor (user identification)
- Ultrasonic sensor (detects container presence)
- RTC Module DS1307 (real-time clock for timing)
- 4 x Servo motor (mechanical movement)
- LCD display (user interface)
- Power supply (for Raspberry Pi)
- Jumper wires (pack of 40)
- Enclosure/case (to house components)
- Resistors (for circuit protection)
Making the Database

Database Summary for Instructables
This database is designed for managing patient care, specifically focusing on medication administration, patient information, caregivers, and component tracking. Here’s a clear overview of the structure and relationships:
Main Entities and Their Purpose:
- patient: Stores patient information such as name, address, city, date of birth, assigned caregiver, room, RFID tag, and gender.
- verzorger: Contains caregiver details, including name, address, city, and date of birth.
- medicatie: Holds information about medications, including name, type, purpose, and comments.
- patientmedicatie: Links patients to their medications, specifying dosage, comments, and time of administration.
- component: Represents hardware or device components, detailing name, brand, type, and unit of measurement.
- historiek: Tracks the history of actions performed on components, recording the action, date/time, and value.
Key Relationships:
- Each patient is assigned to one verzorger (caregiver).
- Each patientmedicatie entry links a patient to a specific medicatie (medication), allowing for many-to-many relationships between patients and medications.
- component and historiek work together to log actions and changes related to system components.
Circuit

In the attached files are the fritzing files so you can more easily rebuild the circuit
Code
Key Features Overview
app.py
- Patient and Caretaker Management
- Add, update, and retrieve patient details.
- Assign patients to specific caretakers.
- Fetch all patients for a given caretaker.
- Retrieve caretaker information by ID.
- Medication Management
- Add new medications and update existing ones.
- Link medications to patients.
- Retrieve all medications or medications for a specific patient.
- Medication History Tracking
- Log and retrieve medication intake history.
- Track when and if medication was dispensed and taken.
- Hardware Integration
- Uses Raspberry Pi GPIO for real-time hardware control (e.g., dispensing medication, reading RFID tags, measuring distance).
- LCD display for feedback and status messages.
- Servo motor control for dispensing mechanism.
- RFID Authentication
- Identify and authenticate caretakers using RFID cards.
- Display personalized welcome messages on the LCD upon successful login.
- Real-Time Communication
- Uses Socket.IO for real-time updates (e.g., distance sensor changes, time updates, RFID scans) between the hardware and the web interface.
- Background Tasks
- Runs continuous background threads for hardware monitoring and event handling (e.g., distance measurement, time reading, RFID scanning).
- Logging and Error Handling
- Centralized logging for debugging and monitoring.
- Robust error handling in API endpoints.
app.js
1. Real-Time Communication
- Uses Socket.IO to connect to a backend server for live updates (e.g., time changes, RFID login/logout, container detection).
2. User Authentication and Session Management
- Handles caretaker login/logout using RFID and manages session data in localStorage.
3. Patient and Caretaker Display
- Fetches and displays the current caretaker’s name.
- Retrieves and lists all patients assigned to the logged-in caretaker, including details like name, age, gender, room, next medication time, and delay status (late or early).
4. Patient Details and Medication
- Shows detailed information about a selected patient (name, gender, address, age, room).
- Fetches and displays the patient’s prescribed medications, including dosage and scheduled times.
5. Medication History
- Retrieves and displays the medication intake history for patients, allowing caretakers to check off if medication was taken.
6. Medication List
- Lists all available medications and their purposes, with options to edit entries.
7. Hardware Integration
- Reacts to hardware events, such as:
- Detecting if a medication container is present (distance sensor).
- Updating the UI based on container status.
8. Adding New Patients
- Provides a form for caretakers to admit new patients, sending the data to the backend API.
9. UI Interactivity
- Dynamically updates UI elements based on data from the backend and hardware events.
- Enables or disables buttons based on medication selection.
10. Modular Initialization
- Runs different logic depending on the current page (login, home, patient detail, history, medication list, add patient).
Design of Medkit



These pictures give you an idea on which measurements you need to make Medkit. the measurements are:
- height: 35cm
- width: 45cm
- depth: 30cm
All panels are made with wood, screwed together with woodscrews
Making the Lower Half









I started with making the bottom half. My father helped me with this, i'm not very handy. it is in a U shape to accommodate the ultrasonic sensor in the side. the panels are cut from a larger panel with an electric saw. the sides are connected with metal plates.
Making the Upper Half








After the bottom half i made (again with the help of my father) the upper half where the containers reside. The servo's, lcd and rfid-reader also go here. we made a fake wall to hide the screws from the outside and we added hinges for the top panel so there's access to the pills and servo's.
Integration of Circuit Into Medkit





now you can start integrating the circuit with the wooden casing. place the different components in the cutouts and screw them in place.
Finishing Touches




Now you can put both halves together and add the locks on the side to hold the top part shut and the clips in the middle over the separation to lock both halves together.
Github

here you can find all the code for medkit.