#include <Wire.h>
#include <MAX30105.h>
MAX30105 particleSensor;
void setup() {
Serial.begin(115200);
Wire.begin();
if (!particleSensor.begin()) {
Serial.println("MAX30102 not found. Please check your wiring.");
while (1);
}
// Configure sensor for heart rate and SpO2 measurement
particleSensor.setup(); // Use default settings
particleSensor.setPulseAmplitudeRed(0x0A); // Red LED brightness (0x0A = 10)
particleSensor.setPulseAmplitudeGreen(0x0A); // Green LED brightness (0x0A = 10)
}
void loop() {
// Read the sensor values
long redValue = particleSensor.getRed();
long irValue = particleSensor.getIR();
if (redValue == 0 || irValue == 0) {
Serial.println("Sensor is not detecting a valid pulse. Ensure the sensor is in contact with the skin.");
} else {
Serial.print("Red: ");
Serial.print(redValue);
Serial.print(" IR: ");
Serial.println(irValue);
}
delay(1000); // Delay for 1 second before reading again
}