How to Build ESP32 Health Monitoring Patch in Lahore Pakistan

This guide shows you how to build a wearable ESP32 health monitoring patch that reads your heart rate and body temperature and sends the readings to the cloud over Wi-Fi. It is a student and final year project — a working prototype you can demonstrate, explain, and extend.

Important: this is a learning prototype, not a medical device. The MAX30100 is a hobby sensor, not a medical-grade sensor, and its readings are approximate. Do not use this patch to diagnose illness or replace a real medical check-up.

ESP32 Health Monitoring Patch Circuit Diagram

What This Patch Does

  • Reads heart rate (pulse) and blood oxygen (SpO2) with the MAX30100 pulse sensor
  • Reads body temperature with the DS18B20 sensor
  • Shows the readings on the Serial Monitor (and on an optional 0.96" OLED display)
  • Uploads the readings to ThingSpeak over Wi-Fi, so you can watch them on a web dashboard from your phone or laptop

The ESP32 is the right board for this project because it has built-in Wi-Fi and Bluetooth, two I2C pins for the pulse sensor and display, and enough pins for the temperature sensor — all on one small, cheap board.

Components Required

ComponentSpecificationPrice / link
ESP32 Dev Module30-pin Wi-Fi + Bluetooth boardESP32 30-Pin Wi-Fi Bluetooth Development Board — Rs 1,100
Pulse sensorMAX30100 / MAX30102—
Temperature sensorDS18B20 (waterproof version works well)—
Resistor4.7k ohm (pull-up for DS18B20)—
Battery3.7V Li-ion 18650 cell18650 Lithium-Ion Rechargeable Cell 2000mAh — Lot Rs 200 / New Rs 250
Charging moduleTP4056 Type-CTP4056 Charging Board Type-C — Rs 50
Display (optional)OLED 0.96" I2C—
Breadboard + jumper wires——

The MAX30100, DS18B20 and OLED display do not have individual listings in the QKZEE shop — they are available at the Hall Road shop on request.

Wiring Connections

Sensor / ModuleESP32 PinNotes
MAX30100 VCC3V33.3V only — do not connect to 5V
MAX30100 GNDGND—
MAX30100 SDAGPIO 21I2C data
MAX30100 SCLGPIO 22I2C clock
DS18B20 dataGPIO 4OneWire data
DS18B20 VCC3V3—
DS18B20 GNDGND—
4.7k ohm resistorBetween DS18B20 data (GPIO 4) and 3V3Pull-up — without it the sensor will not reply
OLED SDAGPIO 21Shared I2C bus with MAX30100
OLED SCLGPIO 22Shared I2C bus with MAX30100
OLED VCC / GND3V3 / GND—
Battery (via TP4056 OUT)VINFor bench testing, a 5V USB cable is the safer option

How the Patch Works

The MAX30100 shines red and infrared light into your fingertip and measures how much light bounces back. Blood absorbs light differently with every heartbeat, so the sensor can work out your pulse and your blood oxygen level (SpO2) — this is called photoplethysmography.

At the same time, the DS18B20 measures skin temperature. The ESP32 reads both sensors, prints the values to the Serial Monitor, and every 20 seconds uploads them to ThingSpeak over Wi-Fi. You can then watch heart rate, SpO2 and temperature as live charts on your ThingSpeak channel.

ESP32 Health Monitoring Patch — Arduino Code

Install these libraries first from the Arduino IDE Library Manager (Sketch → Include Library → Manage Libraries):

  • MAX30100_PulseOximeter by OXullo
  • OneWire by Paul Stoffregen
  • DallasTemperature by Miles Burton

Then upload this sketch. Replace the Wi-Fi name, password and ThingSpeak Write API Key with your own (see the ThingSpeak section below).

/*
  ESP32 Health Monitoring Patch
  Reads heart rate + SpO2 from MAX30100, temperature from DS18B20,
  prints values on the Serial Monitor and uploads them to ThingSpeak.
  Board: ESP32 Dev Module. MAX30100 on I2C (SDA 21, SCL 22).
  DS18B20 data pin GPIO 4, with a 4.7k ohm resistor to 3.3V.
*/

#include <WiFi.h>
#include <HTTPClient.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "MAX30100_PulseOximeter.h"

#define REPORTING_PERIOD_MS 1000
#define ONE_WIRE_BUS 4

const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
const char* thingSpeakApiKey = "YOUR_THINGSPEAK_WRITE_API_KEY";

PulseOximeter pox;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature tempSensor(&oneWire);
uint32_t tsLastReport = 0;
uint32_t tsLastUpload = 0;

void onBeatDetected() {
  Serial.println("Beat!");
}

void setup() {
  Serial.begin(115200);
  Serial.println("ESP32 Health Monitoring Patch starting...");

  tempSensor.begin();

  if (!pox.begin()) {
    Serial.println("MAX30100 not found - check wiring!");
    while (1);
  }
  pox.setOnBeatDetectedCallback(onBeatDetected);

  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nWiFi connected");
}

void loop() {
  pox.update();

  if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
    tempSensor.requestTemperatures();
    float temperatureC = tempSensor.getTempCByIndex(0);
    float heartRate = pox.getHeartRate();
    float spo2 = pox.getSpO2();

    Serial.print("Heart rate: ");
    Serial.print(heartRate);
    Serial.print(" bpm | SpO2: ");
    Serial.print(spo2);
    Serial.print(" % | Temperature: ");
    Serial.print(temperatureC);
    Serial.println(" C");

    tsLastReport = millis();
  }

  // ThingSpeak accepts an update at most every 15 seconds
  if (millis() - tsLastUpload > 20000 && WiFi.status() == WL_CONNECTED) {
    tempSensor.requestTemperatures();
    float temperatureC = tempSensor.getTempCByIndex(0);

    HTTPClient http;
    String url = "http://api.thingspeak.com/update?api_key=" + String(thingSpeakApiKey)
               + "&field1=" + String(pox.getHeartRate())
               + "&field2=" + String(pox.getSpO2())
               + "&field3=" + String(temperatureC);
    http.begin(url);
    int code = http.GET();
    Serial.print("ThingSpeak response: ");
    Serial.println(code);
    http.end();

    tsLastUpload = millis();
  }
}

Cloud Integration with ThingSpeak

  1. Create a free account at thingspeak.com and make a new channel with 3 fields: Field 1 = Heart Rate, Field 2 = SpO2, Field 3 = Temperature.
  2. Open the channel's API Keys tab and copy the Write API Key.
  3. Paste it into the sketch where it says YOUR_THINGSPEAK_WRITE_API_KEY, along with your Wi-Fi name and password.
  4. Upload the sketch, open the Serial Monitor at 115200 baud, and watch the readings appear. After about 20 seconds, open your ThingSpeak channel — the charts will start filling in.

Firebase and Blynk are also possible for this project, but the sketch above uses ThingSpeak because it is the simplest free option for a student demo: no app to build, just a web dashboard.

Testing the Patch

  1. Test the temperature sensor first. Upload the sketch and open the Serial Monitor. You should see a temperature near room temperature (25–30°C). If it shows −127°C, the DS18B20 is not wired correctly — check GPIO 4 and the 4.7k ohm pull-up resistor.
  2. Test the pulse sensor next. Place your fingertip flat on the MAX30100 window and hold it still. Wait about 10 seconds — the heart rate reading needs a few beats before it settles. Keep your hand steady; movement is the biggest cause of wrong readings.
  3. Test the cloud upload last. Once both sensors show sensible values, check your ThingSpeak channel. If the charts stay empty, check the Wi-Fi password and the API key first.

Troubleshooting

  • "MAX30100 not found" on the Serial Monitor: check SDA → GPIO 21, SCL → GPIO 22, VCC → 3V3 (not 5V), GND → GND. The sensor will not answer on the wrong voltage.
  • Heart rate shows 0: no finger on the sensor, or the finger is moving. Hold it flat and still for 10 seconds.
  • Temperature shows −127°C: the DS18B20 is not connected. Check the data wire on GPIO 4 and the 4.7k ohm resistor between data and 3V3.
  • Wi-Fi never connects: check the Wi-Fi name and password (both are case-sensitive), and use a 2.4 GHz network — the ESP32 does not connect to 5 GHz Wi-Fi.
  • ThingSpeak response is 0: no internet on the Wi-Fi network, or the API key is wrong. A response of 200 means the update worked.

Applications

  • Personal health monitoring demo for a student project or science exhibition
  • Elderly care prototype — family members can watch readings on a phone
  • Fitness tracking demo — heart rate during rest and after exercise
  • Final year project base — add alerts, an OLED display, or a mobile app on top

This is a prototype for learning and demonstration. It is not a medical device and its readings are not accurate enough for diagnosis or treatment decisions.

Where to Buy the Components

The ESP32 board, TP4056 charging module and 18650 cell are available at QKZEE Technologies, Shop 20, 1st Floor, Al-Khalil Center, Hall Road, Lahore, and online at qkzeetech.com with delivery all over Pakistan — see the links in the components table above. The MAX30100, DS18B20 and OLED display are available at the Hall Road shop on request.

Still Stuck?

If a sensor does not respond, or your ThingSpeak charts stay empty, message us — tell us what the Serial Monitor shows (copy the exact lines) and which step you are on, and we will help you find the fault.

Chat on WhatsAppWatch on YouTube

FAQs

Is the MAX30100 a medical-grade sensor?

No. It is a hobby sensor for learning and prototypes. Its heart rate and SpO2 readings are approximate and affected by movement, skin tone and finger placement. Never use them for medical decisions.

Can I use this patch to monitor a patient?

No. This is a student project prototype, not a certified medical device. It is fine for demonstrations and learning, not for real patient care.

Why does my heart rate show 0?

Usually the finger is not flat on the sensor, or it is moving. Hold your fingertip steady on the sensor window and wait about 10 seconds for the reading to settle.

Why does the temperature show −127°C?

That is the DS18B20's "not connected" value. Check the data wire on GPIO 4 and the 4.7k ohm resistor between the data pin and 3V3.

Do I need the OLED display?

No, it is optional. Without it, all readings appear on the Serial Monitor and on ThingSpeak. The display only helps if you want to show values on the patch itself.

Can I use Firebase or Blynk instead of ThingSpeak?

Yes. The sensors and wiring stay the same — only the cloud code changes. ThingSpeak is used here because it is the simplest free dashboard for a student demo.

Conclusion

Building an ESP32 health monitoring patch with a MAX30100 pulse sensor and a DS18B20 temperature sensor is a strong final year project: it combines sensors, Wi-Fi, and cloud dashboards in one wearable prototype. Follow the wiring above, test each sensor on its own first, and you will have live heart rate, SpO2 and temperature charts on ThingSpeak to show your teachers and judges.