Labs / Electronic modules

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.3 · License: CC BY 4.0 · Driver code (sensors/max30102_driver): MIT License

Contents
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

I. Module Introduction

Heart rate and blood oxygen sensor module based on the MAX30102 chip, designed with the MAX30102EFD+ T sensor, communicates with the microcontroller via I2C. The operating voltage of the chip is + 1.8V, with a typical operating current of 600μA (maximum 1200μA).It leverages red light and infrared light to penetrate the skin and blood, and by detecting the difference in absorption of light at different wavelengths by hemoglobin (Hb) and oxyhemoglobin (HbO₂), it outputs a digital signal through preamplification, filtering, and ADC conversion, achieving accurate measurement of heart rate and blood oxygen. It is suitable for scenarios such as health monitoring and wearable devices, and provides reliable hardware support for physiological parameter detection.

II. Introduction to Main Chips

MAX30102EFD+ T is a high-precision pulse oximeter and heart rate sensor integrated with infrared, red light and dual infrared, featuring a built-in low-noise optical receiver and LED driver circuit. It supports the detection of heart rate, blood oxygen saturation (SpO₂) and respiratory rate, with a wide measurement range and high accuracy.It communicates with the main controller via the I²C interface, supports a supply voltage of 1.8~3.3V, features a low-power mode (with a standby current of only 0.7μA), has built-in ambient light suppression algorithm and temperature compensation function, delivers strong anti-interference performance, adopts a compact 2.5mm×4.4mm×1.0mm package, and is compliant with the RoHS standard. It is widely used in wearable medical and consumer electronics scenarios such as smart bracelets, watches, and health monitoring devices.

2.1 Chip Overview

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

2.2 Pin Definition

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

2.3 Functional Block Diagram

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

MAX30102EFD+ T is a complete pulse oximeter and heart rate monitoring system solution module, designed for the stringent requirements of wearable devices. This device maintains an extremely small solution size without compromising optical or electrical performance. It requires very few external hardware components for integration into wearable systems. The following is the functional block diagram description of MAX30102EFD+ T:

Typical Scenario (Taking Heart Rate and Blood Oxygen Detection as an Example):

2.4 Performance Parameters

The following are the charts respectively illustrating the electrical characteristics, pulse oximeter/heart rate sensor characteristics, red LED characteristics, photodetector and temperature sensor characteristics of MAX30102EFD+ T.

MAX30102 1.8V 5.0V 40 85 25
2 0x0c 0x01 SP02_SR 0x05 0x00 65536 MAX30102EFD+T
0x02 0x03 118 215 411 719 1 MAX30102EFD+T
MAX30102EFD+T

MAX30102EFD+ T Key points are specified as follows:

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

The operating characteristics of the MAX30102EFD+ T (heart rate / blood oxygen sensor) are described as follows:

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

This set of diagrams demonstrates the typical operating characteristics of the MAX30102EFD+ T (heart rate / blood oxygen sensor):

2.5 Reference Circuit

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

This is the functional block diagram of MAX30102: it is powered by dual power supplies (VLED+ is 3.3V, Vdd is 1.8V, both equipped with filter capacitors), and has built-in RED (660nm), IR (880nm) and other LEDs and photosensitive elements. After filtering out interference through the "ambient light cancellation module", the optical signal and chip temperature signal are converted into digital quantities via ADC respectively, and then stored in the data register after digital filtering;The oscillator cooperates with LED drive control to LED operate, and finally communicates with the host processor via the I2C interface; the INT pin transmits interrupt signals, which is mainly used for detecting physiological parameters such as heart rate and blood oxygen.

2.6 Chip Configuration

MAX30102EFD+ T is a heart rate and blood oxygen sensor that requires no additional configuration during use.

2.7.1 Register Description

2.7.1.1 Register Address Summary Table
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
2.7.1.2 Interrupt
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

MAX30102 generates interrupts via the active-low INT pin; the interrupt status is recorded by 2 read-only interrupt status registers (0x00, 0x01), and controlled by 2 read-write interrupt enable registers (0x02, 0x03): except for the PWR_RDY (power ready) interrupt which cannot be disabled, the following 4 interrupts — A_FULL (FIFO almost full), PPG_RDY (new FIFO data available), ALC_OVF (ambient light cancellation overflow), and DIE_TEMP_RDY (internal die temperature ready)— can be enabled or disabled via the enable registers, and all of these interrupts are disabled by default.

Interrupt trigger scenarios vary as follows: A_FULL corresponds to the remaining space of the FIFO reaching the set value, PPG_RDY corresponds to new data being written into the FIFO, ALC_OVF corresponds to the ambient light cancellation function exceeding the limit, PWR_RDY corresponds to being ready after power-on/power-off recovery, DIE_TEMP_RDY corresponds to the completion of internal temperature conversion;After an interrupt is triggered, reading the corresponding status register or the register that triggered the interrupt (e. g., PPG_RDY to read FIFO_DATA) will clear the interrupt, INT pin returns to high level, and the corresponding bit in the status register will also be cleared to zero.

2.7.1.3 FIFO
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

MAX30102 's FIFO is a circular buffer with a capacity of 32 samples, managed by the write pointer (FIFO_WR_PTR), read pointer (FIFO_RD_PTR), overflow counter (OVF_COUNTER) and data register (FIFO_DATA)(corresponding to registers 0x04 to 0x07): the write pointer points to the position to be written and increments with each stored sample; the read pointer points to the position to be read and increments with each read sample; the overflow counter counts the number of samples lost when the FIFO is full (and is cleared after a sample is read).

Its data is stored in left-aligned format, and each channel (e. g., RED / IR) sample occupies 3 bytes; in blood oxygen mode, one sample contains 2 channels totaling 6 bytes; when reading FIFO_DATA, the address pointer does not automatically increment, and multiple bytes need to be read consecutively to obtain a complete sample.

FIFO can be configured via the 0x08 register: SMP_AVE sets the averaging of 1-32 merged samples, FIFO_ROLL_OVER_EN controls whether to overwrite old data when the FIFO is full, and FIFO_A_FULL configures the remaining sample count for the almost-full interrupt; it is recommended to clear the pointer before entering the SpO2/heart rate mode to avoid interference from old data.

2.7.1.4 Mode Setting (0x09)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

MAX30102 operating mode is configured via the Mode Configuration register (0x09) through its MODE[2:0] bits. The primary valid modes are as follows: 010 corresponds to heart rate mode (only the Red LED is activated), 011 corresponds to blood oxygen (SpO₂) mode (both Red and IR LED are activated), 111 corresponds to multi- LED mode (also activates both Red and IR LED); other mode combinations (such as 000,001, etc.) are not recommended.Different modes adapt to the acquisition requirements of different physiological parameters such as heart rate and blood oxygen by switching the activated LED channels.

2.7.1.5 Blood Oxygen Saturation Setting (0x0A)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

MAX30102 's SpO₂ configuration register (0x0A) is used to set the core acquisition parameters in the blood oxygen mode, which consists of three key configuration segments:

  1. SPO₂_ADC_RANGE (Bits 6-5): Controls the full-scale range of the ADC, with selectable ranges such as 2048 nA to 16384 nA. These ranges correspond to different LSB accuracies, adapting to optical signal acquisition of varying intensities;
  2. SPO₂_SR (Bits4-2): Set the sampling rate (50~3200 samples/sec), which must match the pulse width of LED; an excessively high setting will be automatically adjusted to the maximum feasible value;
  3. LED_PM (Bits 1-0): Controls the pulse width of LED (infrared, red light), and indirectly determines the integration time and resolution of the ADC.

These configurations collectively adapt to the requirements such as signal accuracy and rate for blood oxygen acquisition.

2.7.1.6 LED Pulse Amplitude (0x0C-0X0D)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

This part of the function is MAX30102 to configure the operating parameters of the LED, which consists of two core modules:

  1. LED pulse width control: The pulse width (69μs~411μs) of LED (red light, infrared light) is set via bits [1:0] of LED_PM, which also directly determines the resolution (15~18 bits) of ADC — the longer the pulse width, the longer the integration time of ADC, the higher the resolution, and the better the acquisition accuracy.
  2. LED Pulse Amplitude Control: The 0x0C and 0x0D registers' LEDx_PA[7:0] bits respectively adjust the currents of the red and infrared LEDs (ranging from 0.0mA to 51.0mA), so as to control the luminous intensity of the LEDs and adapt to the optical signal requirements of different detection scenarios (such as different skin tones and wearing tightness; the actual current may vary slightly due to device calibration).

These two configurations jointly optimize the emission parameters of the LED, and coordinate with the precision and adaptability of subsequent signal acquisition.

2.7.1.7 Multi-LED Mode Control Registers (0x11–0x12)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

This part describes the multi- MAX30102 - LED mode control function, which is managed by registers 0x11 and 0x12: In multi- LED mode, each sample is split into up to 4 time slots (SLOT1 to SLOT4), and the LED to be activated in each slot can be configured via the SLOTx[2:0] bits of that slot (only 001 corresponds to red light LED1, 010 corresponds to infrared LED2, and the rest are mostly disabled/reserved); activated slots will call the corresponding LED pulse amplitude parameters (LED1_PA / LED2_PA).Each activation slot writes 3 bytes of data to the FIFO (if 2 slots are activated, one sample occupies 6 bytes), and the slots must be enabled in the order from SLOT1 to SLOT4; subsequent slots cannot be enabled without enabling the preceding slots.

2.7.1.8 Temperature Data (0x1F–0x21)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

This part describes the on-board temperature detection and compensation function of MAX30102:

  1. Temperature Measurement: A single temperature reading is triggered via the TEMP_EN bit of register 0x21 (this bit is automatically cleared after triggering). The measurement result is stored in two separate registers: 0x1F (integer part, in two's complement format, where 1 bit corresponds to 1°C) and 0x20 (fractional part, with an increment of 0.0625°C). The actual temperature is obtained by adding the values of the two registers (e. g., -128°C + 0.5°C = -127.5°C).
  2. Temperature Compensation: Since LED heat generation will change the red light wavelength (which affects blood oxygen measurement), it is necessary to look up the table to obtain the temperature rise value of the LED according to the current setting and duty cycle of the LED, add it to the temperature measured by the sensor to estimate the actual temperature of the LED, so as to improve the acquisition accuracy of parameters such as blood oxygen.

2.7.2 IIC Communication Description

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)
GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

MAX30102 operates I2C communication in master-slave mode: its fixed 7-bit slave address is "1010111", corresponding to the write address 0xAE and read address 0xAF. The communication is initiated by the master sending a START condition (pulling SDA low while SCL is high) and terminated by a STOP condition (pulling SDA high while SCL is high), with acknowledgment via ACK / NACK at the 9th clock cycle after each byte transmission.

Write operation , the host sequentially sends a write address from the machine, the target register address ( ACK are obtained MAX30102 ), and then sends data bytes (back to ACK after each byte), the register pointer is automatically incremented, and finally STOP ends; read operation needs to send a write address to specify the register, and then send a repeat START and read address, MAX30102 after sending data response, the host intermediate byte back ACK , the last byte back to NACK , only read FIFO_DATA when the register pointer is not automatically incremented, in order to complete the data read and write interaction.

2.8 PCB Routing Precautions

None.

III. Circuit Engineering

3.1 Circuit Source Engineering

To obtain the source code of the circuit, please follow the official account [Freak Embedded]

3.2 Module Usage Instructions

SCH_Schematic1_Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip-V1.0_2025-11-13.pdf 2.1 MB

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

This module provides an I2C communication interface: it supports standard I2C communication rate, with the default configured slave address of 0x57 for I2C, is compatible with 3.3V system level to adapt to mainstream microcontrollers, can stably transmit the digital data of heart rate and blood oxygen corresponding to red light and infrared light detection, is applicable to scenarios such as health monitoring devices and wearable maker projects, and provides a convenient hardware connection solution for the digital collection of physiological parameters and system interaction.

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and connect the heart rate and blood oxygen sensor module based on the MAX30102 chip to communicate with the main controller via the I2C interface.

Here, we first use the HY2.0-4P cable to connect the module to the GraftPort-RP2040 development board's I2C0 interface:

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

The module connections are shown in the following table:

Development Board Pins

Module Pins

Description

Pin 4

SDA

I2C data transmission line, corresponding to the I2C0 SDA

Pin 5

SCL

I2C clock signal line, corresponding to I2C0 's SCL

Here, we need to search for relevant driver packages on uPyPI: https://upypi.net/zh/

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

Enter max30100_driver to search, and the following will be displayed:

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

Click to copy the local installation command:

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

Here, we can use the mip tool to import module driver library code. Below are the usage commands for the mpremote tool:

mpremote mip install github:FreakStudioCN/GraftSense-Drivers-MicroPython/sensors/max30102_driver

After importing the heart rate and blood oxygen sensor module based on the MAX30102 chip - MicroPython driver code, copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2025/09/16 18:00
# @Author  : 侯钧瀚
# @File    : main.py
# @Description : MAX30102 heart rate and PPG reading + simple heart rate calculator example

# ======================================== Import Modules =========================================

# MicroPython built-in module
from machine import I2C, Pin
# Import time-related modules
import time
# Import the MAX30102 driver module
from heartratemonitor import MAX30102, MAX30105_PULSE_AMP_MEDIUM , HeartRateMonitor, CircularBuffer

# ======================================== Global Variables ============================================

# Calculate the heart rate every 2 seconds
hr_compute_interval = 2

# ======================================== Functions ============================================

# ======================================== Custom Classes ============================================

# ======================================== Initialization ==========================================
# Power-on delay of 3 s
time.sleep(3)
# Print debug message
print("FreakStudio: Use MAX30102 to read heart rate and temperature.")
# I2C0: SDA=GP4, SCL=GP5, 400kHz
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
# Create the sensor instance
sensor = MAX30102(i2c=i2c)
# Basic initialization
sensor.setup_sensor()
# Sample rate: 400 Hz
sensor_sample_rate = 400
sensor.set_sample_rate(sensor_sample_rate)
# FIFO averaging: 8
sensor_fifo_average = 8
sensor.set_fifo_average(sensor_fifo_average)
# LED current: medium
sensor.set_active_leds_amplitude(MAX30105_PULSE_AMP_MEDIUM)
# Expected acquisition rate: 400 / 8 = 50 Hz
actual_acquisition_rate = int(sensor_sample_rate / sensor_fifo_average)  # Actual output Hz
# Initialize the heart rate monitor
hr_monitor = HeartRateMonitor(
        # Sample rate matches the sensor
        sample_rate=actual_acquisition_rate,
        # Heart rate calculation window (about 2–5 s, 3 s is used here)
        window_size=int(actual_acquisition_rate * 3),
    )
# Reference time
ref_time = time.ticks_ms()

# ========================================  Main Program  ===========================================

while True:
        # Poll the FIFO for new data; if any, write it to internal storage
        sensor.check()
        time.sleep(0.5)
        # Whether the buffer has available samples
        if sensor.available():
            # Read RED/IR/TEMP channel data (integers)
            red_reading = sensor.pop_red_from_storage()
            ir_reading = sensor.pop_ir_from_storage()
            temp_reading =sensor.read_temperature()
            print("RED: {}, IR: {},TEMP:{:.2f}".format(red_reading, ir_reading,temp_reading))
            # Use IR samples for heart rate calculation (RED/IR/GREEN can be used depending on skin tone)
            hr_monitor.add_sample(ir_reading)


        # Calculate heart rate once every hr_compute_interval seconds
        if time.ticks_diff(time.ticks_ms(), ref_time) / 1000 > hr_compute_interval:
            heart_rate = hr_monitor.calculate_heart_rate()
            if heart_rate is not None:
                print("Heart Rate: {:.0f} BPM".format(heart_rate))
            else:
                print("Not enough data to calculate heart rate")
            # Reset reference time
            ref_time = time.ticks_ms()


Burn the code, open the terminal, and use the mpremote tool to connect to the main controller. Place your finger on the sensor, and the output will be as follows:

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)

It can be seen that the routine can currently run normally and output RED, IR, TEMP, and the heart rate value will be output after sufficient data is collected.

Please note the following points when using it:

IV. Drivers

max30102_driver.zip 25 KB

None.

VI. Revision History

Document Version

Date of Revision

Modifier

Revised Content

v1.0

2025-11-13

Zero Kōkō

Initialize the document

v1.1

2025-12-29

Li Zisheng

Added application experiments and production files

v1.2

2025-12-31

Xin Ruili

Create an open version of the document based on the internal document version v1.1.

v1.3

2026-03-29

Xin Ruili

Modified the application experiment section

VII. Relevant Materials

7.1 Chip Datasheet

MAX30102 Manual.pdf 896 KB

7.2 Unique Icons for PCB Silk Screen

GraftSense: Heart Rate and Blood Oxygen Sensor Module Based on MAX30102 Chip (Open Version)