A real-time IoT health monitoring system that collects vital signs (heart rate, SpO₂, temperature) from wearable sensors, and logs all data to a Flask-based web dashboard for visualization and analytics.
| Component | Function |
|---|---|
| ESP8266 | WiFi microcontroller (data transmission) |
| MAX30100 | Heart rate and SpO₂ sensor |
| DS18B20 | Digital temperature sensor |
| Buzzer | Audio alert in case of abnormal values or fall |
| Power | 3.3V regulated supply |
📄 Refer to hardware setup guide for circuit connection and Arduino IDE configuration.
-
Sensor Data Collection
ESP8266 reads from:- MAX30100 →
Heart_rate,SpO₂ - DS18B20 →
Temperature
- MAX30100 →
-
Alert System
- If any vital drops below threshold or is detected → buzzer rings.
- Simultaneously, Telegram bot sends alert to caretaker.
-
Data Transmission
- ESP8266 sends data to Flask server via HTTP POST (
/add_log) endpoint.
- ESP8266 sends data to Flask server via HTTP POST (
-
Web Dashboard
- Web UI shows real-time logs and plots (heart rate, SpO₂, temperature).
- Alerts are also logged and visualized for analytics.
Backend: Flask + MongoDB
Frontend: HTML + Chart via Matplotlib
Data Storage: MongoDB (Local/Cloud)
IoT Firmware: Arduino (C++)
git clone https://github.com/LegitCoconut/health-monitor.git
cd health-monitorInstall virtual environment (optional but recommended):
python3 -m venv myenvActivate it:
-
Linux/macOS:
source myenv/bin/activate -
Windows:
myenv\Scripts\activate
pip install -r requirements.txtclient = MongoClient("mongodb://localhost:27017/")Set this as an environment variable:
export MONGO_URI="your_mongo_connection_string"On Windows (CMD):
set MONGO_URI="your_mongo_connection_string"You can also create a
.envfile and load it manually.
python app.pyFlask app will run at: http://localhost:5000
To simulate sensor data:
python test.py- Fork or push the project to your GitHub account.
- Login to Vercel, import the GitHub repo.
- In Project Settings > Environment Variables, add:
| Key | Value |
|---|---|
MONGO_URI |
your MongoDB connection URI |
- Set Framework Preset as
OtherorFlask. - Vercel will auto-deploy your project.
⚠️ Note: Vercel is for frontend apps. For backend Flask, use Render, Railway, or deploy on VPS (DigitalOcean, EC2, etc.).
Receives JSON data from ESP8266:
{
"Heart_beat_rate": 80,
"Sp02_level": 96,
"Temperature": 36.5,
"time_of_check": "2025-04-04T12:30:00"
}Inserts into MongoDB:
logs_collection.insert_one(data)Calculates average, peak, and low values for each vital using:
def compute_stats(field):
...Generates time-series graph using matplotlib, returns image as PNG:
plt.savefig(img_io, format='png')
return send_file(img_io, mimetype='image/png')| Endpoint | Description |
|---|---|
/ |
Main dashboard (index.html) |
/get_logs |
Returns all logs (JSON) |
/add_log |
Accepts data from device (POST) |
/stats |
Returns statistical metrics |
/generate_graph |
Returns graph (PNG image) |
health-monitor/
│
├── app.py # Main Flask backend
├── test.py # Dummy data injector
├── requirements.txt # Python dependencies
├── templates/
│ └── index.html # Web dashboard UI
└── static/ # (Optional CSS/JS)- Validate incoming sensor data types.
- Use
.envfor secrets like DB credentials. - Add basic auth to dashboard (Flask-login or JWT).
- Secure MongoDB with IP whitelisting or VPN.