Hereβs the fully translated and polished English version of your documentation β formatted cleanly for GitHub (Markdown-ready). All technical terms are kept accurate, and phrasing is natural for professional English README files.
A real-time medication management system built with IoT, AI, and a web dashboard.
- Pill detection using load cell and IR sensors
- Real-time MQTT communication between ESP32 and backend
- Web dashboard built with React and TailwindCSS
- Local SQLite database for lightweight storage
- JWT authentication for secure access
- Real-time alerts via MQTT
- Live charts for medicine event visualization
ESP32 (Firmware)
β MQTT
Backend: Node.js (Express + MQTT + SQLite)
β REST API
Frontend: React (Dashboard)
- ESP32 DevKit
- Load Cell (HX711 + Sensor) or simulated input
- IR Sensor (optional)
- WiFi connection
- Node.js 16+
- npm or yarn
- PlatformIO (for ESP32 firmware)
- Mosquitto MQTT Broker (local or remote)
- Python 3.8+ (for PlatformIO support)
# Backend
cd backend
npm install
cp .env.example .env
# Edit .env with your settings
# Frontend
cd ../web
npm install# Download and install: https://mosquitto.org/download/
# or via Chocolatey:
choco install mosquitto
# Start broker (usually runs as a service)
# or manually:
mosquitto -c mosquitto.conf# Install
sudo apt-get install mosquitto mosquitto-clients # Ubuntu/Debian
brew install mosquitto # Mac
# Start broker
mosquitto -c /etc/mosquitto/mosquitto.conflistener 1883
allow_anonymous trueEdit backend/.env:
PORT=3000
MQTT_BROKER=mqtt://localhost:1883
JWT_SECRET=your_jwt_secret_hereStart the backend:
cd backend
npm startCreate web/.env:
REACT_APP_API_URL=http://localhost:3000/api
REACT_APP_MQTT_BROKER=ws://localhost:9001Note: For MQTT WebSocket communication, enable WebSocket support in Mosquitto:
listener 9001 protocol websockets
Start the frontend:
cd web
npm start-
Install PlatformIO (VS Code extension or CLI).
-
Edit
firmware/esp32/src/main.cpp:- Set
YOUR_WIFI_SSIDandYOUR_WIFI_PASSWORD - Update
mqtt_serverto your MQTT broker IP - Adjust
device_idif needed
- Set
-
Build and upload:
cd firmware/esp32
pio run -t upload
pio device monitormedimind-pro/
βββ firmware/
β βββ esp32/
β βββ platformio.ini
β βββ src/
β βββ main.cpp
β βββ sensors.cpp
β βββ sensors.h
β βββ wifi_mqtt.cpp
β βββ wifi_mqtt.h
βββ backend/
β βββ index.js
β βββ db.js
β βββ mqtt.js
β βββ api.js
β βββ package.json
β βββ .env.example
βββ web/
β βββ src/
β β βββ App.jsx
β β βββ components/
β β β βββ Login.jsx
β β β βββ Dashboard.jsx
β β β βββ EventList.jsx
β β β βββ StatsCard.jsx
β β β βββ AlertButton.jsx
β β β βββ RealTimeChart.jsx
β β βββ services/
β β βββ api.js
β β βββ AuthService.js
β β βββ mqttService.js
β βββ package.json
β βββ tailwind.config.js
βββ README.md
# Terminal 1: MQTT Broker
mosquitto -c mosquitto.conf
# Terminal 2: Backend
cd backend
npm start
# Terminal 3: Frontend
cd web
npm start-
Open
http://localhost:3000 -
Register with:
- Username
- Password
- Device ID (must match ESP32
device_id)
- Ensure ESP32 is connected to WiFi
- Verify it connects to MQTT broker
- Pill events will be published automatically
- Dashboard displays real-time pill events
- Charts auto-update
- Alerts can be sent manually from the βSend Alertβ button
POST /api/registerβ Register a new userPOST /api/loginβ Log in
GET /api/eventsβ List all events (requires auth)GET /api/statsβ Retrieve event statistics (requires auth)
POST /api/alertβ Send alert (requires auth)
| Topic | Description |
|---|---|
medibox/<device_id>/event |
Pill events (published by ESP32) |
medibox/<device_id>/alert |
Alerts (subscribed by ESP32) |
- JWT authentication for all protected routes
- Passwords hashed with bcrypt
- CORS configured for frontend
- Input validation on all backend routes
- Check WiFi credentials in
main.cpp - Ensure the WiFi network is 2.4GHz (ESP32 doesnβt support 5GHz)
- Verify Mosquitto is running
- Check broker IP in
main.cpp - Confirm port 1883 is open
- Ensure MQTT broker is active
- Check ESP32 connectivity
- View backend logs for errors
- Confirm WebSocket is enabled in Mosquitto
- Verify
REACT_APP_MQTT_BROKERin.env - Ensure port
9001is open
- TensorFlow Lite Micro integration for pill recognition
- Push notifications
- Medication history view
- Reminder scheduling
- Multi-device support
- Mobile-friendly dashboard
- Data export (CSV/PDF)
- Integration with health APIs
MIT License
Contributions are welcome! Please open an issue or pull request in the repository.