Code error for sp32 pulse sensor data to thinspeak

Submitted by Abdul Moiz on

I'm making an esp32 pulse sensor and facing problems with the code to send my pulse sensor data to thingspeak. Here's the code I'm using:

```

#define  USE_ARDUIO_INTERRUPTS true

#include "ThingSpeak.h"

#include <WiFi.h>

#include <PulseSensorPlayground.h>

 

const char* ssid = "HUAWEI-ChwU";   // your network SSID (name)

const char* password = "03003038745";   // your network password

 

WiFiClient  client;

 

unsigned long myChannelNumber = 2010078 ;

const char * myWriteAPIKey = "RHRTPZAXDHUT927V";

 

// Timer variables

unsigned long lastTime = 0;

unsigned long timerDelay = 30000;

//  Variables

const int PulseWire = 36;       // PulseSensor PURPLE WIRE connected to ANALOG PIN 0

const int LED = 2;          // The on-board Arduino LED, close to PIN 13.

int Threshold = 2000;           // Determine which Signal to "count as a beat" and which to ignore.

                               // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.

                               // Otherwise leave the default "550" value.

                               

PulseSensorPlayground pulseSensor;   // Creates an instance of the PulseSensorPlayground object called "pulseSensor"

 

void initBPM() {  

 

  // Configure the PulseSensor object, by assigning our variables to it.

  pulseSensor.analogInput(PulseWire);  

  pulseSensor.blinkOnPulse(LED);       //auto-magically blink Arduino's LED with heartbeat.

  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.  

  }

}

 

void setup() {

  Serial.begin(9600);          // For Serial Monitor

  initBPM();

 

  WiFi.mode(WIFI_STA);  

 

  ThingSpeak.begin(client);  // Initialize ThingSpeak

}

 

void loop() {

  if ((millis() - lastTime) > timerDelay) {

   

    // Connect or reconnect to WiFi

    if(WiFi.status() != WL_CONNECTED){

      Serial.print("Attempting to connect");

      while(WiFi.status() != WL_CONNECTED){

        WiFi.begin(ssid, password);

        delay(5000);    

      }

      Serial.println("\nConnected.");

    }

 

    int myBPM = pulseSensor.getBeatsPerMinute();  // Calls function on our pulseSensor object that returns BPM as an "int".

                                               // "myBPM" hold this BPM value now.

 

   if (pulseSensor.sawStartOfBeat()) {            // Constantly test to see if "a beat happened".

   Serial.println("♥  A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".

   Serial.print("BPM: ");                        // Print phrase "BPM: "

   Serial.println(myBPM);                        // Print the value inside of myBPM.

   }

 

   // Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different

    // pieces of information in a channel.  Here, we write to field 1.

    int x = ThingSpeak.writeField(myChannelNumber, 1, myBPM, myWriteAPIKey);

    //uncomment if you want to get temperature in Fahrenheit

    //int x = ThingSpeak.writeField(myChannelNumber, 1, temperatureF, myWriteAPIKey);

 

    if(x == 200){

      Serial.println("Channel update successful.");

    }

    else{

      Serial.println("Problem updating channel. HTTP error code " + String(x));

    }

    lastTime = millis();

  }

}

```

 

And here's the compile time error that I'm facing rn:

 

```

C:\Users\DELL\AppData\Local\Temp\arduino-sketch-CBF3B8ED5F9B2285CB06B657267B11A1\libraries\PulseSensor_Playground\PulseSensorPlayground.cpp.o:(.literal._ZN21PulseSensorPlayground5beginEv+0x0): undefined reference to `PulseSensorPlayground::UsingInterrupts'
C:\Users\DELL\AppData\Local\Temp\arduino-sketch-CBF3B8ED5F9B2285CB06B657267B11A1\libraries\PulseSensor_Playground\PulseSensorPlayground.cpp.o:(.literal._ZN21PulseSensorPlayground5beginEv+0x8): undefined reference to `PulseSensorPlaygroundSetupInterrupt()'
C:\Users\DELL\AppData\Local\Temp\arduino-sketch-CBF3B8ED5F9B2285CB06B657267B11A1\libraries\PulseSensor_Playground\PulseSensorPlayground.cpp.o: In function `PulseSensorPlayground::begin()':
c:\Users\DELL\Documents\Arduino\libraries\PulseSensor_Playground\src/PulseSensorPlayground.cpp:285: undefined reference to `PulseSensorPlaygroundSetupInterrupt()'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

```