EN2853 - Embedded Systems and Applications | Semester 4 Project
MediBox is an intelligent embedded system designed to manage and monitor medicine dispensing and storage conditions. Built around the ESP32 platform, it integrates environmental sensing, actuator control, real-time scheduling, and an IoT dashboard via Node-RED using MQTT communication. The goal is to assist users—especially the elderly or chronically ill—in maintaining timely medication habits while monitoring the surrounding environment.
-
🌡️ Environmental Monitoring
- DHT22 sensor tracks temperature and humidity inside the medicine box.
- Light intensity sensing with LDR to detect ambient conditions.
-
⚙️ Servo-Controlled Dispenser
- Servo motor dynamically adjusts based on light, temperature, and configurable thresholds.
-
⏰ Alarms & Scheduling
- Multiple daily alarms with options to snooze or delete via button interface.
-
🖥️ OLED Status Display
- 0.96" OLED screen shows real-time temperature, time, alarm notifications, and system status.
-
📡 MQTT Integration
- Publishes sensor data and receives real-time parameter updates using MQTT topics.
-
🌐 Node-RED Dashboard
- Visualizes sensor data and allows real-time parameter tuning remotely via web interface.
- ESP32 Dev Board
- DHT22 Temperature and Humidity Sensor
- LDR (Light Dependent Resistor)
- SG90 Servo Motor
- 0.96" OLED Display (128x64 I2C)
- Buzzer
- Push Buttons (Menu navigation, Acknowledge, Snooze/Delete)
- LEDs (System and Alarm indicators)
- 5V Power Source / USB
-
Development Tools
- Arduino IDE or PlatformIO
- Node-RED for Dashboard
- MQTT Broker (e.g., Mosquitto, HiveMQ Cloud)
-
Key Libraries
Adafruit_SSD1306,Adafruit_GFXDHTespPubSubClientArduinoJsonESP32Servo
MediBox/
├── src/
│ └── main.cpp # Main firmware source code
├── Node-RED/
│ └── flows.json # Dashboard flow for Node-RED
├── platformio.ini # PlatformIO config (if used)
└── README.md # This file
-
Startup Initialization
- Connects to WiFi and MQTT broker.
- Initializes sensors, OLED, and actuators.
- Publishes initial parameter settings.
-
Sensor Sampling & Actuation
- Periodically reads DHT22 and LDR values.
- Computes new servo position based on parameters (e.g., temperature thresholds, gamma scaling).
- Triggers alarm buzzer and updates display when alarm time matches.
-
MQTT Communication
- Publishes:
- Sensor Data →
medibox/sensor_data - Parameters →
Medibox/ts,Medibox/tu, etc. or combined as JSON atMedibox/params
- Sensor Data →
- Subscribes:
- Parameter updates from Node-RED → changes are applied live.
- Publishes:
-
Node-RED Dashboard
- Visual elements: gauges, charts, sliders, and fields.
- Users can remotely:
- View live data (temperature, humidity, light)
- Adjust parameters like
ts,tu,gammaValue,Tmed, etc. - Monitor system status
-
Import the flow:
Node-RED/flows.json -
Configure MQTT broker settings in both firmware and Node-RED.
-
The dashboard displays:
- 🔢 Sensor values in real-time
- 🎛️ Live-configurable parameters
- 📝 System configuration summary
- Ensure all components are wired correctly.
- Use the Serial Monitor to check for connectivity/debug messages.
- Confirm broker credentials and topic names match.
- Use Node-RED’s debug panel to inspect incoming MQTT messages.
Pasindu Dodampegama
Department of Electronic and Telecommunication Engineering
Faculty of Engineering, University of Moratuwa