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.
/*
* 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.