Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Raspberry Pi 5 Heart Rate and SpO2 Monitor with MAX30102 and OLED Display

View and Edit Project In Cirkit DesignerImage of Raspberry Pi 5 Heart Rate and SpO2 Monitor with MAX30102 and OLED Display

Circuit Documentation

Summary

This circuit integrates a MAX30102 pulse oximeter and heart-rate sensor, a 0.96" OLED display, and a Raspberry Pi 5. The Raspberry Pi 5 serves as the main microcontroller, interfacing with the MAX30102 sensor to read heart rate and SpO2 levels and displaying the readings on the OLED display.

Component List

MAX30102

0.96" OLED

Raspberry Pi 5

Wiring Details

MAX30102

0.96" OLED

Raspberry Pi 5

Documented Code

Raspberry Pi 5 Code

/*
 * This Arduino Sketch reads heart rate, pulse rate, and SpO2 using the MAX30102
 * sensor and displays the readings on a 0.96" OLED display. The Raspberry Pi 5
 * is used as the microcontroller to interface with the sensor and the display.
 */

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "MAX30105.h"
#include "spo2_algorithm.h"

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

MAX30105 particleSensor;

void setup() {
  Wire.begin();
  Serial.begin(115200);

  if (!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) {
    Serial.println(F("MAX30105 was not found. Please check wiring/power."));
    for (;;);
  }
  particleSensor.setup();
  particleSensor.setPulseAmplitudeRed(0x0A);
  particleSensor.setPulseAmplitudeGreen(0);
}

void loop() {
  long irValue = particleSensor.getIR();
  if (checkForBeat(irValue) == true) {
    float beatsPerMinute = 60 / getTimeBetweenBeats();
    float SpO2 = calculateSpO2();

    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0, 0);
    display.print(F("Heart Rate: "));
    display.print(beatsPerMinute);
    display.print(F(" BPM"));
    display.setCursor(0, 10);
    display.print(F("SpO2: "));
    display.print(SpO2);
    display.print(F(" %"));
    display.display();
  }
  delay(1000);
}

Additional Code