Tuesday, 26 May 2026

AI Smart Health Monitoring System with Disease Prediction

AI Smart Health Monitoring System with Disease Prediction AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
1. Project Overview This project is an advanced AI-enabled Smart Health Monitoring System using: Espressif Systems ESP32 IoT cloud monitoring AI disease prediction logic Agentic automation using n8n Telegram voice notifications Google Sheets data logging ThingSpeak cloud analytics dashboard The system continuously monitors: Heart Rate SpO₂ (Blood Oxygen) Body Temperature ECG (optional) Blood Pressure (optional simulated) Motion/Fall Detection AI logic predicts possible diseases such as: Fever Hypoxia Tachycardia Bradycardia Stress Cardiac Risk When abnormal values are detected: ESP32 uploads sensor data to cloud n8n automation triggers AI logic Telegram bot sends: Text alert Voice alert Data stored in Google Sheets ThingSpeak dashboard visualizes health trends 2. System Architecture Sensors → ESP32 → WiFi → ThingSpeak Cloud ↓ n8n Webhook ↓ AI Prediction Logic ↓ ┌───────────────┴───────────────┐ ↓ ↓ Telegram Alerts Google Sheets Voice + Text Alerts Health Logs 3. Hardware Components List Component Quantity Purpose ESP32 Dev Board 1 Main controller MAX30102 Pulse Oximeter 1 Heart rate + SpO₂ DS18B20 Temperature Sensor 1 Body temperature AD8232 ECG Sensor Optional ECG monitoring MPU6050 Optional Fall detection OLED Display SSD1306 1 Live display Breadboard 1 Prototyping Jumper Wires Several Connections USB Cable 1 Programming 5V Power Supply 1 Power source 4. Circuit Schematic Diagram ESP32 Connections MAX30102 MAX30102 ESP32 VIN 3.3V GND GND SDA GPIO21 SCL GPIO22 DS18B20 DS18B20 ESP32 VCC 3.3V GND GND DATA GPIO4 Use 4.7kΩ pull-up resistor between DATA and VCC. OLED Display OLED ESP32 VCC 3.3V GND GND SDA GPIO21 SCL GPIO22 5. Flowchart START ↓ Initialize Sensors ↓ Connect WiFi ↓ Read Sensor Data ↓ AI Health Analysis ↓ Abnormal? ┌───────┴────────┐ YES NO ↓ ↓ Send Alert Upload Data ↓ ↓ Telegram Bot ThingSpeak ↓ ↓ Google Sheets Logging ↓ Repeat Loop 6. ESP32 Source Code (Arduino IDE) Required Libraries Install from Arduino Library Manager: WiFi.h HTTPClient.h MAX30105 Adafruit SSD1306 OneWire DallasTemperature ESP32 Code #include #include #include const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String apiKey = "THINGSPEAK_API_KEY"; float temperature = 0; int heartRate = 0; int spo2 = 0; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while(WiFi.status() != WL_CONNECTED){ delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { // Simulated Sensor Values temperature = random(36, 39); heartRate = random(60, 130); spo2 = random(85, 100); Serial.println("Uploading Data"); if(WiFi.status()== WL_CONNECTED){ HTTPClient http; String url = "http://api.thingspeak.com/update?api_key=" + apiKey + "&field1=" + String(temperature) + "&field2=" + String(heartRate) + "&field3=" + String(spo2); http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); http.end(); } // AI Alert Condition if(temperature > 38 || spo2 < 90 || heartRate > 120){ sendAlert(); } delay(15000); } void sendAlert(){ HTTPClient http; String webhook = "YOUR_N8N_WEBHOOK_URL"; http.begin(webhook); http.addHeader("Content-Type", "application/json"); String json = "{"; json += "\"temperature\":" + String(temperature) + ","; json += "\"heartRate\":" + String(heartRate) + ","; json += "\"spo2\":" + String(spo2); json += "}"; int response = http.POST(json); Serial.println(response); http.end(); } 7. Disease Prediction Logic AI Rule-Based Prediction Condition Prediction Temp > 38°C Fever SpO₂ < 90% Respiratory Risk HR > 120 Tachycardia HR < 50 Bradycardia Temp + HR High Infection Risk ECG Abnormal Cardiac Alert AI Formula Risk Score=0.4(Temperature)+0.3(Heart Rate)+0.3(100−SpO 2 ​ ) Decision Threshold Risk Score > 75 → Critical Risk Score 50–75 → Moderate Risk Score < 50 → Normal 8. n8n Workflow Automation Use official website: n8n Official Website Workflow Nodes Webhook ↓ IF Node (Check Critical Values) ↓ Telegram Node ↓ Google Sheets Node ↓ Text-to-Speech API ↓ Telegram Voice Message n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "IF", "type": "n8n-nodes-base.if" }, { "name": "Telegram", "type": "n8n-nodes-base.telegram" }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets" } ] } 9. Telegram Bot Setup Use: Telegram Official Website Steps Open Telegram Search: Telegram BotFather Create new bot: /newbot Copy Bot Token Add token in n8n Telegram node 10. Google Sheets Integration Use: Google Sheets Sheet Columns Timestamp Temp HR SpO₂ Disease Prediction Integration Steps Create spreadsheet Enable Google API credentials Connect Google account in n8n Append sensor data automatically 11. ThingSpeak Cloud Dashboard Setup Use: ThingSpeak Official Website Setup Steps Create ThingSpeak account Create New Channel Add Fields: Temperature Heart Rate SpO₂ Copy: Write API Key Insert into ESP32 code Dashboard Widgets Live Temperature Graph Heart Rate Trend Oxygen Saturation Chart AI Risk Gauge 12. Voice Notification Automation Workflow Critical Alert ↓ n8n Trigger ↓ Generate TTS Audio ↓ Telegram Voice Message Example Voice Alert Warning. Patient oxygen level is critically low. Immediate medical attention required. 13. Advanced AI Features Future AI Enhancements Machine Learning Use: Random Forest SVM Neural Networks Deep Learning Predict: Heart disease Diabetes Sleep apnea Edge AI Deploy TinyML directly on ESP32. 14. Cloud Database Options Platform Purpose Firebase Realtime database MongoDB Atlas Medical records AWS IoT Enterprise IoT Azure IoT Hub Scalable monitoring 15. Security Features HTTPS encryption Token authentication Secure cloud APIs Patient data privacy Access control 16. Future Enhancements Hardware GPS tracking GSM alerts Camera monitoring Smartwatch integration Software AI chatbot doctor Mobile app Predictive analytics Remote doctor dashboard Multi-patient monitoring 17. Deployment Guide Local Deployment Arduino IDE upload Local WiFi Free cloud platforms Production Deployment Dedicated server MQTT broker SSL security Dockerized n8n Database backup 18. Applications Remote patient monitoring Elderly care ICU monitoring Smart hospitals Home healthcare Rural telemedicine 19. Final Output Features ✅ Real-time health monitoring ✅ AI disease prediction ✅ Telegram text alerts ✅ Telegram voice notifications ✅ Google Sheets logging ✅ ThingSpeak visualization ✅ ESP32 cloud IoT ✅ n8n intelligent automation ✅ Agentic AI workflows ✅ Future-ready architecture 20. Recommended Software Tools Software Purpose Arduino IDE ESP32 programming n8n Automation Postman API testing ThingSpeak Cloud dashboard Google Sheets Data logging 21. Conclusion This project combines: AI IoT Cloud computing Automation Healthcare analytics into a powerful next-generation smart healthcare ecosystem using ESP32 and Agentic AI automation. It is ideal for: Engineering final-year projects Research prototypes Healthcare startups Smart hospital systems Remote patient monitoring platforms

No comments:

Post a Comment

AI Smart Health Monitoring System with Disease Prediction

AI Smart Health Monitoring System with Disease Prediction AI-Powered ESP32 + Agentic IoT + n8n Automation + Telegram Voice Alerts + Google S...