PulseSensorPlayground with ESP32

Hello Arduino People :slight_smile:

I am new in programming arduino and I already encountered a problem. please help me.

I have an ESP32 devkit with 32 pins.


and a pulsensor I have tried using the Getting_BPM_to_Monitor in the pulsesensor playground library to check if it is functional.

The pinning are.
(Hearpin to ESP32 format)
Signal to GPIO34, VCC to 3V3, and GND to GND.

The problem is that pulsesensor cannot create the object and here I added some to code to verify.

#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>

const int PulseWire = 10;       
const int LED13 = 13;          
int Threshold = 550;                            
                               
PulseSensorPlayground pulseSensor;

void setup() {   
  pinMode(PulseWire,INPUT);
  Serial.begin(9600);          
  pulseSensor.analogInput(PulseWire);
  pulseSensor.blinkOnPulse(LED13);
  pulseSensor.setThreshold(Threshold);   

  // Double-check the "pulseSensor" object was created and "began" seeing a signal.
   if (pulseSensor.begin()) {
    Serial.println("We created a pulseSensor Object !");  //This prints one time at Arduino power-up,  or on Arduino reset.  
  } else Serial.println("Cannot create a pulseSensor Object !"); //Code to verify that it doesn't create the object
  
}

Can you guys help me answer what is the problem.

rsorima:

  } else Serial.println("Cannot create a pulseSensor Object !"); //Code to verify that it doesn't create the object

Wrong. That code will run if pulseSensor.begin() returns false. Unfortunately the library author didn't bother to document the meanings of the return values of this function in the reference, but it is explained in the source code:

boolean PulseSensorPlayground::PulseSensorPlayground::begin() {

  for (int i = 0; i < SensorCount; ++i) {
    Sensors[i].initializeLEDs();
  }

  // Note the time, for non-interrupt sampling and for timing statistics.
  NextSampleMicros = micros() + MICROS_PER_READ;

  SawNewSample = false;
	Paused = false;

#if PULSE_SENSOR_MEMORY_USAGE
  // Report the RAM usage and hang.
  printMemoryUsage();
  for (;;);
#endif // PULSE_SENSOR_MEMORY_USAGE

  // Lastly, set up and turn on the interrupts.

  if (UsingInterrupts) {
    if (!PulseSensorPlaygroundSetupInterrupt()) {
			Stream *pOut = SerialOutput.getSerial();
		  if (pOut) {
		    pOut->print(F("Interrupts not supported on this platform\n"));
			}
      // The user requested interrupts, but they aren't supported. Say so.
			Paused = true;
      return false;
    }
  }

  return true;
}

The interrupt functionality of the library is only supported on specific AVR-architecture boards like the Uno, Nano, Mega, Leonardo, Micro. It is not supported on your ESP32 board. But you have specified in your sketch that the library should use interrupts:

rsorima:

#define USE_ARDUINO_INTERRUPTS true

Which is why you are getting that error. There is an example sketch that demonstrates how to use the library without interrupts. You will find it in the Arduino IDE at File > Examples > PulseSensor Playground > PulseSensor_BPM_Alternative