Interfacing MAX30100 Pulse Oximeter with Arduino

Interfacing MAX30100 Pulse Oximeter with Arduino

Summary

Are looking to build a pulse oximeter using an Arduino? Look no further than the MAX30100 sensor module. In this informative blog, we'll take a closer look at what the MAX30100 sensor is, how it works, and how you can interface it with an Arduino to build your very own pulse oximeter. Whether you're a beginner or an experienced Arduino enthusiast, this blog is sure to provide valuable insights into this exciting project.

What is the MAX30100 sensor?

MAX30100 sensor is a device that is used to monitor the heart rate and it is also used as a pulse oximeter. The Pulse oximeter consists of Light-emitting diodes and an IR sensor. And signal processing unit to improve the quality of the output signal. It works on the input voltage of 1.8V to 3.3V.

How does the MAX30100 sensor module?

Whenever we breathe in oxygen, the oxygen enters our lungs and passed into our blood. The blood carries oxygen to various organs of our body. Blood carries oxygen to our body, by means of hemoglobin. During a pulse oximetry reading, a small clam-like device is attached to our finger, earlobe, or toe.

 

A small beam of light is passed through the finger. This light passes the finger and is used to measure the content of oxygenated or deoxygenated blood.

 

 

read more :  How 433MHz RF Module Works & Interfacing With Arduino

Working of MX30100 pulse oximeter sensor:

The sensor has two light-emitting diodes and one photodiode. The LED’s are used to emit the light and the photodiode is used to detect and measure the intensity of the received light. In MAX30100 one LED emits monochromatic light and the other LED emits infrared light.

 

 

What is the MAX30100 sensor

 

 

The MAX30100 pulse oximeter can measure both the heart pulse rate and the oxygen level in the blood. The Redlight that the red LED emits is used to measure the pulse rate. And for measuring the oxygen level, both the LEDs are used.

 

 

 

 

 

When the heart pumps the blood, the oxygenated blood is increased in the body. And when the heart relaxes the volume of the oxygenated blood is decreased in the body. As a result, the time variation in the change of the volume of the oxygenated blood, the pulse rate are calculated. (One variation = one pump of the heart). This whole change in the light is detected and measured by the photodiode.

 

The oxygen content is measured by using both the Light-emitting diodes. The oxygenated blood in our body absorbs more infrared light and allows red light to pass through it. And the deoxygenated blood absorbs more red light and allows infrared light to pass through it. The photodiode in the MAX30100 sensor is used to measure the change in the intensity of the light. Using this photodiode, the intensity of the light which is passed into the finger and the through the blood is measured by the photodiode and passes the signal to the analog to digital converter and gives the output data in form of I2c serial communication protocol. And using a microcontroller the pulse rate and the blood oxygen measurement are monitored.

 

 

read more : Arduino Sensor types and Applications

How to interface MAX30100 Pulse oximeter with Arduino?

As we know that the MAX30100 Pulse oximeter sensor works on the I2C communication protocol, we have to find out the I2C pins of our Arduino. In the case of Arduino UNO, A4 and A5 will be the I2C pins. The A4 and A5 are SDA and SCL respectively of the Arduino UNO.

 

 interface MAX30100 Pulse oximeter with Arduino

 

 

The connection has to be made as shown in the below diagram. If you are using Arduino UNO.

 

Arduino UNO Side

MAX30100 Side

5V

VIN

GND

GND

A4

SDA

A5

SCL

 

 

read more : Difference Between Arduino and Raspberry Pi

 

Code:

The below code is used to display the Pulse and the oxygen reading.

 

#include <Wire.h>

#include "MAX30100_PulseOximeter.h"

 

#define REPORTING_PERIOD_MS     1000

// Create a PulseOximeter object

PulseOximeter pox;

// Time at which the last beat occurred

uint32_t tsLastReport = 0;

// Callback routine is executed when a pulse is detected

void onBeatDetected() {

   Serial.println("Beat!");

}

void setup() {

   Serial.begin(9600);

   Serial.print("Initializing pulse oximeter..");

   // Initialize sensor

   if (!pox.begin()) {

       Serial.println("FAILED");

       for(;;);

   } else {

       Serial.println("SUCCESS");

   }

   // Configure sensor to use 7.6mA for LED drive

   pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

   // Register a callback routine

   pox.setOnBeatDetectedCallback(onBeatDetected);

}

void loop() {

   // Read from the sensor

   Pox update();

   // Grab the updated heart rate and SpO2 levels

   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();

   }

}

 

Explanation:

Let’s start at the top of the example. Two libraries viz. MAX30100_PulseOximeter.h and Wire.h are included, a constant called REPORTING_PERIOD_MS is defined to delay the measurements, PulseOximeter object is created and a variable called tsLastReport is created to store the time at which the last beat occurred.

 

#include <Wire.h>

#include "MAX30100_PulseOximeter.h"

#define REPORTING_PERIOD_MS     1000

PulseOximeter pox;

uint32_t tsLastReport = 0;

 

Next, a callback routine is defined which is executed when a pulse is detected. You can write some interesting code in it, for example, to watch the built-in LED blink with your heartbeat!

 

void onBeatDetected() {

   Serial.println("Beat!");

}

Next let’s look at the setup. There are three functions to point out. First, the pox.begin() function call makes sure that we can communicate with the sensor. begin() function returns 1 on success (or 0 if it fails). It also configures the MAX30100 to begin collecting data.

 

if (!pox.begin()) {

   Serial.println("FAILED");

   for(;;);

} else {

   Serial.println("SUCCESS");

}

 

Secondly and equally as important the setIRLedCurrent() function sets the current through the IR LED. The following line sets the current of 7.6mA through the IR LED.

 

 pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

 

By default the library sets the IR LED current to 50mA which can sometimes cause problems like the LED not turning on or getting the Initializing pulse oximeter.. FAILED message on the serial monitor. In that case, set the LED current to a lower value. Here are the other possible values you can use on the setIRLedCurrent() function.

 

 

  • MAX30100_LED_CURR_0MA
  • MAX30100_LED_CURR_4_4MA
  • MAX30100_LED_CURR_7_6MA
  • MAX30100_LED_CURR_11MA
  • MAX30100_LED_CURR_14_2MA
  • MAX30100_LED_CURR_17_4MA
  • MAX30100_LED_CURR_20_8MA
  • MAX30100_LED_CURR_24MA
  • MAX30100_LED_CURR_27_1MA
  • MAX30100_LED_CURR_30_6MA
  • MAX30100_LED_CURR_33_8MA
  • MAXlearnedLED_CURR_37MA
  • MAX30100_LED_CURR_40_2MA
  • MAX30100_LED_CURR_43_6MA
  • MAX30100_LED_CURR_46_8MA
  • MAX30100_LED_CURR_50MA

Remember! The higher the current, the brighter the LED and the deeper it reaches your skin. So, you can play with it while you figure it out.

Finally setOnBeatDetectedCallback() registers callback’s the function.

 

 pox.setOnDetectedCallback(onBeatDetected);

In the main loop, the biometric data is collected from the MAX30100 sensor with the update()  function. It pulls data in from sensor FIFO.  (FIFO: The buffer that stores data samples from the sensor. The FIFO has a 16-sample memory bank, which means it can hold up to 16 SpO2 and heart rate samples)

 

 pox.update();


We then print the biometric data on the serial monitor once every second (REPORTING_PERIOD_MS is set to 1000; change it as per your requirement). For this we use millis() instead of delay(). Since delay() pauses the entire code, we cannot get the updated measurement.

 

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();

   }

 

Serial Monitor:

 

 

 

read more :  Top 10 Arduino Projects to Get Started With

Also, read our blog on Arduino IR sensor explaining the required hardware and Arduino code for interfacing Arduino with IR sensor

Conclusion:

In this blog, we have learned, how the MAX30100 pulse oximeter sensor works and  interfaced with the Pulse Oximeter sensor with the Arduino microcontroller board. We have seen the components required and the code for reading the heart pulse rate and the volume of oxygen in the blood. So, don't wait any longer, get your hands on the MAX30100 and start exploring the endless possibilities today!

 

 

If you appreciate our work don't forget to share this post and leave your opinion in the comment box.

 

Please do check out other blog posts about Interfacing ACS712 with Arduino , Arduino Interfacing with Ultrasonic Sensor , LED Interfacing with Arduino , Interfacing GSM Module with Arduino , IR Sensor Interfacing with Arduino , How to connect ZMPT101B to Arduino and  How to use Buzzer with Arduino.

 

Make sure you check out our wide range of products and collections (we offer some exciting deals!)

You may also like to read

Frequently Asked Questions

1. Which is better MAX30100 or MAX30102?

The MAX30100 comes with a 16-bit FIFO and the MAX30102 comes with a 32-bit FIFO. This means the MAX30102 has higher storage, which is transferred to the microcontroller

read more :  Arduino Uno Pin Diagram: A Complete Guide

2. How do I test my MAX30100 sensor?

The MAX30100 sensor can be tested by running the I2C detect code from Arduino and then printing the MAX30100 values on the serial monitor by running the code mentioned above in the blog. If the values of the Heart rate and the SpO2 value changes to the normal readings (60 to 100 beats per minute and Sp02 as 90-95%), when the finger is placed on the sensor. Then the sensor can be considered as working. If any part of this process fails, then the sensor might be faulty.

read more :  IoT and DIY Smart Car Starter Kit

3. What is MAX30100 used for?

The MAX sensor can function as a heart rate monitor and pulse oximeter, utilizing LEDs, photodetectors, and optimized optics along with low-noise analog signal processing. It uses an I2C interface and is compatible with various microcontrollers including Arduino. This sensor is popularly used by researchers, hobbyists, and students for monitoring blood oxygen levels and heart rate.

4. Can MAX30100 measure blood pressure?

The MAX30100 can detect heart rate and pulse oximetry, which indicates the oxygen level of blood. However, it is unable to measure blood pressure.

read more : Arduino Pin Configuration

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.

You may also like to read