Skip to content

Simple SpO2 plotter from scratch for Arduno IDE by reading MH-ET LIVE MAX30102 raw RED/IR data

License

Notifications You must be signed in to change notification settings

coniferconifer/ESP32_MAX30102_simple-SpO2_plotter

Repository files navigation

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

About

Simple SpO2 plotter from scratch for Arduno IDE by reading MH-ET LIVE MAX30102 raw RED/IR data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published