ESP32-Based Heart Rate and SpO2 Monitor with AD8232 and MAX30102
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to read ECG data from an AD8232 Heart Rate Monitor and SpO2 data from a MAX30102 sensor using an ESP32 microcontroller. The ECG data is read from the VN pin of the ESP32, and the SpO2 data is read via I2C communication.
Component List
ESP32 (30 pin)
- Description: A powerful microcontroller with built-in Wi-Fi and Bluetooth capabilities.
- 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 sensor module used to measure the electrical activity of the heart.
- Pins: GND, 3.3v, OUTPUT, LO-, LO+, SDN, RA, LA, RL
MAX30102
- Description: A sensor module used to measure SpO2 and heart rate.
- Pins: VIN, SDA, SCL, GND, RD, IRD, INT
Resistor
- Description: A 10k Ohm resistor used for signal conditioning.
- Pins: pin1, pin2
- Properties:
- Resistance: 10k Ohms
Wiring Details
ESP32 (30 pin)
VN is connected to:
- pin1 of the Resistor
- OUTPUT of the AD8232 Heart Rate Monitor
D34 is connected to:
- LO- of the AD8232 Heart Rate Monitor
D35 is connected to:
- LO+ of the AD8232 Heart Rate Monitor
D22 is connected to:
- SCL of the MAX30102
D21 is connected to:
- SDA of the MAX30102
GND is connected to:
- GND of the MAX30102
- pin2 of the Resistor
- GND of the AD8232 Heart Rate Monitor
3V3 is connected to:
- VIN of the MAX30102
- 3.3v of the AD8232 Heart Rate Monitor
AD8232 Heart Rate Monitor
OUTPUT is connected to:
- VN of the ESP32
- pin1 of the Resistor
LO- is connected to:
- D34 of the ESP32
LO+ is connected to:
- D35 of the ESP32
GND is connected to:
- GND of the ESP32
- pin2 of the Resistor
- GND of the MAX30102
3.3v is connected to:
- 3V3 of the ESP32
- VIN of the MAX30102
MAX30102
SCL is connected to:
- D22 of the ESP32
SDA is connected to:
- D21 of the ESP32
GND is connected to:
- GND of the ESP32
- pin2 of the Resistor
- GND of the AD8232 Heart Rate Monitor
VIN is connected to:
- 3V3 of the ESP32
- 3.3v of the AD8232 Heart Rate Monitor
Resistor
pin1 is connected to:
- VN of the ESP32
- OUTPUT of the AD8232 Heart Rate Monitor
pin2 is connected to:
- GND of the ESP32
- GND of the MAX30102
- GND of the AD8232 Heart Rate Monitor
Code Documentation
/*
* 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 initializes the ESP32 to read ECG data from the AD8232 Heart Rate Monitor and SpO2 data from the MAX30102 sensor. The ECG data is read from the VN pin of the ESP32, and the SpO2 data is read via I2C communication. The data is then printed to the serial monitor.