PULSE OXIMETER HEART RATE SENSOR MODULE MAX30100
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.
35 ₪
about:
The sensor has two LEDs, one emitting red light, the other emitting infrared light. Infrared light is required for pulse rate. But, Both red light and infrared light are required for measuring Sp02 levels in the blood.
When the heart pumps the blood, the oxygen level is increased because there is more blood. But, when the heart rests, there is a decrease in oxygenated blood. Hence, the pulse rate is determined by getting the time between the rise and fall of oxygenated blood.
The oxygenated blood absorbs more infrared light and passes more red light. But, deoxygenated blood absorbs red light and passes more infrared light.
Basically, the MAX30100 sensor reads the absorption levels for both light sources and stores them in a buffer that can be read via I2C pins.
Features of MAX30100:
- Consumes very low power (operates from 1.8V and 3.3V)
- Ultra-Low Shutdown Current (0.7µA, typ)
- Fast Data Output Capability
Circuit:
library arduino:
Arduino Code:
code
نسخ
اقتباس
عرض
تنزيل
#include <MAX30100.h>
#include <MAX30100_BeatDetector.h>
#include <MAX30100_Filters.h>
#include <MAX30100_PulseOximeter.h>
#include <MAX30100_Registers.h>
#include <MAX30100_SpO2Calculator.h>
#include <Wire.h>
#define REPORTING_PERIOD_MS 500
PulseOximeter pox;
const int numReadings=10;
float filterweight=0.5;
uint32_t tsLastReport = 0;
uint32_t last_beat=0;
int readIndex=0;
int average_beat=0;
int average_SpO2=0;
bool calculation_complete=false;
bool calculating=false;
bool initialized=false;
byte beat=0;
void onBeatDetected() //Calls back when pulse is detected
{
viewBeat();
last_beat=millis();
}
void viewBeat()
{
if (beat==0) {
Serial.print("_");
beat=1;
}
else
{
Serial.print("^");
beat=0;
}
}
void initial_display()
{
if (not initialized)
{
viewBeat();
Serial.print(" MAX30100 Pulse Oximeter Test");
Serial.println("******************************************");
Serial.println("Place place your finger on the sensor");
Serial.println("********************************************");
initialized=true;
}
}
void display_calculating(int j){
viewBeat();
Serial.println("Measuring");
for (int i=0;i<=j;i++) {
Serial.print(". ");
}
}
void display_values()
{
Serial.print(average_beat);
Serial.print("| Bpm ");
Serial.print("| SpO2 ");
Serial.print(average_SpO2);
Serial.print("%");
}
void calculate_average(int beat, int SpO2)
{
if (readIndex==numReadings) {
calculation_complete=true;
calculating=false;
initialized=false;
readIndex=0;
display_values();
}
if (not calculation_complete and beat>30 and beat<220 and SpO2>50) {
average_beat = filterweight * (beat) + (1 - filterweight ) * average_beat;
average_SpO2 = filterweight * (SpO2) + (1 - filterweight ) * average_SpO2;
readIndex++;
display_calculating(readIndex);
}
}
void setup()
{
Serial.begin(115200);
pox.begin();
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop()
{
pox.update();
if ((millis() - tsLastReport > REPORTING_PERIOD_MS) and (not calculation_complete)) {
calculate_average(pox.getHeartRate(),pox.getSpO2());
tsLastReport = millis();
}
if ((millis()-last_beat>10000)) {
calculation_complete=false;
average_beat=0;
average_SpO2=0;
initial_display();
}
}
======== ESP8266 Code & cct & lib ==========
The MAX30100 has I2C Pins. So connect its SDA pin to D21 & SCL pin to D22 of ESP32 Board. The power supply required by MAX30100 is 3.3V. So connect its VCC terminal to 3.3V of ESP32.
code:
code
نسخ
اقتباس
عرض
تنزيل
/*
Arduino-MAX30100 oximetry / heart rate integrated sensor library
Copyright (C) 2016 OXullo Intersecans <x@brainrapers.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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();
}
}