xcoder123 / max30100 Goto Github PK
View Code? Open in Web Editor NEWDriver for MAX30100 using arduino
License: MIT License
Driver for MAX30100 using arduino
License: MIT License
Hey!
I just read your article Implementing pulse oximeter using MAX30100 and was wondering if you think you could use the Max30100 to measure a person's respiratory rate? Do you think inhalations and exhalations will register as variations in SpO2? Is that perhaps something you noticed when experimenting with the chip?
I'd like to publish my code for a Pebble smartstrap using the MAX30102 and I'm currently using a slightly modified version of your library. Would it be possible to license this library under some open source license?
Thanks
Jakob
Hi,
can you help me with GY-MAX30102 sensor it is same board of MAX30100 but with MAX30102 sensor,
i try to use your library on Nodemcu 12E, where i connect SDA and SCL to default pins,
but i could not get any data or red led not running.
Best Regards,
Sayed
I am running below,
#include "MAX30100.h"
#include <Wire.h>
MAX30100* pulseOxymeter;
void setup() {
Wire.begin();
Serial.begin(115200);
Serial.println("Pulse oxymeter test!");
//pulseOxymeter = new MAX30100( DEFAULT_OPERATING_MODE, DEFAULT_SAMPLING_RATE, DEFAULT_LED_PULSE_WIDTH, DEFAULT_IR_LED_CURRENT, true, true );
pulseOxymeter = new MAX30100();
pinMode(2, OUTPUT);
}
void loop() {
//You have to call update with frequency at least 37Hz. But the closer you call it to 100Hz the better, the filter will work.
pulseoxymeter_t result = pulseOxymeter->update();
if( result.pulseDetected == true )
{
Serial.println("BEAT");
Serial.print( "BPM: " );
Serial.print( result.heartBPM );
Serial.print( " | " );
Serial.print( "SaO2: " );
Serial.print( result.SaO2 );
Serial.println( "%" );
}
}
getting error
C:\Users\sim_t\AppData\Local\Temp\arduino_modified_sketch_125959\Example8_SPO2.ino: In function 'void loop()':
Example8_SPO2:19:3: error: 'pulseoxymeter_t' was not declared in this scope
pulseoxymeter_t result = pulseOxymeter->update();
^
Example8_SPO2:19:19: error: expected ';' before 'result'
pulseoxymeter_t result = pulseOxymeter->update();
^
Example8_SPO2:22:7: error: 'result' was not declared in this scope
if( result.pulseDetected == true )
^
Multiple libraries were found for "MAX30100.h"
Used: C:\Users\sim_t\Documents\Arduino\libraries\MAX30100
Not used: C:\Users\sim_t\Documents\Arduino\libraries\MAX30100-master
Not used: C:\Users\sim_t\Documents\Arduino\libraries\MAX30100lib
Not used: C:\Users\sim_t\Documents\Arduino\libraries\MAX30100_milan
exit status 1
'pulseoxymeter_t' was not declared in this scope
any one can help to fix?
I connected the purple oximeter to the Arduino Uno with the following connections:
VIN - 5V
GND - GND
SCL - SCL
SDA - SDA
INT - D2
But it shows me this:
13:16:02.851 -> Pulse oxymeter test!
13:16:02.851 -> BEAT
13:16:02.851 -> BPM: 8616.35 | SaO2: 92.01%
13:16:03.055 -> BEAT
13:16:03.055 -> BPM: 4313.73 | SaO2: 92.66%
13:16:03.089 -> BEAT
13:16:03.089 -> BPM: 1209.15 | SaO2: 92.74%
I used the example sketch from github.
How can I fix this?
First congrats for the tutorial and the explanations, I think your explanation and implementation is the best relating Oximeter functionality.
I still don't understand fully all the filters and signal processing that you used but with time maybe I will get it.
I forked your code in order to use it with my 30102 board and an ESP32 based board, I kind of massacred your driver part to make it work with my 30102 board.
As a suggestion it would have been much nicer if you could have split the driver and the DSP functionality, so that different drivers could be used to get the values from the sensor and then the DSP could process this independently.
With you permission and copyright I will try to make this so I can use some driver that is better written with your processing part.
I had a big problem when debugging, as the sum inside the meanDiff filter and the following butterworth filter was showing inf values when debugging, and I couldn't understand why, as the raw values from the sensor were OK.
After a lot of head banging, I found the cause to be that before the array is filled for the first time, you subtract from the sum the first 15 values, but only the first value is initialized, so for the other values is subtracting some random memory value which is huge and messes up the whole calculation.
I think I fixed this by simply not subtracting until the buffer is filled for the first time:
So this is not an issue as I already fixed it:
`float MAX30100::meanDiff(float M, meanDiffFilter_t* filterValues)
{
float avg = 0;
Serial.print("sum_before = ");
Serial.print(filterValues->sum);
if (filterValues->count == MEAN_FILTER_SIZE) {
filterValues->sum -= filterValues->values[filterValues->index];
}
Serial.print(" sum- = ");
Serial.print(filterValues->sum);
filterValues->values[filterValues->index] = (int32_t)M;
Serial.print(" value = ");
Serial.print(filterValues->values[filterValues->index]);
filterValues->sum += filterValues->values[filterValues->index];
Serial.print(" sum+ = ");
Serial.println(filterValues->sum);
filterValues->index++;
filterValues->index = filterValues->index % MEAN_FILTER_SIZE;
if(filterValues->count < MEAN_FILTER_SIZE)
filterValues->count++;
avg = (float)filterValues->sum / filterValues->count;
#ifdef FLEXIPLOT_DRIVER
Serial.print("{P3|meanDiffValue|0,0,255|");
Serial.print(filterValues->values[filterValues->index]);
Serial.print("|meanDiffIndex|255,0,0|");
Serial.print(filterValues->index);
Serial.print("|meanDiffCount|255,0,0|");
Serial.print(filterValues->count);
Serial.print("|meanDiffSum|255,0,0|");
Serial.print(filterValues->sum);
Serial.print("|meanDiffAverage|255,0,0|");
Serial.print(avg);
Serial.print("|meanDiffReturn|255,0,0|");
Serial.print(avg-M);
Serial.println("}");
#endif
return avg - M;
}`
I have one doubt...
To calculate SPO2 you are using the equations:
But looking for TI docs (who you use as reference), we have:
Pay attention that the variable is R'.
Looking for TI .c code example (slaa468.zip):
[(http://www.ti.com/lit/zip/slaa458)]
I don't know, but I think that you mixed Rs. Because TI implementation no uses linear equation.
Strange, your code works with ArduinoIDE, but could not be linked with VisualMicro, giving the following errors:
`core.a(main.cpp.o)*: (.literal._Z8loopTaskPv+0x4): undefined reference to setup()
Error linking for board M5Stack-Core-ESP32
Debug build failed for project 'MAX30100'
core.a(main.cpp.o)*: (.literal._Z8loopTaskPv+0x8): undefined reference to loop()
core.a(main.cpp.o): In function loopTask(void)
main.cpp:20: undefined reference to setup()
main.cpp:23: undefined reference to loop()
collect2.exe*: error: ld returned 1 exit status`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.