Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA

MAX30102 With Arduino: Heart Rate & SpO2 Monitor

MAX30102 With Arduino: Heart Rate & SpO2 Monitor
-
Written By - Robocraze -
📅 Updated on 18 Nov 2026
✨ Summarize with AI
✅ Prompt copied

Summary

Learn how to build a heart rate and SpO2 monitor with the MAX30102 and Arduino. We cover the pinout, a MAX30100 comparison, wiring to an Arduino UNO and ESP32, library setup and code, an OLED display add-on, and practical tips for stable readings. A student project, not a medical device.

MAX30102 With Arduino: Build a Heart Rate and SpO2 Monitor (Wiring + Code) - Cover Image

The MAX30102 is an optical sensor that shines red (660 nm) and infrared (880 nm) light into a fingertip and measures how much of it is reflected back. An Arduino reads these values over I2C at address 0x57 and calculates heart rate and blood oxygen saturation (SpO2) from them.

In this tutorial, we cover the pinout, the MAX30100 comparison, wiring to an Arduino UNO and ESP32, heart rate and SpO2 code, and an OLED display.

Disclaimer: This is a student project, not a medical device. The readings are not calibrated against a certified pulse oximeter. Do not use them to diagnose, monitor or treat any health condition.

What Is the MAX30102?

The MAX30102 is a pulse oximeter and heart rate sensor from Maxim Integrated, now part of Analog Devices. It combines a red LED, an IR LED, a photodetector and an 18-bit ADC in one package that talks to a microcontroller over I2C.

It works on photoplethysmography (PPG). Each heartbeat pushes a small surge of blood into the fingertip, which changes how much light the tissue absorbs. Counting these ripples gives heart rate.

For SpO2, the sensor compares the two colours: oxygen-rich haemoglobin absorbs more infrared light, and oxygen-poor haemoglobin absorbs more red light. Our guide on what a pulse sensor is explains PPG in more detail.

MAX30102 Sensor Workflow Chart

The sensor only measures light. Every number is calculated on the Arduino, so the result depends on the algorithm, the finger placement and how still the finger stays. For other health sensors, see our beginner's guide to biomedical sensors.

Components and Supplies

MAX30102 Pulse Oximeter Sensor – Accurate heart rate & SpO2 sensor. -Heart Rate Sensor -Biomedical Sensor -RobocrazeMAX30102 Pulse Oximeter Sensor – Accurate heart rate & SpO2 sensor. -Heart Rate Sensor -Biomedical Sensor -Robocraze

    MAX30102 Pulse Oximeter Heart Rate Sensor Module

    MAX30102 Pulse Oximeter Heart Rate Sensor Module The MAX30102 Pulse Oximeter Heart Rate Sensor Module is a compact optical sensing solution for measuring pulse-related signals and developing heart-rate and SpO2 monitoring projects. It combines red and infrared LEDs, a photodetector, ambient-light rejection and low-noise...
    Rs 249/-
    Rs 249/-
    Rs 369/-
    Save Rs 120/-
    MAX30102 3.3 to 5V Pulse Oximeter & Heart Rate Sensor Module (Black) -Sensors -Biomedical Sensors -RobocrazeMAX30102 3.3 to 5V Pulse Oximeter & Heart Rate Sensor Module (Black) -Sensors -Biomedical Sensors -Robocraze

    MAX30102 3.3 to 5V Pulse Oximeter & Heart Rate Sensor Module (Black)

    MAX30102 3.3 to 5V Pulse Oximeter & Heart Rate Sensor Module (Black) The MAX30102 3.3 to 5V Pulse Oximeter & Heart Rate Sensor Module (Black) is an integrated biosensor module designed for heart rate and blood oxygen (SpO₂) monitoring in electronic and wearable projects....
    Rs 265/-
    Rs 265/-
    Rs 299/-
    Save Rs 34/-
    Original Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -RobocrazeOriginal Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -Robocraze

    Arduino Uno R3 Original

    Arduino UNO R3 Original The Arduino Uno R3 is a microcontroller board based on the ATmega328P chip and is widely recognized as the best original Arduino Uno board for beginners and projects. This board has 14 digital I/O pins (6 support PWM), 6 analog...
    Rs 2,750/-
    Rs 2,750/-
    Rs 3,499/-
    Save Rs 749/-
    Arduino Nano Original – Classic ATmega328 board for compact projects. -Original Arduino Board -RobocrazeArduino Nano Original A000005

    Arduino Nano Original A000005

    Arduino Nano Original A000005 The Arduino Nano Original Board is a compact, versatile, and 100% genuine development board built around the ATmega328P microcontroller. Unlike unreliable clone boards, this official Arduino product guarantees stable driver recognition, consistent performance, and long-term durability for your electronics projects....
    Rs 2,299/-
    Rs 2,299/-
    Rs 3,599/-
    Save Rs 1,300/-
    🔥 Trending
    ESP32 NodeMCU (38-Pin) WiFi + BLE – Ideal for IoT. -Nodemcu ESP Board -RobocrazeESP32 NodeMCU (38-Pin) WiFi + BLE – Ideal for IoT. -Nodemcu ESP Board -Robocraze

      ESP32 38-Pin WiFi + Bluetooth NodeMCU Development Board

      ESP32 38-Pin WiFi + Bluetooth NodeMCU Development Board The ESP32 38-Pin WiFi + Bluetooth NodeMCU Development Board is a versatile microcontroller development board designed for IoT, home automation, robotics, embedded systems, and wireless electronics projects. Built around the ESP-WROOM-32 module, it combines a powerful...
      Rs 422/-
      Rs 422/-
      Rs 599/-
      Save Rs 177/-
      0.96 Inch OLED Display Module SPI/I2C 4pin Blue Color -Displays -OLED Display -Robocraze0.96 Inch OLED Display Module SPI/I2C 4pin Blue Color -Displays -OLED Display -Robocraze

        0.96 Inch OLED Display Module SPI/I2C 4pin Blue Color

        0.96 Inch OLED Display Module SPI/I2C - 4pin Blue Color This is the 0.96" OLED display module 4 pin, it is made of 128x64 individual blue OLED pixels, and each one is turned on or off by the controller chip. It works without a backlight,...
        Rs 225/-
        Rs 225/-
        Rs 299/-
        Save Rs 74/-
        400 Tie Points Solderless Breadboard – Medium-sized breadboard for Arduino & projects. Electronic Components - Robocraze400 Tie Points Solderless Breadboard – Medium-sized breadboard for Arduino & projects. Electronic Components - Robocraze

          400 Point Solderless Breadboard (Half Breadboard)

          400 Point Solderless Breadboard (Half Breadboard) Looking for the best breadboard price without compromising on quality? This 400 point breadboard (commonly known as a half breadboard) is perfect for building and testing electronics, especially with Arduino and ESP32 projects. It’s made of strong plastic...
          Rs 39/-
          Rs 39/-
          Rs 69/-
          Save Rs 30/-
          Jumper Wire Set - M2M, M2F, F2F (40 pcs each) – Ideal for Arduino & prototyping. Electronic Components - RobocrazeJumper Wire Set - M2M, M2F, F2F (40 pcs each) – Ideal for Arduino & prototyping. Electronic Components - Robocraze

            Jumper Wire Set - M2M, M2F, F2F (40 pcs each)

            Jumper Wire Set - M2M, M2F, F2F (40 pcs each) These DuPont jumper wires for electronics are premium quality wire manufactured by using quality assured material and advanced techniques, which make them up to the standard in this highly challenging field. This 120pcs Dupont...
            Rs 164/-
            Rs 164/-
            Rs 169/-
            Save Rs 5/-
            3M USB to Micro USB Cable Black3M USB to Micro USB Cable Black – High-quality Arduino USB Cable for fast charging & data transfer. -Robocraze

              3M USB to Micro USB Cable Black

              3M USB to Micro USB Cable Black - (Compatible with Smart Phones, Tablets, Power Bank, Black) Tired of short cables that limit where you can use your devices? The 3M USB to Micro USB Cable in Black is here to help. It’s 3 meters...
              Rs 138/-
              Rs 138/-
              Rs 199/-
              Save Rs 61/-
              4.7k Ohm Resistor (10PC) – Analog & signal processing resistors. -Basic Components -Robocraze4.7k Ohm Resistor (10PC) – Analog & signal processing resistors. -Basic Components -Robocraze

                4.7k Ohm Resistor - (Pack of 10)

                4.7k Ohm Resistor - (Pack of 10) 4.7k ohm Carbon Film Resistors are typical axial-lead resistors, which have much better temperature stability and provide lower noise, and are generally better for high frequency or radiofrequency applications. Excellent Noise Suppression, Moisture-Proof, High Temperature Resistance And Long...
                Rs 12/-
                Rs 12/-
                Rs 19/-
                Save Rs 7/-

                MAX30102 Pinout and Specs

                Most MAX30102 modules have seven pins in a row. We only need four of them: VIN, GND, SDA and SCL.

                MAX30102 Module Pinout Diagram
                Pin Function Used here?
                VIN Power input, 3.3V to 5V Yes
                SCL I2C clock Yes
                SDA I2C data Yes
                INT Interrupt output Optional
                IRD External IR LED drive No
                RD External red LED drive No
                GND Ground Yes
                Specification Value
                LEDs Red 660 nm, infrared 880 nm
                Module supply 3.3V to 5V (chip core runs at 1.8V)
                Interface I2C, up to 400 kHz, address 0x57
                ADC resolution Up to 18-bit
                Sample rate 50 to 3200 samples per second
                FIFO buffer 32 samples
                Operating temperature -40 °C to +85 °C

                Important: Some modules connect their I2C pull-up resistors to the chip's 1.8V supply, which a 5V Arduino UNO may not read reliably. We cover the fix in the wiring section.

                MAX30102 vs MAX30100

                The MAX30102 is the successor to the MAX30100. Both use red and IR LEDs and the same I2C address, but the MAX30102 has a finer ADC, a larger buffer and a faster sample rate.

                Feature MAX30102 MAX30100
                ADC resolution Up to 18-bit Up to 16-bit
                FIFO buffer 32 samples 16 samples
                Maximum sample rate 3200 samples/s 1000 samples/s
                I2C address 0x57 0x57
                Common Arduino library SparkFun MAX3010x MAX30100lib (oxullo)

                For new projects, we recommend the MAX30102. The two chips use different registers, so code written for one will not run on the other.

                Already have a MAX30100 module? Follow our MAX30100 Arduino heart rate sensor tutorial instead.

                Parts list

                Wiring to Arduino UNO and ESP32

                The MAX30102 needs only four wires. INT, IRD and RD stay unconnected.

                MAX30102 pin Arduino UNO / Nano ESP32 (DevKit)
                VIN 5V 3.3V
                GND GND GND
                SDA A4 GPIO 21
                SCL A5 GPIO 22

                On an ESP32, power the module from 3.3V, because the ESP32's pins are not 5V tolerant. On an Arduino Mega, SDA is pin 20 and SCL is pin 21.

                Wiring to Arduino UNO and ESP32

                Check the I2C pull-up voltage on your module

                Many purple MAX30102 boards pull SDA and SCL up to 1.8V. A 5V UNO often cannot read that as a logic HIGH, so the sketch reports "MAX30102 not found" even when the wiring is correct.

                There are two ways to fix this:

                1. Move the solder jumper. Look for a three-pad jumper near the resistors on the module. Move the solder bridge from the 1.8V side to the 3.3V side.
                2. Add external pull-ups. Connect a 4.7 kΩ resistor from SDA to 3.3V and another from SCL to 3.3V.

                Black modules with built-in level shifting, and ESP32 boards, rarely have this problem.

                Library Setup and Code

                We use the SparkFun MAX3010x Pulse and Proximity Sensor Library, version 1.1.2. It supports the MAX30102 despite its MAX30105 class name, and it includes a beat detector and Maxim's SpO2 algorithm.

                Install the library

                1. In the Arduino IDE, go to Sketch > Include Library > Manage Libraries.
                2. Search for MAX3010x and install SparkFun MAX3010x Pulse and Proximity Sensor Library by SparkFun Electronics.
                3. For an ESP32, also install the ESP32 board package from Tools > Board > Boards Manager.

                Code 1: Heart rate (BPM)

                This sketch detects each heartbeat in the IR signal and prints the BPM with a four-beat average.

                #include <Wire.h>
                #include "MAX30105.h"
                #include "heartRate.h"
                
                MAX30105 sensor;
                byte rates[4];
                byte rateIndex = 0;
                long lastBeat = 0;
                
                void setup() {
                  Serial.begin(115200);
                  if (!sensor.begin(Wire, I2C_SPEED_FAST)) {
                    Serial.println("MAX30102 not found");
                    while (1);
                  }
                  sensor.setup();                     // default settings
                  sensor.setPulseAmplitudeRed(0x0A);  // dim red LED, IR does the work
                }
                
                void loop() {
                  long ir = sensor.getIR();
                  if (ir < 50000) {                   // no finger on the sensor
                    Serial.println("No finger detected");
                    return;
                  }
                  if (checkForBeat(ir)) {
                    float bpm = 60000.0 / (millis() - lastBeat);
                    lastBeat = millis();
                    if (bpm > 30 && bpm < 220) {      // ignore noise
                      rates[rateIndex++ % 4] = bpm;
                      int avg = (rates[0] + rates[1] + rates[2] + rates[3]) / 4;
                      Serial.print("BPM: ");
                      Serial.print(bpm, 0);
                      Serial.print("   Avg: ");
                      Serial.println(avg);
                    }
                  }
                }

                An IR reading below 50,000 means nothing is on the sensor. checkForBeat() flags each pulse peak, and the sketch turns the time between two beats into BPM, discarding values outside 30 to 220.

                Code 2: Heart rate and SpO2

                SpO2 needs both LEDs and a few seconds of data. This sketch keeps a window of 100 samples (about 4 seconds), adds 25 new samples each second and reruns Maxim's algorithm.

                #include <Wire.h>
                #include "MAX30105.h"
                #include "spo2_algorithm.h"
                
                MAX30105 sensor;
                #define BUFFER_LEN 100
                
                // UNO: 16-bit buffers to fit in 2 KB of RAM
                #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
                  uint16_t irBuffer[BUFFER_LEN], redBuffer[BUFFER_LEN];
                  #define SHIFT 2
                #else
                  uint32_t irBuffer[BUFFER_LEN], redBuffer[BUFFER_LEN];
                  #define SHIFT 0
                #endif
                
                int32_t spo2, heartRate;
                int8_t validSPO2, validHR;
                uint32_t lastIR = 0;
                
                void readSamples(byte from, byte to) {
                  for (byte i = from; i < to; i++) {
                    while (!sensor.available()) sensor.check();
                    redBuffer[i] = sensor.getRed() >> SHIFT;
                    lastIR = sensor.getIR();
                    irBuffer[i] = lastIR >> SHIFT;
                    sensor.nextSample();
                  }
                }
                
                void setup() {
                  Serial.begin(115200);
                  if (!sensor.begin(Wire, I2C_SPEED_FAST)) {
                    Serial.println("MAX30102 not found");
                    while (1);
                  }
                  // brightness, averaging, mode 2 (red + IR), sample rate, pulse width, ADC range
                  sensor.setup(60, 4, 2, 100, 411, 4096);
                  readSamples(0, BUFFER_LEN);
                }
                
                void loop() {
                  for (byte i = 25; i < BUFFER_LEN; i++) {  // keep the newest 75 samples
                    redBuffer[i - 25] = redBuffer[i];
                    irBuffer[i - 25] = irBuffer[i];
                  }
                  readSamples(75, BUFFER_LEN);
                  
                  maxim_heart_rate_and_oxygen_saturation(irBuffer, BUFFER_LEN, redBuffer,
                        &spo2, &validSPO2, &heartRate, &validHR);
                        
                  if (lastIR < 50000) {
                    Serial.println("No finger detected");
                    return;
                  }
                  
                  Serial.print("HR: ");
                  if (validHR && heartRate > 30 && heartRate < 220) Serial.print(heartRate);
                  else Serial.print("--");
                  Serial.print(" bpm   SpO2: ");
                  if (validSPO2 && spo2 > 70 && spo2 <= 100) Serial.print(spo2);
                  else Serial.print("--");
                  Serial.println(" %");
                }

                Mode 2 turns on both LEDs, and a 411 µs pulse width gives the full 18-bit resolution. On the UNO, we scale each reading down by 4 to fit 16-bit buffers. This does not change the result, because SpO2 depends on the ratio between the two signals. The sketch prints -- whenever the algorithm marks a result as invalid.

                Upload and test

                Upload the sketch, open the Serial Monitor at 115200 baud and rest a fingertip lightly on the sensor. Valid readings appear after about 5 to 10 seconds.

                Example output (your values will differ):

                HR: -- bpm   SpO2: -- %
                HR: 76 bpm   SpO2: 97 %
                HR: 75 bpm   SpO2: 98 %
                No finger detected

                The first lines show -- while the buffer fills. Large jumps between lines usually mean the finger moved.

                Add an OLED Display

                A 0.96 inch SSD1306 OLED turns the project into a standalone monitor. The OLED uses I2C address 0x3C, so it shares the SDA and SCL pins with the MAX30102: connect its VCC, GND, SDA and SCL to the same pins as the sensor.

                MAX30102 and 0.96 inch OLED display sharing the Arduino UNO I2C pins A4 and A5

                We use the SSD1306Ascii library instead of Adafruit SSD1306, because the Adafruit library's 1 KB screen buffer leaves too little RAM on an UNO for the SpO2 buffers. Install it from the Library Manager by searching SSD1306Ascii. New to OLEDs? See our 0.96 inch OLED with Arduino and ESP32 guide.

                Start from Code 2 and make three changes. Add the library and display object at the top:

                #include "SSD1306Ascii.h"
                #include "SSD1306AsciiWire.h"
                
                SSD1306AsciiWire oled;

                Start the display at the beginning of setup():

                Wire.begin();
                oled.begin(&Adafruit128x64, 0x3C);
                oled.setFont(System5x7);

                Replace the Serial printing at the end of loop(), from Serial.print("HR: ") onwards:

                oled.clear();
                oled.set2X();
                oled.print("HR  ");
                if (validHR && heartRate > 30 && heartRate < 220) oled.println(heartRate);
                else oled.println("--");
                oled.print("O2% ");
                if (validSPO2 && spo2 > 70 && spo2 <= 100) oled.println(spo2);
                else oled.println("--");

                Getting Stable Readings

                Most problems come from how the finger sits on the sensor, not from the code.

                Finger pressure

                Rest the fingertip lightly and keep it still. Pressing hard squeezes blood out of the tissue and flattens the pulse. A rubber band or tape gives gentle, even pressure.

                Ambient light

                Sunlight or a desk lamp can swamp the sensor. Cover the finger and sensor, or build the project into an enclosure.

                3.3V logic and power

                If the sensor drops out at random, check the pull-up voltage described in the wiring section, and use short wires and a stable supply.

                Quick troubleshooting

                Problem Likely cause Fix
                "MAX30102 not found" SDA/SCL swapped or 1.8V pull-ups Check wiring, then apply the pull-up fix
                Always "No finger detected" Weak IR signal Cover the sensor fully; raise LED brightness
                BPM jumps around Movement or heavy pressure Press lightly and hold still
                IR value stuck at maximum Signal saturated Lower LED brightness to 30 to 40

                Conclusion

                With the readings stable, a natural next step is to use the ESP32's Wi-Fi to send heart rate and SpO2 to a phone or dashboard. Whatever we build on top of it, the MAX30102 stays a learning tool, not a replacement for a certified medical pulse oximeter.

                Excerpt

                MAX30102 Arduino tutorial: pinout, wiring and code for heart rate and SpO2, plus ESP32 setup, an OLED display, MAX30100 comparison and stability tips.

                Frequently Asked Questions

                1. How does the MAX30102 measure SpO2?

                It shines red and infrared light into the fingertip and measures the reflected light. Oxygen-rich and oxygen-poor blood absorb these wavelengths differently, and software converts the ratio between the two signals into an estimated SpO2 percentage.

                2. What is the I2C address of the MAX30102?

                The MAX30102 uses the fixed 7-bit I2C address 0x57. Because it cannot be changed, only one MAX30102 can sit on an I2C bus unless we add an I2C multiplexer.

                3. MAX30102 vs MAX30100: which is better?

                The MAX30102 is better for new projects. Its 18-bit ADC, 32-sample FIFO and higher sample rate give cleaner signals and more reliable SpO2 results.

                4. Why are my MAX30102 readings unstable?

                The usual causes are finger movement, pressing too hard and ambient light. Rest the fingertip lightly, keep it still and shield the sensor. Also check that the module's I2C pull-ups are not tied to 1.8V.

                5. Can we use the MAX30102 with ESP32?

                Yes. Connect SDA to GPIO 21, SCL to GPIO 22 and power the module from 3.3V. The library and code in this tutorial work on the ESP32 without changes.

                6. Is the MAX30102 accurate enough for medical use?

                No. Hobby modules are not certified medical devices and are not calibrated against clinical equipment. Use them for learning and experiments only.

                7. Can the MAX30102 measure body temperature?

                Not reliably. Its internal temperature sensor measures the chip, not the body. For body temperature, use a dedicated sensor such as the MLX90614 or DS18B20.

                8. Does the MAX30102 work with 5V?

                Most modules accept 5V on VIN through onboard regulators. The I2C lines are the issue: some modules pull them up to 1.8V, which a 5V Arduino may not read. Move the pull-up jumper to 3.3V or add external pull-ups.

                Prev Post
                Next Post

                Leave a comment

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

                Thanks for subscribing!

                This email has been registered!

                Shop the look

                Choose Options

                Edit Option
                Back In Stock Notification
                Compare
                Product SKU Description Collection Availability Product Type Other Details

                Choose Options

                this is just a warning
                Login
                Shopping Cart
                0 items
                FREE SHIPPING!
                ₹100 OFF
                ₹200 OFF
                ₹999
                ₹2500
                ₹4900
                WhatsApp Chat Chat