Advertisement
pleasedontcode

Vital Stats rev_02

Feb 11th, 2024
40
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: Vital Stats
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-02-11 10:43:18
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* turn on when set temperature reached */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Wire.h>
  25. #include <DS18B20.h>    //https://github.com/matmunk/DS18B20
  26. #include "MAX30100_PulseOximeter.h"
  27.  
  28. /****** SYSTEM REQUIREMENTS *****/
  29. /****** SYSTEM REQUIREMENT 1 *****/
  30. const float SET_TEMPERATURE = 25.0; // Set temperature in °C
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35.  
  36. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  37. const uint8_t heat_DS18B20_DQ_PIN_D4 = 4;
  38. const uint8_t jju_MAX30100_INT_PIN_D13 = 13;
  39.  
  40. /***** DEFINITION OF I2C PINS *****/
  41. const uint8_t jju_MAX30100_I2C_PIN_SDA_D21 = 21;
  42. const uint8_t jju_MAX30100_I2C_PIN_SCL_D22 = 22;
  43.  
  44. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  45. DS18B20 ds(heat_DS18B20_DQ_PIN_D4); // Instance of DS18B20 class
  46. PulseOximeter pox; // Instance of PulseOximeter class
  47.  
  48. void setup(void)
  49. {
  50.   // put your setup code here, to run once:
  51.   pinMode(heat_DS18B20_DQ_PIN_D4, INPUT);
  52.   pinMode(jju_MAX30100_INT_PIN_D13, INPUT_PULLUP);
  53.  
  54.   // initialize the PulseOximeter library
  55.   if (!pox.begin()) {
  56.     Serial.println("ERROR: Failed to initialize PulseOximeter!");
  57.     while (1);
  58.   }
  59. }
  60.  
  61. void loop(void)
  62. {
  63.   // put your main code here, to run repeatedly:
  64.  
  65.   // Read temperature from DS18B20 sensor
  66.   float temperature = ds.getTempC();
  67.  
  68.   // Read heart rate and SpO2 from MAX30100 sensor
  69.   pox.update();
  70.   float heartRate = pox.getHeartRate();
  71.   float spo2 = pox.getSpO2();
  72.  
  73.   // Print temperature, heart rate, and SpO2
  74.   Serial.print("Temperature: ");
  75.   Serial.print(temperature);
  76.   Serial.println(" °C");
  77.   Serial.print("Heart Rate: ");
  78.   Serial.print(heartRate);
  79.   Serial.println(" bpm");
  80.   Serial.print("SpO2: ");
  81.   Serial.print(spo2);
  82.   Serial.println("%");
  83.  
  84.   // Check if the temperature reaches the set value
  85.   if (temperature >= SET_TEMPERATURE) {
  86.     // Perform action to turn on
  87.     // ...
  88.   }
  89.  
  90.   delay(1000);
  91. }
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement