Techatronic
Published

Pulse oximeter NodeMCU

In this post, we are discussing the interfacing of a MAX30101 pulse oximeter sensor with nodemcu.

BeginnerFull instructions provided2 hours1,432
Pulse oximeter NodeMCU

Things used in this project

Story

Read more

Code

Code snippet #3

Plain text
  //TECHATRONIC.COM  
 // BLYNK LIBRARY  
 // https://github.com/blynkkk/blynk-library  
 // ESP8266 LIBRARY  
 // https://github.com/ekstrand/ESP8266wifi  
 // Arduino-MAX30100 LIBRARY  
 // https://github.com/oxullo/Arduino-MAX30100  
 // SimpleTimer LIBRARY  
 // https://github.com/jfturcot/SimpleTimer  
 #include <Wire.h>  
 #include <ESP8266WiFi.h>  
 #include <BlynkSimpleEsp8266.h>  
 #include "MAX30100_PulseOximeter.h"  
 #include <SimpleTimer.h>  
 #include <ESP8266WiFi.h>  
 #include <BlynkSimpleEsp8266.h>  
 // BPM GAUGE CONNECT V2  
 // SP02 GAUGE CONNECT V3  
 char auth[] = "your auth token";  // You should get Auth Token in the Blynk App.  
 char ssid[] = "your wifi ssid";              // Your WiFi credentials.  
 char pass[] = "your wifi password";             // Your WiFi Password.               
 #define REPORTING_PERIOD_MS   3000  
 SimpleTimer timer;  
 PulseOximeter pox;  
 uint32_t tsLastReport = 0;  
 void onBeatDetected()  
 {  
  ;  
 }  
 void setup()  
 {  
  Serial.begin(115200);  
  Blynk.begin(auth, ssid, pass);  
  Serial.print("Initializing pulse oximeter..");  
  if (!pox.begin()) {  
   Serial.println("FAILED");  
   for (;;);  
  } else {  
   Serial.println("SUCCESS");  
   digitalWrite(1, HIGH);  
  }  
  pox.setIRLedCurrent(MAX30100_LED_CURR_24MA);  
  // Register a callback for the beat detection  
  pox.setOnBeatDetectedCallback(onBeatDetected);  
  timer.setInterval(3000L, getSendData);  
 }  
 void loop()  
 {  
  timer.run(); // Initiates SimpleTimer  
  Blynk.run();  
  // Make sure to call update as fast as possible  
  pox.update();  
  if (millis() - tsLastReport > REPORTING_PERIOD_MS) {  
   // to android cell phone application  
   Serial.print("BPM: ");  
   Serial.print(pox.getHeartRate());  
   //blue.println("\n");  
   Serial.print("  SpO2: ");  
   Serial.print(pox.getSpO2());  
   Serial.print("%");  
   Serial.println("\n");  
   Blynk.virtualWrite(V2, pox.getHeartRate() );  
   Blynk.virtualWrite(V3, pox.getSpO2());  
   tsLastReport = millis();  
  }  
 }  
 void getSendData()  
 {  
 }  

Code snippet #4

Plain text
  //TECHATRONIC.COM  
 // BLYNK LIBRARY  
 // https://github.com/blynkkk/blynk-library  
 // ESP8266 LIBRARY  
 // https://github.com/ekstrand/ESP8266wifi  
 // Arduino-MAX30100 LIBRARY  
 // https://github.com/oxullo/Arduino-MAX30100  
 // SimpleTimer LIBRARY  
 // https://github.com/jfturcot/SimpleTimer  
 #include <Wire.h>  
 #include <ESP8266WiFi.h>  
 #include <BlynkSimpleEsp8266.h>  
 #include "MAX30100_PulseOximeter.h"  
 #include <SimpleTimer.h>  
 #include <ESP8266WiFi.h>  
 #include <BlynkSimpleEsp8266.h>  
 // BPM GAUGE CONNECT V2  
 // SP02 GAUGE CONNECT V3  
 char auth[] = "your auth token";  // You should get Auth Token in the Blynk App.  
 char ssid[] = "your wifi ssid";              // Your WiFi credentials.  
 char pass[] = "your wifi password";             // Your WiFi Password.               
 #define REPORTING_PERIOD_MS   3000  
 SimpleTimer timer;  
 PulseOximeter pox;  
 uint32_t tsLastReport = 0;  
 void onBeatDetected()  
 {  
  ;  
 }  
 void setup()  
 {  
  Serial.begin(115200);  
  Blynk.begin(auth, ssid, pass);  
  Serial.print("Initializing pulse oximeter..");  
  if (!pox.begin()) {  
   Serial.println("FAILED");  
   for (;;);  
  } else {  
   Serial.println("SUCCESS");  
   digitalWrite(1, HIGH);  
  }  
  pox.setIRLedCurrent(MAX30100_LED_CURR_24MA);  
  // Register a callback for the beat detection  
  pox.setOnBeatDetectedCallback(onBeatDetected);  
  timer.setInterval(3000L, getSendData);  
 }  
 void loop()  
 {  
  timer.run(); // Initiates SimpleTimer  
  Blynk.run();  
  // Make sure to call update as fast as possible  
  pox.update();  
  if (millis() - tsLastReport > REPORTING_PERIOD_MS) {  
   // to android cell phone application  
   Serial.print("BPM: ");  
   Serial.print(pox.getHeartRate());  
   //blue.println("\n");  
   Serial.print("  SpO2: ");  
   Serial.print(pox.getSpO2());  
   Serial.print("%");  
   Serial.println("\n");  
   Blynk.virtualWrite(V2, pox.getHeartRate() );  
   Blynk.virtualWrite(V3, pox.getSpO2());  
   tsLastReport = millis();  
  }  
 }  
 void getSendData()  
 {  
 }  

Credits

Techatronic
72 projects • 131 followers
Electronic engineer
Contact

Comments

Please log in or sign up to comment.