[SOLVED] ERROR TO COMPILE "undefined reference to" FOR ARDUINO UNO

#include <SoftwareSerial.h>
#include "Timer.h"
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.   
Timer t;
PulseSensorPlayground pulseSensor;
#define USE_ARDUINO_INTERRUPTS true    
#define DEBUG true
#define SSID "********"     // "SSID-WiFiname"
#define PASS "************" // "password"
#define IP "184.106.153.149"      // thingspeak.com ip

String msg = "GET /update?key=your api key"; 
SoftwareSerial esp8266(10,11);

//Variables
const int PulseWire = A0;       // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13;          // The on-board Arduino LED, close to PIN 13.
int Threshold = 550;           //for heart rate sensor
float myTemp;
int myBPM;
String BPM;
String temp;
int error;
int panic;
int raw_myTemp;
float Voltage;
float tempC;
void setup()
{
 
  Serial.begin(9600); 
  esp8266.begin(115200);
  pulseSensor.analogInput(PulseWire);   
  pulseSensor.blinkOnPulse(LED13);       //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.  
  }
  Serial.println("AT");
  esp8266.println("AT");

  delay(3000);

  if(esp8266.find("OK"))
  {
    connectWiFi();
  }
  t.every(10000, getReadings);
   t.every(10000, updateInfo);
}

void loop()
{
  panic_button();
start: //label
    error=0;
   t.update();
    //Resend if transmission is not completed
    if (error==1)
    {
      goto start; //go to label "start"
    } 
 delay(4000);
}

void updateInfo()
{
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  Serial.println(cmd);
  esp8266.println(cmd);
  delay(2000);
  if(esp8266.find("Error"))
  {
    return;
  }
  cmd = msg ;
  cmd += "&field1=";    //field 1 for BPM
  cmd += BPM;
  cmd += "&field2=";  //field 2 for temperature
  cmd += temp;
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  esp8266.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  esp8266.println(cmd.length());
  if(esp8266.find(">"))
  {
    Serial.print(cmd);
    esp8266.print(cmd);
  }
  else
  {
    Serial.println("AT+CIPCLOSE");
    esp8266.println("AT+CIPCLOSE");
    //Resend...
    error=1;
  }
}

boolean connectWiFi()
{
  Serial.println("AT+CWMODE=1");
  esp8266.println("AT+CWMODE=1");
  delay(2000);
  String cmd="AT+CWJAP=\"";
  cmd+=SSID;
  cmd+="\",\"";
  cmd+=PASS;
  cmd+="\"";
  Serial.println(cmd);
  esp8266.println(cmd);
  delay(5000);
  if(esp8266.find("OK"))
  {
    return true;
  }
  else
  {
    return false;
  }
}

void getReadings(){
  raw_myTemp = analogRead(A1);
  Voltage = (raw_myTemp / 1023.0) * 5000; // 5000 to get millivots.
  tempC = Voltage * 0.1; 
  myTemp = (tempC * 1.8) + 32; // conver to F
  Serial.println(myTemp);
  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(myBPM);                        // Print the value inside of myBPM. 
}

  delay(20);            
    char buffer1[10];
     char buffer2[10];
    BPM = dtostrf(myBPM, 4, 1, buffer1);
    temp = dtostrf(myTemp, 4, 1, buffer2);  
  }

void panic_button(){
  panic = digitalRead(8);
    if(panic == HIGH){
    Serial.println(panic);
      String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  Serial.println(cmd);
  esp8266.println(cmd);
  delay(2000);
  if(esp8266.find("Error"))
  {
    return;
  }
  cmd = msg ;
  cmd += "&field3=";    
  cmd += panic;
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  esp8266.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  esp8266.println(cmd.length());
  if(esp8266.find(">"))
  {
    Serial.print(cmd);
    esp8266.print(cmd);
  }
  else
  {
    Serial.println("AT+CIPCLOSE");
    esp8266.println("AT+CIPCLOSE");
    //Resend...
    error=1;
  }
}
}

Hi Vetri,

Welcome to circuit digest forums.

While using forums make sure you brief you question properly. In your above question you have not mentioned what error you are facing. Copy the error message form your Arduino console and paste it here. It should help you get better answers 

The console is the black screen at the bottom of the IDE with orange font clour 

 

  Joined May 19, 2015      213
Tuesday at 03:45 PM

When I had compile IoT Based Patient Monitoring System using ESP8266 and Arduino code ,i had this  error.The error define below:

C:\Users\AISHAA~1\AppData\Local\Temp\ccKAbp0w.ltrans0.ltrans.o: In function `begin':

C:\Users\Aisha Anam\Documents\Arduino\libraries\PulseSensorPlayground-master\src/PulseSensorPlayground.cpp:55: undefined reference to `PulseSensorPlayground::UsingInterrupts'

C:\Users\Aisha Anam\Documents\Arduino\libraries\PulseSensorPlayground-master\src/PulseSensorPlayground.cpp:56: undefined reference to `PulseSensorPlaygroundSetupInterrupt()'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

 

 

 

  Joined October 27, 2018      4
Saturday at 12:14 PM

Are you aure the PulseSensorPlayground librarey for Arduino is added ?

  Joined August 11, 2018      35
Saturday at 01:52 PM

yes library is included

 

  Joined October 27, 2018      4
Saturday at 12:14 PM

Hi Aisha, welcome to CircuitDigest forums .......

For some reasons the author has messed with the macros. The #define statements should always be used ahead of the any program, even before you declare the libraries. 

In this case the line #define USE_ARDUINO_INTERRUPTS true     is used after including the header files which causes the compile time error.

Simply make the following changes and you are good to go. Cut the define codes and paste in on top of the program as shown below.

 

#define USE_ARDUINO_INTERRUPTS true    
#define DEBUG true
#define SSID "********"     // "SSID-WiFiname"
#define PASS "************" // "password"
#define IP "184.106.153.149"      // thingspeak.com ip

#include <SoftwareSerial.h>
#include "Timer.h"
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.   
Timer t;
PulseSensorPlayground pulseSensor;

 

All the best.

 

 

  Joined August 16, 2016      998
Tuesday at 12:29 AM

thanks its work it.when i uploaded program on arduino then serial moniter show this reading:

 

AT+CIPCLOSE
101.50
07:55:41.758 -> 121
07:55:41.758 -> AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPSEND=60
GET /update?key=MY2JD466BHTAH7ES&field1=121.0&field2=101.5
107.66
07:55:53.094 -> 176
07:55:53.094 -> AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPSEND=60
07:55:56.124 -> GET /update?key=MY2JD466BHTAH7ES&field1=176.0&field2=107.7
112.06
07:56:04.134 -> 218
AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPSEND=60
AT+CIPCLOSE
98.86
07:56:16.196 -> 224
07:56:16.196 -> AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPSEND=59
AT+CIPCLOSE
99.74
07:56:28.246 -> 135
AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPSEND=59
AT+CIPCLOSE
97.98
07:56:40.308 -> 220
07:56:40.308 -> AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPSEND=59
GET /update?key=MY2JD466BHTAH7ES&field1=220.0&field2=98.0

 

 

Now the problem is that arduino could not send an email on gmail account and pateint_info on thinkspeak.What do i do

  Joined October 27, 2018      4
Saturday at 12:14 PM

Hi,

Aisha, I am marking this thread as [SOLVED] since the compilation error you have posted for is solved. 

You can always open new threads to ask new questions. People will no longer be able to ask or answer on this thread. 

  Joined May 19, 2015      213
Tuesday at 03:45 PM