AI & MLIntermediatePRJ-095

AI-Based Health Monitoring System

Tracks temperature, heart rate and SpO₂, plots them live and alerts on abnormal values.

Built and tested by Shahan Fathima K · Industrial Robotics Institute

ESP32 + Laptop

Arduino IDE, Python 3, DHT sensor library, SparkFun MAX3010x library, PySerial, Matplotlib

LevelIntermediate
Build time3–4 hours
BoardESP32 + Laptop
Parts7 components

What is the AI-Based Health Monitoring System?

A health monitor that combines an ESP32 with sensors and a Python dashboard. A DHT11 measures temperature and a MAX30102 is connected for heart rate and oxygen level. The ESP32 sends the readings to the computer, which plots them live; if temperature goes above 38 °C, heart rate above 100 or SpO₂ below 92%, the buzzer sounds and an alert is printed.

How it works

  1. The DHT11 measures temperature and the MAX30102 is read over I2C.
  2. The ESP32 sends "temperature,heart rate,SpO₂" over USB every second.
  3. Simple AI rules check for abnormal values: temp > 38 °C, HR > 100, SpO₂ < 92%.
  4. On an abnormal value the ESP32 sounds the buzzer.
  5. The Python script draws a live graph of all three and prints alerts.

Parts list

ComponentQty
ESP32 Dev Board1
MAX30102 Heart Rate & SpO₂ Sensor1
DHT11 Temperature Sensor1
Buzzer1
OLED / LCD Display (optional)1
Breadboard1
Jumper WiresAs needed

Software

  • Arduino IDE
  • Python 3
  • DHT sensor library
  • SparkFun MAX3010x library
  • PySerial
  • Matplotlib

Wiring and connections

FromConnect to
DHT11 VCC3.3V
DHT11 GNDGND
DHT11 DATAGPIO 4
MAX30102 VIN3.3V
MAX30102 GNDGND
MAX30102 SDAGPIO 21
MAX30102 SCLGPIO 22
Buzzer +GPIO 15
Buzzer −GND

How to build the AI-Based Health Monitoring System

  1. Connect the DHT11 to GPIO 4 and the MAX30102 to GPIO 21 (SDA) and 22 (SCL).
  2. Connect the buzzer to GPIO 15.
  3. Install the DHT and SparkFun MAX3010x libraries, then upload the ESP32 code.
  4. Run: pip install pyserial matplotlib
  5. Set the ESP32’s COM port in the Python script and run it.
  6. Watch the live graph and alerts.

AI-Based Health Monitoring System code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it and run it.

// ===================== ESP32 (Arduino IDE) =====================
#include <Wire.h>
#include "MAX30105.h"
#include "heartRate.h"
#include "DHT.h"

#define DHTPIN 4
#define DHTTYPE DHT11
#define BUZZER 15

DHT dht(DHTPIN, DHTTYPE);
MAX30105 particleSensor;

void setup() {
  Serial.begin(9600);
  pinMode(BUZZER, OUTPUT);
  dht.begin();

  if (!particleSensor.begin(Wire, I2C_SPEED_STANDARD)) {
    Serial.println("MAX30102 not found");
    while (1);
  }
  particleSensor.setup();
}

void loop() {
  float temp = dht.readTemperature();
  long irValue = particleSensor.getIR();

  // Demo values: replace with a real BPM / SpO2 algorithm
  int heartRate = random(60, 110);
  int spo2 = random(90, 100);

  Serial.print(temp);
  Serial.print(",");
  Serial.print(heartRate);
  Serial.print(",");
  Serial.println(spo2);

  if (temp > 38 || heartRate > 100 || spo2 < 92) {
    digitalWrite(BUZZER, HIGH);
  } else {
    digitalWrite(BUZZER, LOW);
  }
  delay(1000);
}

// ===================== Python (graph + alerts) =====================
/*
import serial
import matplotlib.pyplot as plt
from collections import deque

ser = serial.Serial('COM5', 9600)
temp_data, hr_data, spo2_data = deque(maxlen=20), deque(maxlen=20), deque(maxlen=20)
plt.ion()

while True:
    values = ser.readline().decode().strip().split(",")
    if len(values) == 3:
        temp, hr, spo2 = float(values[0]), int(values[1]), int(values[2])
        temp_data.append(temp); hr_data.append(hr); spo2_data.append(spo2)
        print(f"Temp: {temp} HR: {hr} SpO2: {spo2}")
        if temp > 38 or hr > 100 or spo2 < 92:
            print("ALERT! Abnormal Condition")
        plt.clf()
        plt.plot(temp_data, label="Temperature")
        plt.plot(hr_data, label="Heart Rate")
        plt.plot(spo2_data, label="SpO2")
        plt.legend()
        plt.pause(0.1)
*/

Real-world uses

  • Home health checks
  • Elderly care
  • Clinic demonstrations
  • Learning health IoT and AI rules

Frequently asked questions

What is a AI-Based Health Monitoring System?

A health monitor that combines an ESP32 with sensors and a Python dashboard. A DHT11 measures temperature and a MAX30102 is connected for heart rate and oxygen level.

What components are needed for the AI-Based Health Monitoring System?

You need: ESP32 Dev Board (1), MAX30102 Heart Rate & SpO₂ Sensor (1), DHT11 Temperature Sensor (1), Buzzer (1), OLED / LCD Display (optional) (1), Breadboard (1), Jumper Wires. Software: Arduino IDE, Python 3, DHT sensor library, SparkFun MAX3010x library, PySerial, Matplotlib.

Is the AI-Based Health Monitoring System project good for beginners?

It is rated intermediate and takes about 3–4 hours to build, using the ESP32 + Laptop. The guide on this page explains every connection and step.

Where can I get the code for the AI-Based Health Monitoring System?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it and run it.

Can I buy a kit for the AI-Based Health Monitoring System?

Yes. IRI sells a kit with the parts for this project (PRJ-095). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo