DIY Pulse Oximeter by interfacing MAX30100 sensor with Arduino

DIY Pulse Oximeter by interfacing MAX30100 sensor with Arduino DIY Pulse Oximeter by interfacing MAX30100 sensor with Arduino

In this detailed tutorial, learn how to build a pulse oximeter using MAX30100 sensor with Arduino and display the Heart rate BPM and blood oxygen level termed as SpO2 values on serial monitor, LCD display or OLED Display.

So before getting started into the project lets learn about the principles, working and applications of the MAX30100 sensor and learn how the sensor calculates the Heart rate and Blood Oxygen levels.

What is Pulse Oximeter and how do they work ?

Pulse Oximeter is a device used to measure the amount of oxygen present in the blood.

How Oxygen enters and leaves our body?

When we inhale the air, Oxygen from the air is taken by the lungs and moves through the paper thin small capillary tubes, a protein named hemoglobin which is present in the Red blood cells dissolves this oxygen into blood and send it to the left side of heart which pumps it through out the body through arteries. And brings back the carbon dioxide to the right side of the heart which further goes out through the exhaling process.

Principle of Pulse Oximeters

According to biology oxygenated blood absorbs more infrared light and passes red light through it than deoxygenated blood. So by using this principle Pulse oximeters are equipped with one Infra red and red light LEDs together which emit them to know the passage of infra red and red lights.

ir rays on fingers for blood oxygen detection

When the heart pumps blood the oxygenated blood in the body increases and when the heart relaxes the oxygenated blood decreases, with the help of sensors the time difference between the increase and decrease in the volume of oxygen in blood is calculated, which is nothing but Pulse rate.

Working of MAX30100 Pulse Oximeter sensor

The MAX30100 pulse oximeter sensor is equipped with one IR LED and one Red LED, which emits the IR and light respectively the LED current can be configured through programming.

When the sensor is turned on the both IR and Red LEDs glow. For example, if we place the finger on the sensor the rays pass through the finger according to the oxygen levels in the body according to the biology principle, and another photo sensor collect the remaining rays after absorption and produces signal which is later converted into digital signals and the communicated to the microcontroller through I2C bus interface.

For the detailed work flow look at the below functional diagram of MAX30100 pulse oximeter sensor:

Functional Diagram of MAX30100 pulse oximeter sensorSo, we learnt about how MAX30100 pulse oximeter works. now, let’s learn about features and applications.

Features of MAX30100 pulse oximeter sensor

MAX30100 is small and compact chip with complete pulse oximetry and heart rate sensor system developed for the need of monitoring them in wearable devices. It is equipped with low noise analog signal processing with ambient light cancellation to detect pulse and heart rate signals.

  • Ultra-Low-Power Operation ( can be adjustable through programming)
  • Ultra-Low Shutdown Current (0.7µA, typ)
  • Operating Voltage 1.8V – 5.5V.

Applications of MAX30100 sensor

  • Wearable Devices
  • Fitness Assistant Devices
  • Medical Monitoring Devices

MAX30100 Pulse Oximeter Sensor Module

The MAX30100 is a device that integrates a pulse oximeter and a heart rate monitor. It has two LEDs: a red led (660nm) and an infrared led (920nm), a photodetector, specialized optics, an ambient light filter between 50 and 60Hz, and a 16-bit delta sigma ADC converter with up to 1000 samples per second. It also has an internal temperature sensor to compensate for the effects of temperature in the measurement.

The MAX30100 needs two voltages to operate: 1.8V and 3.3V, so this module includes both on-board voltage regulators, that way only a 5V source is needed for power. Its current consumption is minimal, making it ideal for portable applications. It can be used in medical monitoring equipment, fitness assistants and wearables in general.

max30100 pulse sensor

Notes:  Instead of buying this MAX30100(RCWL-0530) version we recommend you to buy GY-MAX30100 which doesn’t have any design errors and we can directly plug and use.

GY-MAX30100 MODULEThis is same but has no design issues, you can use it same as old MAX30100 with all the circuit diagrams same.

Interfacing MAX30100 Pulse Oximeter sensor with Arduino to display values on Serial monitor

Now let us interface the MAX30100 Pulse Oximeter sensor with Arduino to display the blood oxygen levels i.e., SpO2 on serial monitor. First lets know what are the components required for this project, circuit diagram, Arduino libraries and then the program to work with.

Components Required

  • Arduino Uno Board
  • MAX30100 pulse oximeter sensor module
  • Few connecting wires

Circuit diagram

Now lets connect all the required components listed above according to the below schematic diagram to display the blood SpO2 on the serial monitor.

interfacing Max30100 pulse oximeter sensor with arduino to print values on serial monitorAs you can see from the above diagram we connected the SCL and SDA of the sensor to A5 and A4 of Arduino respectively. The VIN and GND of the sensor are connected to the 3v3 or 5V and GND pins of Arduino respectively. That it for connections power up the Arduino and connect it the pc for the next code upload step.

This connection not only works for Arduino UNO but also works for Arduino pro mini, Arduino Nano to Arduino mega. Just refer the pin diagrams of them and connect the SCL and SDA from sensor to the Board.

Source code:

Power up the Arduino and connect it to the pc where Arduino IDE is installed. Copy and paste the below code to the Arduino IDE and select the correct COM port and Board, and then hit the upload button to upload the code.

For the code to work you need the following Arduino library which you can install from the Sketch->Include Library or directly download from this link.

#include <Wire.h>
#include "MAX30100_PulseOximeter.h" //library initialization
 
#define REPORTING_PERIOD_MS     1000 //update frequency 1000ms
 
PulseOximeter pox;
uint32_t tsLastReport = 0;
 
void onBeatDetected()
{
    Serial.println("Beat!");
}
 
void setup()
{
    Serial.begin(115200);
    Serial.print("Initializing pulse oximeter..");
 
    // Initialize the PulseOximeter instance
    // Failures are generally due to an improper I2C wiring, missing power supply
    // or wrong target chip
    if (!pox.begin()) {
        Serial.println("FAILED");
        for(;;);
    } else {
        Serial.println("SUCCESS");
    }
     pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
 
    // Register a callback for the beat detection
    pox.setOnBeatDetectedCallback(onBeatDetected);
}
 
void loop()
{
    // Make sure to call update as fast as possible
    pox.update();
    if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
        Serial.print("Heart rate:");
        Serial.print(pox.getHeartRate());
        Serial.print("bpm / SpO2:");
        Serial.print(pox.getSpO2());
        Serial.println("%");
 
        tsLastReport = millis();
    }
}

Output:

After uploading the code open serial monitor and set the baud rate to 115200 to get the heart rate and blood SpO2 values on the serial monitor as shown in the below output image.

max30100 pulse oximeter sensor with arduino output on serial monitor

Interfacing MAX30100 Pulse Oximeter sensor with Arduino to display values on LCD display with I2C Adapter

Here in this version we are adding an 16X2 LCD display module to display the values on it. this makes it portable and can use it anywhere with out the need of PC to display the output values. Lets learn how to add 16X2 LCD display to MAX30100 pulse oximeter sensor and Arduino.

Required components

  • Arduino UNO board
  • MAX30100 pulse oximeter sensor module
  • 16X2 LCD display module with I2C adapter
  • Few connecting wires

Circuit Diagram:

Now connect all the above required components as shown in the below circuit diagram image.

interfacing Max30100 pulse oximeter sensor with arduino to print values on lcd displayAs you can see from the above image we connected 16X2 LCD display with I2C adapter which takes very few connecting wires than the normal one. we connected the VCC and GND of LCD display module to the 5V and GND of the Arduino board and SDA and SCL of the LCD module to A4 and A5 of Arduino respectively. The connection between pulse oximeter sensor the Arduino remains same as the previous version.

Source code:

After connecting as per the circuit diagram connect the Arduino to PC where Arduino IDE is installed, then copy and paste the below code and install the required libraries and then hit upload the code button.

Required Libraries:

#include <LiquidCrystal_I2C.h> //#include < Wire .h> we are removing this because it is already added in liquid crystal library
#include "MAX30100_PulseOximeter.h"
 
// Create the lcd object address 0x27 and 16 columns x 2 rows 
LiquidCrystal_I2C lcd (0x27, 16,2); //we can find the address through I2C address scanner
 
#define REPORTING_PERIOD_MS     1000
 
PulseOximeter pox;
uint32_t tsLastReport = 0;
 
void onBeatDetected()
{
    Serial.println("Beat!");
}
 
void setup()
{
    Serial.begin(115200);
    Serial.print("Initializing pulse oximeter..");
    lcd.init ();
    lcd. backlight ();
    lcd.print("Initializing...");
    delay(3000);
    lcd.clear();
 
    // Initialize the PulseOximeter instance
    // Failures are generally due to an improper wiring, missing power supply
    if (!pox.begin()) {
        Serial.println("FAILED");
        for(;;);
    } else {
        Serial.println("SUCCESS");
    }
     pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
 
    // Register a callback for the beat detection
    pox.setOnBeatDetectedCallback(onBeatDetected);
}
 
void loop()
{
    // Make sure to call update as fast as possible
    pox.update();
    if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
        Serial.print("Heart rate:");
        Serial.print(pox.getHeartRate());
        Serial.print("bpm / SpO2:");
        Serial.print(pox.getSpO2());
        Serial.println("%");
 
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print("BPM : ");
        lcd.print(pox.getHeartRate());
        
        lcd.setCursor(0,1);
        lcd.print("SpO2: ");
        lcd.print(pox.getSpO2());
        lcd.print("%");
 
        tsLastReport = millis();
    }
}

Output:

After uploading the code press reset button on the Arduino to restart the code execution, then you can see the BPM heart rate and SpO2 blood oxygen level values are displayed on the LCD display module as shown in the below output image.

max30100 pulse oximeter with lcd display and arduino output

Interfacing MAX30100 Pulse Oximeter sensor with Arduino to display values on OLED Display module

In the same way you can interface the OLED display module to display the values on it. Just use the OLED Arduino library and connect it the same way as LCD module SCL and SDA. And editing few lines of code will achieve this version.

Faults and Errors in MAX30100 pulse Oximeter sensor module and methods to solve this errors.

The normal cheaper version of MAX30100(RCWL-0530) pulse oximeter sensor has a design issue which leads to errors and sensor won’t work as expected. So to remove the design error we came up with two methods which can help you solve the issue. So first lets se where is the design error from below module circuit diagram image.

max30100 design issue schematic diagramAs you can see from the above image the 3 4.7k ohms resistors are powered from the 1.8v power supply which is not enough for most of the microcontroller boards with higher logic levels.

So to solve this issue we need to power them up with higher voltage, we can achieve this in 2 methods.

Method 1:

In this method remove the 3 resistors from the board and add external resistors. connect the resistors as shown in the below image.

method to solve design error in max30100 pulse oximeter moduleFrom the above image you can see all the  images are removed and 3 external 4.7k ohm resistors are added to SDA, SCL and INT pins and INT pin is connected to digital pin 2 of Arduino.

This is a hard process where it is difficult to remove the very tiny resistors from the module so we came up with another method where you can just add a wire to make a track.

Method 2: 

In this method a small piece of connecting wire is connected between 2 points of the modules as shown in the below image where point 1 is where are resistors are in parallel and point 2 is where we can get 3.3v.

method 2 max30100 pulse sensor error removalNotes:  Instead of buying this MAX30100(RCWL-0530) version we recommend you to buy GY-MAX30100 which doesn’t have any design errors and we can directly plug and use.

Related article: ECG Monitoring system with Arduino or ESP32

Rules to follow

  • It may generate incorrect readings if the finger is not placed correctly
  • Make sure you do not move your finger which can result in an in correct reading.
  • The ambient light falling on the sensor can affect the final reading while using the sensor.
  • Never press the the sensor too hard as this affect the blood flow which results in getting an incorrect reading.
  • Try to place your finger softly and make sure it doesn’t move, in this way you can get the most accurate results.
5 comments
  1. I TRIED SECOND METHOD BUT STILL NOT WORKING
    MY FRIENDS ARE USING SAME OXIMETER WITHOUT ANY CHANGES BUT IN THEIR THEY ARE NOT GETTING ANY ERRORS
    I AM USING ARDUINO UNO AND THEY ARE USING ATMEGA32 CONTROLLER
    IS IT DUE TO THIS
    AS OUR CODES ARE ALSO SIMILAR

  2. I am getting “initializing pulse oximeter failed” note on serial monitor output…I am using NodeMCU esp8266 module…please help, sensor GY-30100, Oled diaplay

Leave a Reply

Your email address will not be published. Required fields are marked *