Code Monkey home page Code Monkey logo

esp32_max30102_simple-spo2_plotter's Introduction

Simple SpO2 plotter for MH-ET LIVE MAX30102

Using Sparkfun MAX3010X library https://github.com/sparkfun/SparkFun_MAX3010x_Sensor_Library SpO2 is calulated from square root means of all raw data at 50Hz sampling speed, providing stable SpO2 values and shows SpO2 and the user's heart beat at the same time on Arduino's serial plotter.

What's new

Sparkfun's MAX30105 board is supported. (May 19, 2020) use #define MAX30105

Fig.1 SpO2 at boot time Fig.1 SpO2 at boot time

Fig.2 SpO2 drops by breath holding Fig.2 SpO2 by breath taking

about SpO2 and pulse oximeter

Peripheral oxygen saturation (SpO2) is an estimation of the oxygen saturation level usually measured with a pulse oximeter device.

Fig.3 MH-ET LIVE MAX30102 breakout board Fig.3 MH-ET LIVE MAX30102 breakout board

Tips:

  • Used algorithm

The DC components of IR and RED are obtained by inputting the raw data into a low-pass filter. The AC components of IR and RED are calculated by subtracting the DC components from the raw data. The square root mean of the AC components of IR and RED is calculated for every 100 samples.

Fig.4 Raw RED signal - DC(low pass filtered RED)
Fig.4 Raw RED signal - DC(low pass filtered RED)

SpO2 is calculated as

  R=((square root means of RED/ RED average )/((square root means of IR)/IR average)) 
  
  SpO2 = -23.3 * (R - 0.4) + 100

A linear approximation is made by reading values from 0.4 to 1 on the x-axis of the graph in https://ww1.microchip.com/downloads/en/Appnotes/00001525B.pdf or https://ww1.microchip.com/downloads/jp/AppNotes/00001525B_JP.pdf This is because a linear approximation of SpO2 from 100 to about 80 is sufficient for practical purposes. SpO2 below 80 is a difficult value for survival.

  • when IR signal is smaller than 30000 (#define FINGER_ON 30000), then SpO2 becomes 80 to indicate your finger is not on the sensor.

  • Since MH-ET LIVE MAX30102 breakout board seems outputting IR and RED swapped when Sparkfun's library is used.

red = particleSensor.getFIFOIR();
ir = particleSensor.getFIFORed();

is used in my code. If you have Sparkfun's MAX30105 breakout board , use #define MAX30105

Fig.5 insulating MAX30102 breakout board
Fig.5 insulating MAX30102 breakout board

Instructions:

  1. Install Sparkfun's MAX3010X library
  2. Load the code onto ESP32 with MH-ET LIVE MAX30102 board
  3. Put MAX30102 board in a plastic bag , insulating from your finger and attach the sensor to your finger tip
  4. Run this program by pressing reset botton on ESP32 devkitC
  5. Wait for 3 seconds and Open Arduino IDE Tools->'Serial Plotter' Make sure the drop down is set to 115200 baud
  6. Search the best position and pressure for the sensor by watching the blips on Arduino's serial plotter. I recommend to place LED under the backside of nail , wrap you finger and the sensor by rubber band softly.
  7. Checkout the SpO2 and blips by seeing serial plotter. 100%,95%,90%,85% SpO2 lines are always drawn on the plotter

Hardware Connections (Breakout board to ESP32 Arduino):

  -VIN = 3.3V
  -GND = GND
  -SDA = 21 (or SDA)
  -SCL = 22 (or SCL)
  -INT = Not connected

Hardware Connections (Breakout board to Arduino nano):

this script also works on Arduino nao.(experimental)

  -VIN = 3.3V 
  -GND = GND
  -SDA = A4 (or SDA)
  -SCL = A5 (or SCL)
  -INT = Not connected

Trouble Shooting:

Make sure to solder jumper on 3V3 side. If you forget this, I2C does not work and can not find MAX30102, says

 "MAX30102 was not found. Please check wiring/power/solder jumper."

Fig.6 3.3V solder jumper Fig.6 3.3V solder jumper

Fig.7 for Sparkfun's MAX30105 , use #define MAX30105 Fig.7 for Sparkfun's MAX30105 , use #define MAX30105

LICENSED under Apache License 2.0

References

Fig.7 IR and RED LED at MAX30102 on MH-ET LIVE

esp32_max30102_simple-spo2_plotter's People

Contributors

coniferconifer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

esp32_max30102_simple-spo2_plotter's Issues

Equation for SPO2, SpO2 = -23.3 * (R - 0.4) + 100;

Screen Shot 2022-05-30 at 3 18 45 AM

Could you please explain to us, how you derived this equation from the calibration curve in the document AN1525 (Pulse Oximeter Design Using Microchip’s Analog Devices and dsPIC® Digital Signal Controllers (DSCs))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.