|
arduino IDEArduino
|
Oximeter with MAX30100 Heart Rate Sensor and ESP32
Hey Guys how you doing?
In this article, you will learn about the MAX30100 Pulse Oximeter heart rate monitor sensor, and how we can use it to make a simple Oximeter with ESP32 DEV Board.
So let's get started.
Materials
Following are the things used in this build-
- MAX30100 Sensor module
- ESP32 Wemos D32 pro
- Breadboard
- Jumper Wires
- Arduino nano (optional)
About the MAX30100
The MAX30100 is integrated pulse oximetry and heart rate monitor sensor made by maxim integrated.
It combines a photodetector, optimized optics, and low-noise analog signal processing to detect pulse oximetry and heart-rate signals when we rest our fingertips on the sensor.
It operates from 1.8V and 3.3V power source. To use this sensor properly, its Module comes with an Onboard Voltage regulator that regulates 5V into 3.3V for optimal working.
It even has an On-Chip Temperature Sensor. The temperature sensor for (optionally) calibrating the temperature dependence of the SpO2 subsystem. The SpO2 algorithm is relatively insensitive to the wavelength of the IR LED, but the red LED’s wavelength is critical to the correct interpretation of the data.
The temperature sensor data can be used to compensate for the SpO2 error with ambient temperature changes.
The MAX30100 integrates red and IR LED drivers to drive LED pulses for SpO2 and HR measurements. The LED current can be programmed from 0mA to 50mA and we can do that by changing the below line in code with given lines.
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA); //Current set at 7mA
Here are a few lines for different current levels, the more you increase the current of LED, the more will the glow of LED and accuracy will increase drastically.
- MAX30100_LED_CURR_4_4MA
- MAX30100_LED_CURR_7_6MA
- MAX30100_LED_CURR_11MA
- MAX30100_LED_CURR_14_2MA
- MAX30100_LED_CURR_40_2MA
- MAX30100_LED_CURR_43_6MA
- MAX30100_LED_CURR_46_8MA
- MAX30100_LED_CURR_50MA
Here's its datasheet.
https://datasheets.maximintegrated.com/en/ds/MAX30100.pdf
How does it measure Heart rate and Blood Oxygen Level
So here's how the MAX30100 Sensor works, it contains two LEDs one red led and one IR Led, Both of these LEDs have different wavelengths (660nm and 880nm).
When we place our finger onto the Sensor, both LED light goes into the fingertip and it gets reflected, a photo sensor picks up this light and calculates how much is the heart rate and what is the blood oxygen level.
This process is known as photoplethysmogram and its widespread use in similar medical equipment.
PCBWAY Giftshop
As for sourcing the Sensor Module, I used PCBWAY's Giftshop for ordering the sensor.
Aside from PCB Services, PCBWAY also has a dedicated components store.
PCBWAY GIFTSHOP is an online marketplace from where we can source all the major electronics stuff, like Arduino boards, Raspberry Pi boards, Modules, sensors, etc.
PCBWAY have this system that lets us purchase anything from their gift shop through beans, Beans are like a redeemable currency or coupons that we get by placing an order on PCBWAY or by sharing your projects in the community to get beans.
Check PCBWAY out for getting great PCB service from here- https://www.pcbway.com/
Correction in Sensor Module
Before getting started, we first need to change something in the Sensor module, let me explain what and why.
So this module is based on MAX30100 Sensor and it requires two different voltages to work, one for LED and one for the sensor itself.
In this module, there are three 4.7kOhm Resistors that are connected in between the SDA, SCL, and INT signal lines and 1.8V from the voltage regulator.
If we connect this module with an Arduino or ESP32 Board that takes high logic level (3.3V and 5V).
1.8V Logic Level won't show up on the I2C Bus and this module is practically unusable.
Here's the solution, we cut down the Track between the SOT23 Voltage Regulator and the first resistor, then we add a connection between the first resistor's pad and the other voltage regulator's VCC (3.3V one).
By doing this, this module will show up on I2C Bus and pick up pickup readings from it.
CONNECTION DIAGRAM
As for the connections, I have used an ESP32 Based Lolin D32 Pro Board but you can use any ESP32 Board or even Arduino boards like Nano or UNO.
The connection will stay the same for every Dev Board.
- We add the VCC of the Module to 5V of the Microcontroller
- GND to GND
- SDA of Module to SDA of Microcontroller which was D21 in ESP32
- SCL of Module to SCL of Microcontroller which was D22 in ESP32
Code and Library
As for the Code, I'm using two sketches in this tutorial, first one is for getting the Heat Rate and Blood Oxygen level and the other one is for getting the raw data from both LEDs.
As for the library, we use the MAX30100 Library by OXULLO which can be downloaded from GitHub or you can search the library in library manager and download it from there.
Reading Heartbeat and Blood Oxygen level
For the first test, we will be measuring the heartbeat per minute and the Blood Oxygen Level.
We first upload this below sketch to the setup and then open the serial monitor.
#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 sensorif (!pox.begin()) { Serial.println("FAILED"); for(;;); } else { Serial.println("SUCCESS"); } pox.setIRLedCurrent(MAX30100_LED_CURR_46_8MA); // Register a callback routine pox.setOnBeatDetectedCallback(onBeatDetected); } void loop() { // Read from the sensor pox.update(); // Grab the updated heart rate and SpO2 levelsif (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(); } }
We place our fingertip on the sensor, make sure to push down the module tightly, and try not to move the fingertip or you'll get false readings. wait for 10 seconds as this is the minimum time that is required for reading to get stabilized.
Reading Raw Readings and Plotting Graph
Next, we use the below sketch to get readings from the Module and plot a graph in the Serial Plotter, we again push down the sensor with our fingertip and let the sensor settles down for 10 seconds.
#include <Wire.h> #include "MAX30100_PulseOximeter.h" // Create a MAX30100 object MAX30100 sensor; void setup() { Serial.begin(115200); Serial.print("Initializing MAX30100.."); // Initialize sensorif (!sensor.begin()) { Serial.println("FAILED"); for(;;); } else { Serial.println("SUCCESS"); } // Configure sensor configureMax30100(); } void loop() { uint16_t ir, red; sensor.update(); while (sensor.getRawValues(&ir, &red)) { Serial.print(red); Serial.print(", "); Serial.println(ir); } } void configureMax30100() { sensor.setMode(MAX30100_MODE_SPO2_HR); sensor.setLedsCurrent(MAX30100_LED_CURR_50MA, MAX30100_LED_CURR_27_1MA); sensor.setLedsPulseWidth(MAX30100_SPC_PW_1600US_16BITS); sensor.setSamplingRate(MAX30100_SAMPRATE_100HZ); sensor.setHighresModeEnabled(true); }
Here's the graph and the value of both LEDs are shown in a different colors.
Conclusion and Version 2
Here's what I learned whiles tinkering with this setup.
The MAX30100 Sensor is an interesting device, it works on some level but it's not precise enough to be used in a proper DIY Oximeter setup.
As for Version 2, I will be making an Oximeter Setup anyway by using an ESP32 Wroom Module with the MAX30100 Sensor and an OLED display that will show the data readings.
This is it for today folks, I hope this small tutorial was helpful to you guys.
Thanks, PCBWAY for supporting this project, do check out their page for getting all sorts of PCB RElated services for an economic cost.
Thanks again and peace out.
#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");
}
pox.setIRLedCurrent(MAX30100_LED_CURR_46_8MA);
// 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();
}
}
Oximeter with MAX30100 Heart Rate Sensor and ESP32
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Arnov Arnov sharma
- WALKPi PCB Version Greetings everyone and welcome back, This is the WalkPi, a homebrew audio player that plays music fr...
- Delete Button XL Greetings everyone and welcome back, and here's something fun and useful.In essence, the Delete Butt...
- Arduino Retro Game Controller Greetings everyone and welcome back. Here's something fun.The Arduino Retro Game Controller was buil...
- Super Power Buck Converter Greetings everyone and welcome back!Here's something powerful, The SUPER POWER BUCK CONVERTER BOARD ...
- Pocket Temp Meter Greetings and welcome back.So here's something portable and useful: the Pocket TEMP Meter project.As...
- Pico Powered DC Fan Driver Hello everyone and welcome back.So here's something cool: a 5V to 12V DC motor driver based around a...
- Mini Solar Light Project with a Twist Greetings.This is the Cube Light, a Small and compact cube-shaped emergency solar light that boasts ...
- PALPi V5 Handheld Retro Game Console Hey, Guys what's up?So this is PALPi which is a Raspberry Pi Zero W Based Handheld Retro Game Consol...
- DIY Thermometer with TTGO T Display and DS18B20 Greetings.So this is the DIY Thermometer made entirely from scratch using a TTGO T display board and...
- Motion Trigger Circuit with and without Microcontroller GreetingsHere's a tutorial on how to use an HC-SR505 PIR Module with and without a microcontroller t...
- Motor Driver Board Atmega328PU and HC01 Hey, what's up folks here's something super cool and useful if you're making a basic Robot Setup, A ...
- Power Block Hey Everyone what's up!So this is Power block, a DIY UPS that can be used to power a bunch of 5V Ope...
- Goku PCB Badge V2 Hey everyone what's up!So here's something SUPER cool, A PCB Board themed after Goku from Dragon Bal...
- RGB Mixinator V2 Hey Everyone how you doin!So here's a fun little project that utilizes an Arduino Nano, THE MIXINATO...
- Gengar PCB Art Hey guys and how you doing!So this is the GENGAR PCB Badge or a Blinky Board which is based around 5...
- R2D2 Mini Edition So here's something special, A Mini R2D2 PCB that speaks ASTROMECH.Astromech is a fictional language...
- C-3PO Blinky Board Hey guys and how you doing!So this is the C3P0 PCB Badge or a Blinky Board which is based around 555...
- WALKPi Breadboard Version Greetings everyone and welcome back, Here's something loud and musical.Similar to a traditional walk...
-
-
-
kmMiniSchield MIDI I/O - IN/OUT/THROUGH MIDI extension for kmMidiMini
125 0 0 -
DIY Laser Power Meter with Arduino
177 0 2 -
-
-
Box & Bolt, 3D Printed Cardboard Crafting Tools
165 0 2 -