🧪 New tutorials are being published — build from robot arms to sensors step by step
Skip to content

Heart Rate & SpO2 Sensor

Overview

The Juxi Technology Heart Rate & SpO2 Sensor is based on the MAX30102 chip, supporting both IIC and UART communication modes for real-time heart rate and blood oxygen saturation data collection. It includes an Arduino library and Python SDK (Raspberry Pi / Windows / Jetson), along with a visual host application.

Features:

  • MAX30102 high-precision heart rate & SpO2 chip
  • Dual communication modes: IIC and UART
  • Arduino library + Python SDK
  • Windows visual host application
  • Open source: GitHub

Specifications

ParameterDetail
ChipMAX30102
MeasurementsHeart Rate (HR) / Blood Oxygen Saturation (SpO2)
CommunicationIIC (0x57) / UART (9600bps)
Operating Voltage3.3V - 5V
Development SupportArduino / Python (RPi / Windows / Jetson)

Quick Start

Wiring

IIC Wiring:

IIC Wiring Diagram

MAX30102Arduino / Raspberry Pi
VCC3.3V / 5V
GNDGND
SCLSCL (I2C Clock)
SDASDA (I2C Data)

UART Wiring:

UART Wiring Diagram

MAX30102Arduino UNO
VCCVCC
GNDGND
TXPin 4
RXPin 5

Arduino Example

Install the library: copy JUXI_HeartRate_SPO2.h and .cpp from the repo src/ directory into your Arduino libraries folder.

cpp
#include "JUXI_HeartRate_SPO2.h"

#define I2C_COMMUNICATION
#define I2C_ADDRESS  0x57
JUXI_HeartRate_SPO2_I2C MAX30102(&Wire, I2C_ADDRESS);

void setup() {
  Serial.begin(9600);
  while (!MAX30102.begin()) {
    Serial.println("init fail!");
    delay(1000);
  }
  Serial.println("start measuring...");
}

void loop() {
  MAX30102.sensor_read_data();
  int heartRate = MAX30102.sensor_get_heartRate();
  int spo2 = MAX30102.sensor_get_spo2();

  if (heartRate > 0 && spo2 > 0) {
    Serial.print("Heart Rate: ");
    Serial.print(heartRate);
    Serial.print(" bpm, SpO2: ");
    Serial.print(spo2);
    Serial.println(" %");
  }
  delay(100);
}

Python Example (Raspberry Pi / Jetson)

python
import sys
import os
import time
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
from JUXI_HeartRate_SPO2 import *

# Select communication mode: ctype=0 for IIC, ctype=1 for UART
ctype = 1

if ctype == 0:
    I2C_1 = 0x01
    I2C_ADDRESS = 0x57
    max30102 = JUXI_HeartRate_SPO2_i2c(I2C_1, I2C_ADDRESS)
else:
    max30102 = JUXI_HeartRate_SPO2_uart(9600)

def setup():
    while not max30102.begin():
        print("init fail!")
        time.sleep(1)
    print("start measuring...")
    max30102.sensor_start_collect()
    time.sleep(1)

def loop():
    max30102.sensor_read_data()
    hr = max30102.sensor_get_heartRate()
    spo2 = max30102.sensor_get_spo2()
    if hr > 0 and spo2 > 0:
        print(f"Heart Rate: {hr} bpm, SpO2: {spo2}%")
    time.sleep(0.1)

if __name__ == "__main__":
    setup()
    try:
        while True:
            loop()
    except KeyboardInterrupt:
        print("Program ended")

Host Application

Juxi Technology provides a Windows visual host application for real-time heart rate and SpO2 waveform display:

Host Application Screenshot

  • Repo path: HeartRateOximeter/上位机源代码/HeartRateOximeter.py
  • Download: GitHub Releases

FAQ

Q: Initialization fails (init fail)?

A: Verify wiring is correct. For IIC mode, check the device address (default 0x57). For UART mode, confirm the baud rate is 9600.

Q: Unstable readings?

A: Ensure the sensor has good skin contact. Keep your finger steady on the sensor and avoid movement.

Q: How to use on Windows?

A: Refer to the example code and documentation in the repo's python/windows/ directory.

Support