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: PulseOximeter Readings
- - Source Code NOT compiled for: Arduino Nano 33 BLE
- - Source Code created on: 2025-06-21 10:04:52
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Develop a user requirement specifying the */
- /* integration of the MAX30100 Pulse Oximeter sensor */
- /* with the Arduino Nano 33 BLE to measure heart rate */
- /* and SpO2 levels, ensuring proper library usage and */
- /* sensor initialization. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <MAX30100_PulseOximeter.h> //https://github.com/gabriel-milan/Arduino-MAX30100
- #include <Wire.h> // Included for compatibility, though MAX30100_PulseOximeter.h may include it already
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- PulseOximeter pox;
- uint32_t tsLastReport = 0;
- const uint32_t REPORTING_PERIOD_MS = 1000; // Reporting interval in milliseconds
- // Callback (registered below) fired when a pulse is detected
- void onBeatDetected()
- {
- Serial.println("Beat!");
- }
- void setup()
- {
- Serial.begin(115200);
- Serial.print("Initializing pulse oximeter..");
- // Initialize the PulseOximeter instance
- // Failures are generally due to an improper I2C wiring, missing power supply
- // or wrong target chip
- if (!pox.begin()) {
- Serial.println("FAILED");
- for(;;);
- } else {
- Serial.println("SUCCESS");
- }
- // The default current for the IR LED is 50mA and it could be changed
- // by uncommenting the following line. Check MAX30100_Registers.h for all the
- // available options.
- // pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
- // Register a callback for the beat detection
- pox.setOnBeatDetectedCallback(onBeatDetected);
- }
- void loop()
- {
- // Make sure to call update as fast as possible
- pox.update();
- // Asynchronously dump heart rate and oxidation levels to the serial
- // For both, a value of 0 means "invalid"
- if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
- Serial.print("Heart rate:");
- Serial.print(pox.getHeartRate());
- Serial.print(" bpm / SpO2:");
- Serial.print(pox.getSpO2());
- Serial.println("%");
- tsLastReport = millis();
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement