Home Code Arduino and MAX30100 oximetry and heart-rate monitor sensor example

Arduino and MAX30100 oximetry and heart-rate monitor sensor example

by shedboy71
[lebox id="1"]
The MAX30100 is an integrated pulse oximetry and heart-rate monitor sensor solution. It combines two LEDs, a photodetector, optimized optics, and low-noise analog signal processing to detect pulse oximetry and heart-rate signals.

The MAX30100 operates from 1.8V and 3.3V power supplies and can be powered down through software with negligible standby current, permitting the power supply to remain connected at all times.

MAX30100-Sensor-Module

MAX30100-Sensor-Module

Key Features

  • Complete Pulse Oximeter and Heart-Rate Sensor Solution Simplifies Design
    • Integrated LEDs, Photo Sensor, and High-Performance Analog Front-End
    • Tiny 5.6mm x 2.8mm x 1.2mm 14-Pin Optically Enhanced System-in-Package
  • Ultra-Low-Power Operation Increases Battery Life for Wearable Devices
    • Programmable Sample Rate and LED Current for Power Savings
    • Ultra-Low Shutdown Current (0.7µA, typ)
  • Advanced Functionality Improves Measurement Performance
    • High SNR Provides Robust Motion Artifact Resilience
    • Integrated Ambient Light Cancellation
    • High Sample Rate Capability
    • Fast Data Output Capability

 

Connection

Arduino Module Pin
5v Vin
Gnd Gnd
SDA SDA
SCL SCL

 

Code

You will need the library from https://github.com/oxullo/Arduino-MAX30100 and import it into the Arduino IDE

This is the minimal example which worked with my module

[codesyntax lang=”cpp”]

#include <Wire.h>
#include "MAX30100_PulseOximeter.h"

#define REPORTING_PERIOD_MS     1000

// PulseOximeter is the higher level interface to the sensor
// it offers:
//  * beat detection reporting
//  * heart rate calculation
//  * SpO2 (oxidation level) calculation
PulseOximeter pox;

uint32_t tsLastReport = 0;

// Callback (registered below) fired when a pulse is detected
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");
    }

    // The default current for the IR LED is 50mA and it could be changed
    //   by uncommenting the following line. Check MAX30100_Registers.h for all the
    //   available options.
    // 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();

    // Asynchronously dump heart rate and oxidation levels to the serial
    // For both, a value of 0 means "invalid"
    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();
    }
}

[/codesyntax]

 

Output

Open the serial monitor

Heart rate:95.04bpm / SpO2:93%
Beat!
Beat!
Heart rate:79.23bpm / SpO2:94%
Beat!
Heart rate:78.94bpm / SpO2:94%
Beat!
Heart rate:76.35bpm / SpO2:94%
Beat!
Beat!
Heart rate:76.26bpm / SpO2:94%
Beat!

 

Links

 

Share
[lebox id="2"]

You may also like

Leave a Comment