Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

ESP32-Based ECG and SpO2 Monitoring System

Image of ESP32-Based ECG and SpO2 Monitoring System

Circuit Documentation

Summary

The circuit in question is designed to read and process physiological signals, specifically ECG data from an AD8232 Heart Rate Monitor and SpO2 data from a MAX30102 sensor. The ESP32 microcontroller serves as the central processing unit, interfacing with the sensors and handling data acquisition and communication. The AD8232 outputs an analog ECG signal that is read by the ESP32, while the MAX30102 communicates with the ESP32 via I2C to provide SpO2 data. A resistor is included in the circuit for signal conditioning or pull-up/pull-down purposes.

Component List

ESP32 (30 pin)

  • Description: A microcontroller with Wi-Fi and Bluetooth capabilities, featuring a wide range of GPIO pins.
  • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3

AD8232 Heart Rate Monitor

  • Description: A single-lead heart rate monitor for wearable health monitoring applications.
  • Pins: GND, 3.3v, OUTPUT, LO-, LO+, SDN, RA, LA, RL

MAX30102

  • Description: An integrated pulse oximetry and heart-rate monitor sensor solution.
  • Pins: VIN, SDA, SCL, GND, RD, IRD, INT

Resistor

  • Description: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
  • Resistance: 10,000 Ohms

Wiring Details

ESP32 (30 pin)

  • VN connected to AD8232 Heart Rate Monitor OUTPUT and one terminal of the Resistor
  • D34 connected to AD8232 Heart Rate Monitor LO-
  • D35 connected to AD8232 Heart Rate Monitor LO+
  • D22 connected to MAX30102 SCL
  • D21 connected to MAX30102 SDA
  • GND connected to GND of MAX30102, AD8232 Heart Rate Monitor, and the other terminal of the Resistor
  • 3V3 connected to VIN of MAX30102 and 3.3v of AD8232 Heart Rate Monitor

AD8232 Heart Rate Monitor

  • OUTPUT connected to VN of ESP32 and one terminal of the Resistor
  • LO- connected to D34 of ESP32
  • LO+ connected to D35 of ESP32
  • GND connected to GND of ESP32
  • 3.3v connected to 3V3 of ESP32

MAX30102

  • VIN connected to 3V3 of ESP32
  • SDA connected to D21 of ESP32
  • SCL connected to D22 of ESP32
  • GND connected to GND of ESP32

Resistor

  • One terminal connected to VN of ESP32 and OUTPUT of AD8232 Heart Rate Monitor
  • The other terminal connected to GND of ESP32

Documented Code

/*
 * This Arduino Sketch reads ECG data from the AD8232 Heart Rate Monitor and
 * SpO2 data from the MAX30102 sensor. The ECG data is read from the VN pin
 * and the SpO2 data is read via I2C communication.
 */

#include <Wire.h>
#include "MAX30105.h"

MAX30105 particleSensor;

const int ecgPin = 36; // VN pin of ESP32
const int loMinusPin = 34; // LO- pin of AD8232
const int loPlusPin = 35; // LO+ pin of AD8232

void setup() {
  Serial.begin(115200);
  pinMode(ecgPin, INPUT);
  pinMode(loMinusPin, INPUT);
  pinMode(loPlusPin, INPUT);

  // Initialize MAX30102
  Wire.begin(21, 22); // SDA, SCL
  if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) {
    Serial.println("MAX30102 was not found. Please check wiring/power.");
    while (1);
  }
  particleSensor.setup(); // Configure sensor with default settings
}

void loop() {
  // Read ECG data
  int ecgValue = analogRead(ecgPin);
  Serial.print("ECG: ");
  Serial.println(ecgValue);

  // Read SpO2 data
  long irValue = particleSensor.getIR();
  long redValue = particleSensor.getRed();
  Serial.print("IR: ");
  Serial.print(irValue);
  Serial.print(" Red: ");
  Serial.println(redValue);

  delay(1000); // Delay for readability
}

This code is designed to run on the ESP32 microcontroller. It initializes the MAX30102 sensor and continuously reads and prints the ECG data from the AD8232 and the IR and Red values from the MAX30102 sensor to the serial monitor. The I2C communication with the MAX30102 is set up with SDA on pin 21 and SCL on pin 22 of the ESP32.