Advertisement
safwan092

project-7701-Nano-Code

Apr 28th, 2021
1,216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.36 KB | None | 0 0
  1. #define USE_ARDUINO_INTERRUPTS true
  2. #include <Wire.h>
  3. #include <SHT21.h>
  4. #include "MAX30100_PulseOximeter.h"
  5.  
  6. SHT21 sht;
  7. float temp;
  8. #define REPORTING_PERIOD_MS     1000
  9.  
  10. PulseOximeter pox;
  11. uint32_t tsLastReport = 0;
  12.  
  13. void onBeatDetected()
  14. {
  15.   //Serial.println("Beat!");
  16. }
  17.  
  18. void setup()
  19. {
  20.   Serial.begin(115200);
  21.   //Wire.begin();
  22.   //Serial.print("Initializing pulse oximeter..");
  23.  
  24.   // Initialize the PulseOximeter instance
  25.   // Failures are generally due to an improper I2C wiring, missing power supply
  26.   // or wrong target chip
  27.   if (!pox.begin()) {
  28.     //Serial.println("FAILED");
  29.     for (;;);
  30.   } else {
  31.     //Serial.println("SUCCESS");
  32.   }
  33.   //pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
  34.  
  35.   // Register a callback for the beat detection
  36.   //pox.setOnBeatDetectedCallback(onBeatDetected);
  37. }
  38.  
  39. void loop()
  40. {
  41.   // Make sure to call update as fast as possible
  42.   pox.update();
  43.   if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
  44.     //Serial.print("Heart rate:");
  45.     temp = sht.getTemperature();
  46.     //if (pox.getHeartRate() > 60) {
  47.       Serial.print(pox.getHeartRate());
  48.       Serial.print(", ");
  49.       Serial.print(temp);
  50.       Serial.print(",");
  51.       Serial.println("end");
  52.       //Serial.print("bpm / SpO2:");
  53.       //Serial.print(pox.getSpO2());
  54.       //Serial.println("%");
  55.     //}
  56.     tsLastReport = millis();
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement