How to Use the MAX30102 Pulse Oximeter and Heart Rate Sensor with Arduino

How to Use the MAX30102 Pulse Oximeter and Heart Rate Sensor with Arduino

The MAX30102 is a digital pulse oximeter and heart rate sensor capable of measuring blood oxygen levels (SpO2) and pulse rate. It uses infrared and red LEDs to detect blood flow changes in the finger, making it ideal for health monitoring and wearable devices. This tutorial will guide you through interfacing the MAX30102 with Arduino.


What You Will Need

  1. MAX30102 Sensor Module
  2. Arduino Board (e.g., Uno, Mega, Nano)
  3. Breadboard and Jumper Wires
  4. A computer with the Arduino IDE installed

Step 1: Understanding the MAX30102 Sensor

The MAX30102 sensor communicates with Arduino using the I2C protocol, making it simple to integrate into projects. It features:

  • Red and IR LEDs: Used for pulse and oxygen level detection.
  • I2C Interface: Communicates with microcontrollers.
  • Integrated Temperature Sensor: For compensating environmental effects.

MAX30102 Pinout

Pin Function
VIN Power Supply (3.3V/5V)
GND Ground
SDA I2C Data Line
SCL I2C Clock Line
INT Interrupt (optional)

Step 2: Wiring the MAX30102 to Arduino

Here’s how to connect the MAX30102 sensor to the Arduino:

MAX30102 Pin Arduino Pin
VIN 3.3V/5V
GND GND
SDA A4 (SDA)
SCL A5 (SCL)

Note: For other Arduino boards, ensure you use the correct I2C pins.


Step 3: Install the Required Library

To make working with the MAX30102 easier, install the "SparkFun MAX3010x Sensor Library."

Steps to Install:

  1. Open the Arduino IDE.
  2. Go to Sketch > Include Library > Manage Libraries.
  3. Search for "SparkFun MAX3010x" and click Install.

Step 4: Upload the Code

Here is an example sketch to measure heart rate and SpO2:

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

MAX30105 particleSensor;

void setup() {
  Serial.begin(115200);
  Serial.println("Initializing MAX30102...");

  if (!particleSensor.begin()) {
    Serial.println("MAX30102 not detected. Check connections.");
    while (1);
  }

  Serial.println("Place your finger on the sensor.");
}

void loop() {
  long redValue = particleSensor.getRed(); // Measure red light absorption
  long irValue = particleSensor.getIR();   // Measure infrared light absorption

  Serial.print("Red: ");
  Serial.print(redValue);
  Serial.print(" | IR: ");
  Serial.println(irValue);

  delay(100); // Delay for readability
}

Step 5: Test the Setup

  1. Connect the Arduino to your computer via USB.
  2. Open the Arduino IDE and select the correct Board and Port under the Tools menu.
  3. Upload the code to the Arduino by clicking Upload.
  4. Open the Serial Monitor (Tools > Serial Monitor) and set the baud rate to 115200.
  5. Place your finger on the sensor, and observe the red and infrared readings displayed in the Serial Monitor.

Optional: Advanced Features with Pulse and SpO2 Calculation

To calculate heart rate and SpO2, use an advanced example provided in the SparkFun library:

  1. Open the Arduino IDE.
  2. Go to File > Examples > SparkFun MAX3010x Sensor Library > Example7_SPO2_HR.
  3. Upload the example to your Arduino and follow the instructions in the Serial Monitor.

Applications of the MAX30102

  1. Wearable health monitoring devices
  2. Fitness trackers
  3. Heart rate and SpO2 monitoring systems
  4. Biomedical research projects

Troubleshooting

  • No response from the sensor: Verify the I2C connections and ensure the correct power supply (3.3V or 5V).
  • Inconsistent readings: Ensure your finger fully covers the sensor and avoid movement.
  • Library errors: Confirm that the SparkFun MAX3010x library is correctly installed.

Conclusion

You’ve successfully interfaced the MAX30102 pulse oximeter and heart rate sensor with Arduino. This powerful sensor is perfect for wearable health monitoring and IoT applications. Experiment with its features to build innovative health-focused projects!

Leave a comment

Notice an Issue? Have a Suggestion?
If you encounter a problem or have an idea for a new feature, let us know! Report a problem or request a feature here.