Problem in sending data to Cayenne using Uno with ESP8266-01

sorry, change EspSerial.begin to 9600 only.

Hi there, thanks again and sorry for the late reply.

After I reconstruct the code, I successfully upload the data to cayenne. It seems the same as the previous code but don’t know why it works, and the circuit setup also the same… Anyway, it works.

Thank you so much in helping me out.

Here is the code:

#define USE_ARDUINO_INTERRUPTS true    
#include <PulseSensorPlayground.h>       
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266Shield.h> 

//  Variables
const int PulseWire = 2;       
//const int LED13 = 13;          
//int Threshold = 550;           
                               
                                
                               
PulseSensorPlayground pulseSensor;  // Creates an instance of the PulseSensorPlayground object called "pulseSensor"

// WiFi network info.
char ssid[] = "";
char wifiPassword[] = "";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";

//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
#define EspSerial Serial1

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

void setup() {   

  Serial.begin(9600);         

  // Configure the PulseSensor object, by assigning our variables to it. 
  pulseSensor.analogInput(PulseWire);   
  //pulseSensor.blinkOnPulse(LED13);      
  //pulseSensor.setThreshold(Threshold); 

  EspSerial.begin(9600);
  delay(10);

  Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);

  
   if (pulseSensor.begin()) {
    Serial.println("We created a pulseSensor Object !");  //This prints one time at Arduino power-up,  or on Arduino reset.  
  }
}



void loop() {

 int myBPM = pulseSensor.getBeatsPerMinute();  
                                            

if (pulseSensor.sawStartOfBeat()) {             
 Serial.println("♥  A HeartBeat Happened ! "); 
 Serial.print("BPM: ");                         
 Serial.println(myBPM);                         
 Cayenne.virtualWrite(1,myBPM);
}

  delay(20);                    

}

Now, the next thing to do is increase the upload rate, because by using this code the data is being uploaded every 1 second. Hope can make it faster so that I can show the ECG as well…

Anyway, thanks again!

you cannot publish at a very high rate. have a look at this post-Sending MQTT messages within rate limits