Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Vital Stats
- - Source Code compiled for: ESP32 DevKit V1
- - Source Code created on: 2024-02-11 10:43:18
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* turn on when set temperature reached */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Wire.h>
- #include <DS18B20.h> //https://github.com/matmunk/DS18B20
- #include "MAX30100_PulseOximeter.h"
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- const float SET_TEMPERATURE = 25.0; // Set temperature in °C
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t heat_DS18B20_DQ_PIN_D4 = 4;
- const uint8_t jju_MAX30100_INT_PIN_D13 = 13;
- /***** DEFINITION OF I2C PINS *****/
- const uint8_t jju_MAX30100_I2C_PIN_SDA_D21 = 21;
- const uint8_t jju_MAX30100_I2C_PIN_SCL_D22 = 22;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- DS18B20 ds(heat_DS18B20_DQ_PIN_D4); // Instance of DS18B20 class
- PulseOximeter pox; // Instance of PulseOximeter class
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(heat_DS18B20_DQ_PIN_D4, INPUT);
- pinMode(jju_MAX30100_INT_PIN_D13, INPUT_PULLUP);
- // initialize the PulseOximeter library
- if (!pox.begin()) {
- Serial.println("ERROR: Failed to initialize PulseOximeter!");
- while (1);
- }
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Read temperature from DS18B20 sensor
- float temperature = ds.getTempC();
- // Read heart rate and SpO2 from MAX30100 sensor
- pox.update();
- float heartRate = pox.getHeartRate();
- float spo2 = pox.getSpO2();
- // Print temperature, heart rate, and SpO2
- Serial.print("Temperature: ");
- Serial.print(temperature);
- Serial.println(" °C");
- Serial.print("Heart Rate: ");
- Serial.print(heartRate);
- Serial.println(" bpm");
- Serial.print("SpO2: ");
- Serial.print(spo2);
- Serial.println("%");
- // Check if the temperature reaches the set value
- if (temperature >= SET_TEMPERATURE) {
- // Perform action to turn on
- // ...
- }
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement