Advertisement
pleasedontcode

"Pulse Oximeter Integration" rev_01

Feb 29th, 2024
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: "Pulse Oximeter Integration"
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-02-29 13:08:17
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* i want to connect esp32 with max30102 and generate */
  21.     /* code and see resualt */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Wire.h>
  26. #include "MAX30100_PulseOximeter.h"
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t MAX30100_INT_PIN = 4;
  34.  
  35. /***** DEFINITION OF I2C PINS *****/
  36. const uint8_t MAX30100_SDA_PIN = 21;
  37. const uint8_t MAX30100_SCL_PIN = 22;
  38.  
  39. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  40. PulseOximeter pox;
  41.  
  42. void setup(void)
  43. {
  44.     // put your setup code here, to run once:
  45.     pinMode(MAX30100_INT_PIN, INPUT_PULLUP);
  46.  
  47.     // Initialize the PulseOximeter library
  48.     if (!pox.begin()) {
  49.         Serial.println("Failed to initialize PulseOximeter!");
  50.         while (1);
  51.     }
  52. }
  53.  
  54. void loop(void)
  55. {
  56.     // put your main code here, to run repeatedly:
  57.  
  58.     // Update the PulseOximeter sensor readings
  59.     pox.update();
  60.  
  61.     // Get heart rate and SpO2 values
  62.     float heartRate = pox.getHeartRate();
  63.     uint8_t spo2 = pox.getSpO2();
  64.  
  65.     // Print the values to the serial monitor
  66.     Serial.print("Heart Rate: ");
  67.     Serial.print(heartRate);
  68.     Serial.print(" bpm, SpO2: ");
  69.     Serial.print(spo2);
  70.     Serial.println("%");
  71.  
  72.     // Delay for some time before the next reading
  73.     delay(1000);
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement