
Interfacing MAX30100 Pulse Oximeter with Arduino
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.
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.
Β
Β
Β
Β
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.
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.
Β
Β
Β
Β
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 |
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:
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!)
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
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.
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.
Components and Supplies
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
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.
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.